Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 1ef47c9ca305020157f328d763e1ad5325891892..56481065a289b9ae927f58d3a91287cf6566d137 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -5750,16 +5750,7 @@ MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) { |
| JSObject::MigrateToMap(object, transition_map); |
| } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) { |
| // Create a new descriptor array with fully-frozen properties |
| - int num_descriptors = old_map->NumberOfOwnDescriptors(); |
| - Handle<DescriptorArray> new_descriptors = |
| - DescriptorArray::CopyUpToAddAttributes( |
| - handle(old_map->instance_descriptors()), num_descriptors, FROZEN); |
| - Handle<Map> new_map = Map::CopyReplaceDescriptors( |
| - old_map, new_descriptors, INSERT_TRANSITION, |
| - isolate->factory()->frozen_symbol()); |
| - new_map->freeze(); |
| - new_map->set_is_extensible(false); |
| - new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
| + Handle<Map> new_map = Map::CopyForFreeze(old_map); |
| JSObject::MigrateToMap(object, new_map); |
| } else { |
| // Slow path: need to normalize properties for safety |
| @@ -6956,15 +6947,6 @@ Handle<Map> Map::ShareDescriptor(Handle<Map> map, |
| Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, |
| Handle<DescriptorArray> descriptors, |
| TransitionFlag flag, |
| - SimpleTransitionFlag simple_flag) { |
| - return CopyReplaceDescriptors( |
| - map, descriptors, flag, Handle<Name>::null(), simple_flag); |
| -} |
| - |
| - |
| -Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, |
| - Handle<DescriptorArray> descriptors, |
| - TransitionFlag flag, |
| Handle<Name> name, |
|
Igor Sheludko
2014/04/16 10:26:21
While we are here: since name can be null handle p
Toon Verwaest
2014/04/16 11:16:47
Done.
|
| SimpleTransitionFlag simple_flag) { |
| ASSERT(descriptors->IsSortedNoDuplicates()); |
| @@ -7109,7 +7091,8 @@ Handle<Map> Map::Copy(Handle<Map> map) { |
| int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
| Handle<DescriptorArray> new_descriptors = |
| DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors); |
| - return CopyReplaceDescriptors(map, new_descriptors, OMIT_TRANSITION); |
| + return CopyReplaceDescriptors( |
| + map, new_descriptors, OMIT_TRANSITION, Handle<Name>()); |
| } |
| @@ -7142,6 +7125,20 @@ Handle<Map> Map::Create(Handle<JSFunction> constructor, |
| } |
| +Handle<Map> Map::CopyForFreeze(Handle<Map> map) { |
| + int num_descriptors = map->NumberOfOwnDescriptors(); |
| + Isolate* isolate = map->GetIsolate(); |
| + Handle<DescriptorArray> new_desc = DescriptorArray::CopyUpToAddAttributes( |
| + handle(map->instance_descriptors(), isolate), num_descriptors, FROZEN); |
| + Handle<Map> new_map = Map::CopyReplaceDescriptors( |
| + map, new_desc, INSERT_TRANSITION, isolate->factory()->frozen_symbol()); |
| + new_map->freeze(); |
| + new_map->set_is_extensible(false); |
| + new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
| + return new_map; |
| +} |
| + |
| + |
| Handle<Map> Map::CopyAddDescriptor(Handle<Map> map, |
| Descriptor* descriptor, |
| TransitionFlag flag) { |