Reland "Handlify Runtime::InitializeIntrinsicFunctionNames."
R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/236823003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20738 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
22f7451e6c
commit
123a271e72
@ -1332,17 +1332,6 @@ Handle<JSModule> Factory::NewJSModule(Handle<Context> context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO(mstarzinger): Temporary wrapper until handlified.
|
|
||||||
static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict,
|
|
||||||
Handle<Name> name,
|
|
||||||
Handle<Object> value,
|
|
||||||
PropertyDetails details) {
|
|
||||||
CALL_HEAP_FUNCTION(dict->GetIsolate(),
|
|
||||||
dict->Add(*name, *value, details),
|
|
||||||
NameDictionary);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static Handle<GlobalObject> NewGlobalObjectFromMap(Isolate* isolate,
|
static Handle<GlobalObject> NewGlobalObjectFromMap(Isolate* isolate,
|
||||||
Handle<Map> map) {
|
Handle<Map> map) {
|
||||||
CALL_HEAP_FUNCTION(isolate,
|
CALL_HEAP_FUNCTION(isolate,
|
||||||
@ -1385,7 +1374,7 @@ Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) {
|
|||||||
Handle<Name> name(descs->GetKey(i));
|
Handle<Name> name(descs->GetKey(i));
|
||||||
Handle<Object> value(descs->GetCallbacksObject(i), isolate());
|
Handle<Object> value(descs->GetCallbacksObject(i), isolate());
|
||||||
Handle<PropertyCell> cell = NewPropertyCell(value);
|
Handle<PropertyCell> cell = NewPropertyCell(value);
|
||||||
NameDictionaryAdd(dictionary, name, cell, d);
|
NameDictionary::AddNameEntry(dictionary, name, cell, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate the global object and initialize it with the backing store.
|
// Allocate the global object and initialize it with the backing store.
|
||||||
|
@ -2996,10 +2996,6 @@ bool Heap::CreateInitialObjects() {
|
|||||||
NameDictionary::Allocate(this, Runtime::kNumFunctions);
|
NameDictionary::Allocate(this, Runtime::kNumFunctions);
|
||||||
if (!maybe_obj->ToObject(&obj)) return false;
|
if (!maybe_obj->ToObject(&obj)) return false;
|
||||||
}
|
}
|
||||||
{ MaybeObject* maybe_obj = Runtime::InitializeIntrinsicFunctionNames(this,
|
|
||||||
obj);
|
|
||||||
if (!maybe_obj->ToObject(&obj)) return false;
|
|
||||||
}
|
|
||||||
set_intrinsic_function_names(NameDictionary::cast(obj));
|
set_intrinsic_function_names(NameDictionary::cast(obj));
|
||||||
|
|
||||||
{ MaybeObject* maybe_obj = AllocateInitialNumberStringCache();
|
{ MaybeObject* maybe_obj = AllocateInitialNumberStringCache();
|
||||||
@ -6113,6 +6109,11 @@ bool Heap::CreateHeapObjects() {
|
|||||||
array_buffers_list_ = undefined_value();
|
array_buffers_list_ = undefined_value();
|
||||||
allocation_sites_list_ = undefined_value();
|
allocation_sites_list_ = undefined_value();
|
||||||
weak_object_to_code_table_ = undefined_value();
|
weak_object_to_code_table_ = undefined_value();
|
||||||
|
|
||||||
|
HandleScope scope(isolate());
|
||||||
|
Runtime::InitializeIntrinsicFunctionNames(
|
||||||
|
isolate(), handle(intrinsic_function_names(), isolate()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,17 +634,6 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO(mstarzinger): Temporary wrapper until handlified.
|
|
||||||
static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict,
|
|
||||||
Handle<Name> name,
|
|
||||||
Handle<Object> value,
|
|
||||||
PropertyDetails details) {
|
|
||||||
CALL_HEAP_FUNCTION(dict->GetIsolate(),
|
|
||||||
dict->Add(*name, *value, details),
|
|
||||||
NameDictionary);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
void JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
||||||
Handle<Name> name,
|
Handle<Name> name,
|
||||||
Handle<Object> value,
|
Handle<Object> value,
|
||||||
@ -664,8 +653,8 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
|||||||
store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
|
store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
property_dictionary =
|
property_dictionary = NameDictionary::AddNameEntry(
|
||||||
NameDictionaryAdd(property_dictionary, name, store_value, details);
|
property_dictionary, name, store_value, details);
|
||||||
object->set_properties(*property_dictionary);
|
object->set_properties(*property_dictionary);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1914,7 +1903,8 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
|
|||||||
value = cell;
|
value = cell;
|
||||||
}
|
}
|
||||||
PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
|
PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
|
||||||
Handle<NameDictionary> result = NameDictionaryAdd(dict, name, value, details);
|
Handle<NameDictionary> result =
|
||||||
|
NameDictionary::AddNameEntry(dict, name, value, details);
|
||||||
if (*dict != *result) object->set_properties(*result);
|
if (*dict != *result) object->set_properties(*result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4473,7 +4463,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
|
|||||||
Handle<Object> value(descs->GetConstant(i), isolate);
|
Handle<Object> value(descs->GetConstant(i), isolate);
|
||||||
PropertyDetails d = PropertyDetails(
|
PropertyDetails d = PropertyDetails(
|
||||||
details.attributes(), NORMAL, i + 1);
|
details.attributes(), NORMAL, i + 1);
|
||||||
dictionary = NameDictionaryAdd(dictionary, key, value, d);
|
dictionary = NameDictionary::AddNameEntry(dictionary, key, value, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FIELD: {
|
case FIELD: {
|
||||||
@ -4482,7 +4472,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
|
|||||||
object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate);
|
object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate);
|
||||||
PropertyDetails d =
|
PropertyDetails d =
|
||||||
PropertyDetails(details.attributes(), NORMAL, i + 1);
|
PropertyDetails(details.attributes(), NORMAL, i + 1);
|
||||||
dictionary = NameDictionaryAdd(dictionary, key, value, d);
|
dictionary = NameDictionary::AddNameEntry(dictionary, key, value, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLBACKS: {
|
case CALLBACKS: {
|
||||||
@ -4490,7 +4480,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
|
|||||||
Handle<Object> value(descs->GetCallbacksObject(i), isolate);
|
Handle<Object> value(descs->GetCallbacksObject(i), isolate);
|
||||||
PropertyDetails d = PropertyDetails(
|
PropertyDetails d = PropertyDetails(
|
||||||
details.attributes(), CALLBACKS, i + 1);
|
details.attributes(), CALLBACKS, i + 1);
|
||||||
dictionary = NameDictionaryAdd(dictionary, key, value, d);
|
dictionary = NameDictionary::AddNameEntry(dictionary, key, value, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case INTERCEPTOR:
|
case INTERCEPTOR:
|
||||||
@ -14320,6 +14310,16 @@ int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
|
|||||||
FindEntry(uint32_t);
|
FindEntry(uint32_t);
|
||||||
|
|
||||||
|
|
||||||
|
Handle<NameDictionary> NameDictionary::AddNameEntry(Handle<NameDictionary> dict,
|
||||||
|
Handle<Name> name,
|
||||||
|
Handle<Object> value,
|
||||||
|
PropertyDetails details) {
|
||||||
|
CALL_HEAP_FUNCTION(dict->GetIsolate(),
|
||||||
|
dict->Add(*name, *value, details),
|
||||||
|
NameDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Object> JSObject::PrepareSlowElementsForSort(
|
Handle<Object> JSObject::PrepareSlowElementsForSort(
|
||||||
Handle<JSObject> object, uint32_t limit) {
|
Handle<JSObject> object, uint32_t limit) {
|
||||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||||
@ -14851,7 +14851,7 @@ Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell(
|
|||||||
isolate->factory()->the_hole_value());
|
isolate->factory()->the_hole_value());
|
||||||
PropertyDetails details(NONE, NORMAL, 0);
|
PropertyDetails details(NONE, NORMAL, 0);
|
||||||
details = details.AsDeleted();
|
details = details.AsDeleted();
|
||||||
Handle<NameDictionary> dictionary = NameDictionaryAdd(
|
Handle<NameDictionary> dictionary = NameDictionary::AddNameEntry(
|
||||||
handle(global->property_dictionary()), name, cell, details);
|
handle(global->property_dictionary()), name, cell, details);
|
||||||
global->set_properties(*dictionary);
|
global->set_properties(*dictionary);
|
||||||
return cell;
|
return cell;
|
||||||
|
@ -4107,6 +4107,12 @@ class NameDictionary: public Dictionary<NameDictionary,
|
|||||||
// Find entry for key, otherwise return kNotFound. Optimized version of
|
// Find entry for key, otherwise return kNotFound. Optimized version of
|
||||||
// HashTable::FindEntry.
|
// HashTable::FindEntry.
|
||||||
int FindEntry(Name* key);
|
int FindEntry(Name* key);
|
||||||
|
|
||||||
|
// TODO(mstarzinger): Temporary wrapper until handlified.
|
||||||
|
static Handle<NameDictionary> AddNameEntry(Handle<NameDictionary> dict,
|
||||||
|
Handle<Name> name,
|
||||||
|
Handle<Object> value,
|
||||||
|
PropertyDetails details);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -15084,32 +15084,22 @@ static const Runtime::Function kIntrinsicFunctions[] = {
|
|||||||
#undef F
|
#undef F
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
|
void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate,
|
||||||
Object* dictionary) {
|
Handle<NameDictionary> dict) {
|
||||||
ASSERT(dictionary != NULL);
|
ASSERT(dict->NumberOfElements() == 0);
|
||||||
ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0);
|
HandleScope scope(isolate);
|
||||||
for (int i = 0; i < kNumFunctions; ++i) {
|
for (int i = 0; i < kNumFunctions; ++i) {
|
||||||
const char* name = kIntrinsicFunctions[i].name;
|
const char* name = kIntrinsicFunctions[i].name;
|
||||||
if (name == NULL) continue;
|
if (name == NULL) continue;
|
||||||
Object* name_string;
|
Handle<NameDictionary> new_dict = NameDictionary::AddNameEntry(
|
||||||
{ MaybeObject* maybe_name_string =
|
dict,
|
||||||
heap->InternalizeUtf8String(name);
|
isolate->factory()->InternalizeUtf8String(name),
|
||||||
if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string;
|
Handle<Smi>(Smi::FromInt(i), isolate),
|
||||||
}
|
|
||||||
NameDictionary* name_dictionary = NameDictionary::cast(dictionary);
|
|
||||||
{ MaybeObject* maybe_dictionary = name_dictionary->Add(
|
|
||||||
String::cast(name_string),
|
|
||||||
Smi::FromInt(i),
|
|
||||||
PropertyDetails(NONE, NORMAL, Representation::None()));
|
PropertyDetails(NONE, NORMAL, Representation::None()));
|
||||||
if (!maybe_dictionary->ToObject(&dictionary)) {
|
// The dictionary does not need to grow.
|
||||||
// Non-recoverable failure. Calling code must restart heap
|
CHECK(new_dict.is_identical_to(dict));
|
||||||
// initialization.
|
|
||||||
return maybe_dictionary;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return dictionary;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Runtime::Function* Runtime::FunctionForName(Handle<String> name) {
|
const Runtime::Function* Runtime::FunctionForName(Handle<String> name) {
|
||||||
|
@ -798,11 +798,8 @@ class Runtime : public AllStatic {
|
|||||||
|
|
||||||
// Add internalized strings for all the intrinsic function names to a
|
// Add internalized strings for all the intrinsic function names to a
|
||||||
// StringDictionary.
|
// StringDictionary.
|
||||||
// Returns failure if an allocation fails. In this case, it must be
|
static void InitializeIntrinsicFunctionNames(Isolate* isolate,
|
||||||
// retried with a new, empty StringDictionary, not with the same one.
|
Handle<NameDictionary> dict);
|
||||||
// Alternatively, heap initialization can be completely restarted.
|
|
||||||
MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames(
|
|
||||||
Heap* heap, Object* dictionary);
|
|
||||||
|
|
||||||
// Get the intrinsic function with the given name, which must be internalized.
|
// Get the intrinsic function with the given name, which must be internalized.
|
||||||
static const Function* FunctionForName(Handle<String> name);
|
static const Function* FunctionForName(Handle<String> name);
|
||||||
|
Loading…
Reference in New Issue
Block a user