Commit 3a12bbe0 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Handlify Runtime::InitializeIntrinsicFunctionNames.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/236133005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20718 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b280ad6c
......@@ -1318,17 +1318,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,
Handle<Map> map) {
CALL_HEAP_FUNCTION(isolate,
......@@ -1371,7 +1360,7 @@ Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) {
Handle<Name> name(descs->GetKey(i));
Handle<Object> value(descs->GetCallbacksObject(i), isolate());
Handle<PropertyCell> cell = NewPropertyCell(value);
NameDictionaryAdd(dictionary, name, cell, d);
NameDictionary::Add(dictionary, name, cell, d);
}
// Allocate the global object and initialize it with the backing store.
......
......@@ -2996,10 +2996,6 @@ bool Heap::CreateInitialObjects() {
NameDictionary::Allocate(this, Runtime::kNumFunctions);
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));
{ MaybeObject* maybe_obj = AllocateInitialNumberStringCache();
......@@ -6180,6 +6176,11 @@ bool Heap::CreateHeapObjects() {
array_buffers_list_ = undefined_value();
allocation_sites_list_ = undefined_value();
weak_object_to_code_table_ = undefined_value();
HandleScope scope(isolate());
Runtime::InitializeIntrinsicFunctionNames(
isolate(), handle(intrinsic_function_names(), isolate()));
return true;
}
......
......@@ -633,17 +633,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,
Handle<Name> name,
Handle<Object> value,
......@@ -664,7 +653,7 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
}
property_dictionary =
NameDictionaryAdd(property_dictionary, name, store_value, details);
NameDictionary::Add(property_dictionary, name, store_value, details);
object->set_properties(*property_dictionary);
return;
}
......@@ -1944,7 +1933,8 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
value = cell;
}
PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
Handle<NameDictionary> result = NameDictionaryAdd(dict, name, value, details);
Handle<NameDictionary> result =
NameDictionary::Add(dict, name, value, details);
if (*dict != *result) object->set_properties(*result);
}
......@@ -4503,7 +4493,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
Handle<Object> value(descs->GetConstant(i), isolate);
PropertyDetails d = PropertyDetails(
details.attributes(), NORMAL, i + 1);
dictionary = NameDictionaryAdd(dictionary, key, value, d);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
case FIELD: {
......@@ -4512,7 +4502,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate);
PropertyDetails d =
PropertyDetails(details.attributes(), NORMAL, i + 1);
dictionary = NameDictionaryAdd(dictionary, key, value, d);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
case CALLBACKS: {
......@@ -4520,7 +4510,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
Handle<Object> value(descs->GetCallbacksObject(i), isolate);
PropertyDetails d = PropertyDetails(
details.attributes(), CALLBACKS, i + 1);
dictionary = NameDictionaryAdd(dictionary, key, value, d);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
case INTERCEPTOR:
......@@ -14308,6 +14298,17 @@ template
int HashTable<SeededNumberDictionaryShape, uint32_t>::FindEntry(uint32_t);
Handle<NameDictionary> NameDictionary::Add(Handle<NameDictionary> dict,
Handle<Name> name,
Handle<Object> value,
PropertyDetails details) {
CALL_HEAP_FUNCTION(dict->GetIsolate(),
Handle<Dictionary>::cast(dict)->Add(
*name, *value, details),
NameDictionary);
}
Handle<Object> JSObject::PrepareSlowElementsForSort(
Handle<JSObject> object, uint32_t limit) {
CALL_HEAP_FUNCTION(object->GetIsolate(),
......@@ -14839,7 +14840,7 @@ Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell(
isolate->factory()->the_hole_value());
PropertyDetails details(NONE, NORMAL, 0);
details = details.AsDeleted();
Handle<NameDictionary> dictionary = NameDictionaryAdd(
Handle<NameDictionary> dictionary = NameDictionary::Add(
handle(global->property_dictionary()), name, cell, details);
global->set_properties(*dictionary);
return cell;
......
......@@ -4093,6 +4093,12 @@ class NameDictionary: public Dictionary<NameDictionaryShape, Name*> {
// Find entry for key, otherwise return kNotFound. Optimized version of
// HashTable::FindEntry.
int FindEntry(Name* key);
// TODO(mstarzinger): Temporary wrapper until handlified.
static Handle<NameDictionary> Add(Handle<NameDictionary> dict,
Handle<Name> name,
Handle<Object> value,
PropertyDetails details);
};
......
......@@ -15089,31 +15089,21 @@ static const Runtime::Function kIntrinsicFunctions[] = {
#undef F
MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
Object* dictionary) {
ASSERT(dictionary != NULL);
ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0);
void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate,
Handle<NameDictionary> dict) {
ASSERT(dict->NumberOfElements() == 0);
HandleScope scope(isolate);
for (int i = 0; i < kNumFunctions; ++i) {
const char* name = kIntrinsicFunctions[i].name;
if (name == NULL) continue;
Object* name_string;
{ MaybeObject* maybe_name_string =
heap->InternalizeUtf8String(name);
if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string;
}
NameDictionary* name_dictionary = NameDictionary::cast(dictionary);
{ MaybeObject* maybe_dictionary = name_dictionary->Add(
String::cast(name_string),
Smi::FromInt(i),
PropertyDetails(NONE, NORMAL, Representation::None()));
if (!maybe_dictionary->ToObject(&dictionary)) {
// Non-recoverable failure. Calling code must restart heap
// initialization.
return maybe_dictionary;
}
}
Handle<NameDictionary> new_dict = NameDictionary::Add(
dict,
isolate->factory()->InternalizeUtf8String(name),
Handle<Smi>(Smi::FromInt(i), isolate),
PropertyDetails(NONE, NORMAL, Representation::None()));
// The dictionary does not need to grow.
CHECK(new_dict.is_identical_to(dict));
}
return dictionary;
}
......
......@@ -798,11 +798,8 @@ class Runtime : public AllStatic {
// Add internalized strings for all the intrinsic function names to a
// StringDictionary.
// Returns failure if an allocation fails. In this case, it must be
// retried with a new, empty StringDictionary, not with the same one.
// Alternatively, heap initialization can be completely restarted.
MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames(
Heap* heap, Object* dictionary);
static void InitializeIntrinsicFunctionNames(Isolate* isolate,
Handle<NameDictionary> dict);
// Get the intrinsic function with the given name, which must be internalized.
static const Function* FunctionForName(Handle<String> name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment