Commit 2e0c2965 authored by ishell@chromium.org's avatar ishell@chromium.org

Dictionary::Add() handlified.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20948 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cb46971a
...@@ -1500,7 +1500,7 @@ Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) { ...@@ -1500,7 +1500,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);
NameDictionary::AddNameEntry(dictionary, name, cell, d); NameDictionary::Add(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.
......
...@@ -667,7 +667,7 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object, ...@@ -667,7 +667,7 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
store_value = object->GetIsolate()->factory()->NewPropertyCell(value); store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
} }
property_dictionary = NameDictionary::AddNameEntry( property_dictionary = NameDictionary::Add(
property_dictionary, name, store_value, details); property_dictionary, name, store_value, details);
object->set_properties(*property_dictionary); object->set_properties(*property_dictionary);
return; return;
...@@ -1942,7 +1942,7 @@ void JSObject::AddSlowProperty(Handle<JSObject> object, ...@@ -1942,7 +1942,7 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
} }
PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
Handle<NameDictionary> result = Handle<NameDictionary> result =
NameDictionary::AddNameEntry(dict, name, value, details); NameDictionary::Add(dict, name, value, details);
if (*dict != *result) object->set_properties(*result); if (*dict != *result) object->set_properties(*result);
} }
...@@ -4641,7 +4641,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object, ...@@ -4641,7 +4641,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 = NameDictionary::AddNameEntry(dictionary, key, value, d); dictionary = NameDictionary::Add(dictionary, key, value, d);
break; break;
} }
case FIELD: { case FIELD: {
...@@ -4650,7 +4650,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object, ...@@ -4650,7 +4650,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 = NameDictionary::AddNameEntry(dictionary, key, value, d); dictionary = NameDictionary::Add(dictionary, key, value, d);
break; break;
} }
case CALLBACKS: { case CALLBACKS: {
...@@ -4658,7 +4658,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object, ...@@ -4658,7 +4658,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 = NameDictionary::AddNameEntry(dictionary, key, value, d); dictionary = NameDictionary::Add(dictionary, key, value, d);
break; break;
} }
case INTERCEPTOR: case INTERCEPTOR:
...@@ -14988,9 +14988,9 @@ template int ...@@ -14988,9 +14988,9 @@ template int
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
NumberOfElementsFilterAttributes(PropertyAttributes); NumberOfElementsFilterAttributes(PropertyAttributes);
template MaybeObject* template Handle<NameDictionary>
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add( Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add(
Handle<Name>, Object*, PropertyDetails); Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails);
template MaybeObject* template MaybeObject*
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
...@@ -15000,13 +15000,19 @@ template int ...@@ -15000,13 +15000,19 @@ template int
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
NumberOfElementsFilterAttributes(PropertyAttributes); NumberOfElementsFilterAttributes(PropertyAttributes);
template MaybeObject* template Handle<SeededNumberDictionary>
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::Add( Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
uint32_t, Object*, PropertyDetails); Add(Handle<SeededNumberDictionary>,
uint32_t,
Handle<Object>,
PropertyDetails);
template MaybeObject* template Handle<UnseededNumberDictionary>
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
Add(uint32_t, Object*, PropertyDetails); Add(Handle<UnseededNumberDictionary>,
uint32_t,
Handle<Object>,
PropertyDetails);
template MaybeObject* template MaybeObject*
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
...@@ -15045,16 +15051,6 @@ int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: ...@@ -15045,16 +15051,6 @@ 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) {
ASSERT(object->HasDictionaryElements()); ASSERT(object->HasDictionaryElements());
...@@ -15495,7 +15491,7 @@ Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( ...@@ -15495,7 +15491,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 = NameDictionary::AddNameEntry( Handle<NameDictionary> dictionary = NameDictionary::Add(
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;
...@@ -15977,20 +15973,17 @@ Handle<Derived> Dictionary<Derived, Shape, Key>::AtPut( ...@@ -15977,20 +15973,17 @@ Handle<Derived> Dictionary<Derived, Shape, Key>::AtPut(
template<typename Derived, typename Shape, typename Key> template<typename Derived, typename Shape, typename Key>
MaybeObject* Dictionary<Derived, Shape, Key>::Add( Handle<Derived> Dictionary<Derived, Shape, Key>::Add(
Handle<Derived> dictionary,
Key key, Key key,
Object* value, Handle<Object> value,
PropertyDetails details) { PropertyDetails details) {
// Valdate key is absent. // Valdate key is absent.
SLOW_ASSERT((this->FindEntry(key) == Dictionary::kNotFound)); SLOW_ASSERT((dictionary->FindEntry(key) == Dictionary::kNotFound));
// Check whether the dictionary should be extended. // Check whether the dictionary should be extended.
Object* obj; dictionary = EnsureCapacity(dictionary, 1, key);
{ MaybeObject* maybe_obj = EnsureCapacity(1, key);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
return Dictionary::cast(obj)->AddEntry( return AddEntry(dictionary, key, value, details, dictionary->Hash(key));
key, value, details, Dictionary::Hash(key));
} }
...@@ -16066,9 +16059,7 @@ Handle<SeededNumberDictionary> SeededNumberDictionary::AddNumberEntry( ...@@ -16066,9 +16059,7 @@ Handle<SeededNumberDictionary> SeededNumberDictionary::AddNumberEntry(
PropertyDetails details) { PropertyDetails details) {
dictionary->UpdateMaxNumberKey(key); dictionary->UpdateMaxNumberKey(key);
SLOW_ASSERT(dictionary->FindEntry(key) == kNotFound); SLOW_ASSERT(dictionary->FindEntry(key) == kNotFound);
CALL_HEAP_FUNCTION(dictionary->GetIsolate(), return Add(dictionary, key, value, details);
dictionary->Add(key, *value, details),
SeededNumberDictionary);
} }
...@@ -16077,10 +16068,7 @@ Handle<UnseededNumberDictionary> UnseededNumberDictionary::AddNumberEntry( ...@@ -16077,10 +16068,7 @@ Handle<UnseededNumberDictionary> UnseededNumberDictionary::AddNumberEntry(
uint32_t key, uint32_t key,
Handle<Object> value) { Handle<Object> value) {
SLOW_ASSERT(dictionary->FindEntry(key) == kNotFound); SLOW_ASSERT(dictionary->FindEntry(key) == kNotFound);
CALL_HEAP_FUNCTION(dictionary->GetIsolate(), return Add(dictionary, key, value, PropertyDetails(NONE, NORMAL, 0));
dictionary->Add(
key, *value, PropertyDetails(NONE, NORMAL, 0)),
UnseededNumberDictionary);
} }
......
...@@ -4064,7 +4064,7 @@ class Dictionary: public HashTable<Derived, Shape, Key> { ...@@ -4064,7 +4064,7 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
// Creates a new dictionary. // Creates a new dictionary.
static Handle<Derived> New( MUST_USE_RESULT static Handle<Derived> New(
Isolate* isolate, Isolate* isolate,
int at_least_space_for, int at_least_space_for,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
...@@ -4089,9 +4089,11 @@ class Dictionary: public HashTable<Derived, Shape, Key> { ...@@ -4089,9 +4089,11 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
Object* value, Object* value,
PropertyDetails details); PropertyDetails details);
MUST_USE_RESULT MaybeObject* Add(Key key, MUST_USE_RESULT static Handle<Derived> Add(
Object* value, Handle<Derived> dictionary,
PropertyDetails details); Key key,
Handle<Object> value,
PropertyDetails details);
protected: protected:
// Generic at put operation. // Generic at put operation.
...@@ -4153,12 +4155,6 @@ class NameDictionary: public Dictionary<NameDictionary, ...@@ -4153,12 +4155,6 @@ class NameDictionary: public Dictionary<NameDictionary,
// TODO(ishell): Remove this when all the callers are handlified. // TODO(ishell): Remove this when all the callers are handlified.
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);
}; };
......
...@@ -15125,7 +15125,7 @@ void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, ...@@ -15125,7 +15125,7 @@ void Runtime::InitializeIntrinsicFunctionNames(Isolate* 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;
Handle<NameDictionary> new_dict = NameDictionary::AddNameEntry( Handle<NameDictionary> new_dict = NameDictionary::Add(
dict, dict,
isolate->factory()->InternalizeUtf8String(name), isolate->factory()->InternalizeUtf8String(name),
Handle<Smi>(Smi::FromInt(i), isolate), Handle<Smi>(Smi::FromInt(i), isolate),
......
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