Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 99c91df58e29a765ad5376ea0e6076a5451bdc99..9ea5c27122086b3eda7ba553becd42389f5a7a02 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -3207,7 +3207,7 @@ bool Map::InstancesNeedRewriting(Map* target, int target_number_of_fields, |
| void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map, |
| Handle<Map> new_map, |
| Isolate* isolate) { |
| - if (!old_map->is_prototype_map()) return; |
| + DCHECK(old_map->is_prototype_map()); |
| DCHECK(new_map->is_prototype_map()); |
| bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate); |
| new_map->set_prototype_info(old_map->prototype_info()); |
| @@ -3567,22 +3567,28 @@ void MigrateFastToSlow(Handle<JSObject> object, Handle<Map> new_map, |
| } // namespace |
| +// static |
| +void JSObject::NotifyMapChange(Handle<Map> old_map, Handle<Map> new_map, |
| + Isolate* isolate) { |
| + if (!old_map->is_prototype_map()) return; |
| + |
| + // If this object is a prototype (the callee will check), invalidate any |
|
Jakob Kummerow
2016/11/16 17:15:35
nit: outdated comment. I'd just drop it, the metho
Igor Sheludko
2016/11/16 17:20:03
Done.
|
| + // prototype chains involving it. |
| + InvalidatePrototypeChains(*old_map); |
| + |
| + // If the map was registered with its prototype before, ensure that it |
| + // registers with its new prototype now. This preserves the invariant that |
| + // when a map on a prototype chain is registered with its prototype, then |
| + // all prototypes further up the chain are also registered with their |
| + // respective prototypes. |
| + UpdatePrototypeUserRegistration(old_map, new_map, new_map->GetIsolate()); |
|
Jakob Kummerow
2016/11/16 17:15:35
nit: s/new_map->GetIsolate()/isolate/
Igor Sheludko
2016/11/16 17:20:03
Done.
|
| +} |
| + |
| void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map, |
| int expected_additional_properties) { |
| if (object->map() == *new_map) return; |
| Handle<Map> old_map(object->map()); |
| - if (old_map->is_prototype_map()) { |
| - // If this object is a prototype (the callee will check), invalidate any |
| - // prototype chains involving it. |
| - InvalidatePrototypeChains(object->map()); |
| - |
| - // If the map was registered with its prototype before, ensure that it |
| - // registers with its new prototype now. This preserves the invariant that |
| - // when a map on a prototype chain is registered with its prototype, then |
| - // all prototypes further up the chain are also registered with their |
| - // respective prototypes. |
| - UpdatePrototypeUserRegistration(old_map, new_map, new_map->GetIsolate()); |
| - } |
| + NotifyMapChange(old_map, new_map, new_map->GetIsolate()); |
| if (old_map->is_dictionary_map()) { |
| // For slow-to-fast migrations JSObject::MigrateSlowToFast() |
| @@ -6012,7 +6018,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object, |
| Handle<Map> new_map = Map::CopyDropDescriptors(old_map); |
| new_map->set_dictionary_map(false); |
| - UpdatePrototypeUserRegistration(old_map, new_map, isolate); |
| + NotifyMapChange(old_map, new_map, isolate); |
| #if TRACE_MAPS |
| if (FLAG_trace_maps) { |
| @@ -12704,7 +12710,7 @@ bool JSObject::UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate) { |
| static void InvalidatePrototypeChainsInternal(Map* map) { |
| - if (!map->is_prototype_map()) return; |
| + DCHECK(map->is_prototype_map()); |
| if (FLAG_trace_prototype_users) { |
| PrintF("Invalidating prototype map %p 's cell\n", |
| reinterpret_cast<void*>(map)); |