Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 98b3056eedf7e528247cf4624c63925aff438566..96335ac30af12dba9f9f256f12187849d461ebea 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -8857,14 +8857,7 @@ MaybeHandle<Object> JSObject::DefineAccessor(LookupIterator* it, |
| getter->IsFunctionTemplateInfo()); |
| DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull() || |
| getter->IsFunctionTemplateInfo()); |
| - // At least one of the accessors needs to be a new value. |
| - DCHECK(!getter->IsNull() || !setter->IsNull()); |
| - if (!getter->IsNull()) { |
| - it->TransitionToAccessorProperty(ACCESSOR_GETTER, getter, attributes); |
| - } |
| - if (!setter->IsNull()) { |
| - it->TransitionToAccessorProperty(ACCESSOR_SETTER, setter, attributes); |
| - } |
| + it->TransitionToAccessorProperty(getter, setter, attributes); |
| return isolate->factory()->undefined_value(); |
| } |
| @@ -9662,13 +9655,14 @@ Handle<Map> Map::ReconfigureExistingProperty(Handle<Map> map, int descriptor, |
| return new_map; |
| } |
| -Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map, |
| +Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map, |
| Handle<Name> name, int descriptor, |
| - AccessorComponent component, |
| - Handle<Object> accessor, |
| + Handle<Object> getter, |
| + Handle<Object> setter, |
| PropertyAttributes attributes) { |
| + // At least one of the accessors needs to be a new value. |
| + DCHECK(!getter->IsNull() || !setter->IsNull()); |
| DCHECK(name->IsUniqueName()); |
| - Isolate* isolate = name->GetIsolate(); |
| // Dictionary maps can always have additional data properties. |
| if (map->is_dictionary_map()) return map; |
| @@ -9697,7 +9691,7 @@ Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map, |
| } |
| Handle<AccessorPair> pair = Handle<AccessorPair>::cast(maybe_pair); |
| - if (pair->get(component) != *accessor) { |
| + if (!pair->Equals(*getter, *setter)) { |
| return Map::Normalize(map, mode, "TransitionToDifferentAccessor"); |
| } |
| @@ -9724,10 +9718,19 @@ Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map, |
| return Map::Normalize(map, mode, "AccessorsOverwritingNonPair"); |
| } |
| - Object* current = Handle<AccessorPair>::cast(maybe_pair)->get(component); |
| - if (current == *accessor) return map; |
| + Handle<AccessorPair> current_pair = Handle<AccessorPair>::cast(maybe_pair); |
| + if (current_pair->Equals(*getter, *setter)) return map; |
| - if (!current->IsTheHole()) { |
| + bool overwriting_accessor = false; |
| + if (!getter->IsNull() && !current_pair->get(ACCESSOR_GETTER)->IsTheHole() && |
|
Toon Verwaest
2016/05/04 09:32:42
What about just unifying the accessor-missing sent
|
| + current_pair->get(ACCESSOR_GETTER) != *getter) { |
| + overwriting_accessor = true; |
| + } |
| + if (!setter->IsNull() && !current_pair->get(ACCESSOR_SETTER)->IsTheHole() && |
| + current_pair->get(ACCESSOR_SETTER) != *setter) { |
| + overwriting_accessor = true; |
| + } |
| + if (overwriting_accessor) { |
| return Map::Normalize(map, mode, "AccessorsOverwritingAccessors"); |
| } |
| @@ -9739,7 +9742,8 @@ Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map, |
| pair = isolate->factory()->NewAccessorPair(); |
| } |
| - pair->set(component, *accessor); |
| + pair->SetComponents(*getter, *setter); |
|
Toon Verwaest
2016/05/04 09:32:42
Unless you do the above, this probably will alread
|
| + |
| TransitionFlag flag = INSERT_TRANSITION; |
| AccessorConstantDescriptor new_desc(name, pair, attributes); |
| return Map::CopyInsertDescriptor(map, &new_desc, flag); |