Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 6dc5de2552847c8487da20604452705a7837143f..23edd137bb12aaee726599011974a038fd4a8a68 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -5014,7 +5014,8 @@ static Smi* GenerateIdentityHash(Isolate* isolate) { |
| void JSObject::SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash) { |
| DCHECK(!object->IsJSGlobalProxy()); |
| Isolate* isolate = object->GetIsolate(); |
| - SetHiddenProperty(object, isolate->factory()->identity_hash_string(), hash); |
| + Handle<Name> hash_code_symbol(isolate->heap()->hash_code_symbol()); |
| + JSObject::AddProperty(object, hash_code_symbol, hash, NONE); |
| } |
| @@ -5037,11 +5038,12 @@ Object* JSObject::GetIdentityHash() { |
| if (IsJSGlobalProxy()) { |
| return JSGlobalProxy::cast(this)->hash(); |
|
adamk
2015/05/19 17:39:38
To expand slightly on Toon's explanation, here's t
|
| } |
| - Object* stored_value = |
| - GetHiddenProperty(isolate->factory()->identity_hash_string()); |
| - return stored_value->IsSmi() |
| - ? stored_value |
| - : isolate->heap()->undefined_value(); |
| + Handle<Name> hash_code_symbol(isolate->heap()->hash_code_symbol()); |
| + Handle<Object> stored_value = |
| + Object::GetPropertyOrElement(Handle<Object>(this, isolate), |
| + hash_code_symbol).ToHandleChecked(); |
| + return stored_value->IsSmi() ? *stored_value |
| + : isolate->heap()->undefined_value(); |
| } |
| @@ -5056,7 +5058,8 @@ Handle<Smi> JSObject::GetOrCreateIdentityHash(Handle<JSObject> object) { |
| if (maybe_hash->IsSmi()) return Handle<Smi>::cast(maybe_hash); |
| Handle<Smi> hash(GenerateIdentityHash(isolate), isolate); |
| - SetHiddenProperty(object, isolate->factory()->identity_hash_string(), hash); |
| + Handle<Name> hash_code_symbol(isolate->heap()->hash_code_symbol()); |
| + JSObject::AddProperty(object, hash_code_symbol, hash, NONE); |
| return hash; |
| } |
| @@ -5075,8 +5078,6 @@ Object* JSObject::GetHiddenProperty(Handle<Name> key) { |
| DisallowHeapAllocation no_gc; |
| DCHECK(key->IsUniqueName()); |
| if (IsJSGlobalProxy()) { |
| - // JSGlobalProxies store their hash internally. |
| - DCHECK(*key != GetHeap()->identity_hash_string()); |
| // For a proxy, use the prototype as target object. |
| PrototypeIterator iter(GetIsolate(), this); |
| // If the proxy is detached, return undefined. |
| @@ -5087,15 +5088,7 @@ Object* JSObject::GetHiddenProperty(Handle<Name> key) { |
| DCHECK(!IsJSGlobalProxy()); |
| Object* inline_value = GetHiddenPropertiesHashTable(); |
| - if (inline_value->IsSmi()) { |
| - // Handle inline-stored identity hash. |
| - if (*key == GetHeap()->identity_hash_string()) { |
| - return inline_value; |
| - } else { |
| - return GetHeap()->the_hole_value(); |
| - } |
| - } |
| - |
| + DCHECK(!inline_value->IsSmi()); |
| if (inline_value->IsUndefined()) return GetHeap()->the_hole_value(); |
| ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value); |
| @@ -5111,8 +5104,6 @@ Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> object, |
| DCHECK(key->IsUniqueName()); |
| if (object->IsJSGlobalProxy()) { |
| - // JSGlobalProxies store their hash internally. |
| - DCHECK(*key != *isolate->factory()->identity_hash_string()); |
| // For a proxy, use the prototype as target object. |
| PrototypeIterator iter(isolate, object); |
| // If the proxy is detached, return undefined. |
| @@ -5126,13 +5117,6 @@ Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> object, |
| Handle<Object> inline_value(object->GetHiddenPropertiesHashTable(), isolate); |
| - // If there is no backing store yet, store the identity hash inline. |
| - if (value->IsSmi() && |
| - *key == *isolate->factory()->identity_hash_string() && |
| - (inline_value->IsUndefined() || inline_value->IsSmi())) { |
| - return JSObject::SetHiddenPropertiesHashTable(object, value); |
| - } |
| - |
| Handle<ObjectHashTable> hashtable = |
| GetOrCreateHiddenPropertiesHashtable(object); |
| @@ -5164,9 +5148,8 @@ void JSObject::DeleteHiddenProperty(Handle<JSObject> object, Handle<Name> key) { |
| Object* inline_value = object->GetHiddenPropertiesHashTable(); |
| - // We never delete (inline-stored) identity hashes. |
| - DCHECK(*key != *isolate->factory()->identity_hash_string()); |
| - if (inline_value->IsUndefined() || inline_value->IsSmi()) return; |
| + DCHECK(!inline_value->IsSmi()); |
| + if (inline_value->IsUndefined()) return; |
| Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); |
| bool was_present = false; |
| @@ -5230,14 +5213,7 @@ Handle<ObjectHashTable> JSObject::GetOrCreateHiddenPropertiesHashtable( |
| Handle<ObjectHashTable> hashtable = ObjectHashTable::New( |
| isolate, kInitialCapacity, USE_CUSTOM_MINIMUM_CAPACITY); |
| - if (inline_value->IsSmi()) { |
| - // We were storing the identity hash inline and now allocated an actual |
| - // dictionary. Put the identity hash into the new dictionary. |
| - hashtable = ObjectHashTable::Put(hashtable, |
| - isolate->factory()->identity_hash_string(), |
| - inline_value); |
| - } |
| - |
| + DCHECK(inline_value->IsUndefined()); |
| SetHiddenPropertiesHashTable(object, hashtable); |
| return hashtable; |
| } |