OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 8689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8700 // for the global object and its prototype chain, and excluding it saves | 8700 // for the global object and its prototype chain, and excluding it saves |
8701 // memory on the map transition tree. | 8701 // memory on the map transition tree. |
8702 | 8702 |
8703 // static | 8703 // static |
8704 Handle<Map> Map::TransitionToImmutableProto(Handle<Map> map) { | 8704 Handle<Map> Map::TransitionToImmutableProto(Handle<Map> map) { |
8705 Handle<Map> new_map = Map::Copy(map, "ImmutablePrototype"); | 8705 Handle<Map> new_map = Map::Copy(map, "ImmutablePrototype"); |
8706 new_map->set_immutable_proto(true); | 8706 new_map->set_immutable_proto(true); |
8707 return new_map; | 8707 return new_map; |
8708 } | 8708 } |
8709 | 8709 |
8710 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, | 8710 namespace { |
8711 int in_object_properties, | 8711 void EnsureInitialMap(Handle<Map> map) { |
8712 int unused_property_fields) { | |
8713 #ifdef DEBUG | 8712 #ifdef DEBUG |
8714 Isolate* isolate = map->GetIsolate(); | 8713 Isolate* isolate = map->GetIsolate(); |
8715 // Strict function maps have Function as a constructor but the | 8714 // Strict function maps have Function as a constructor but the |
8716 // Function's initial map is a sloppy function map. Same holds for | 8715 // Function's initial map is a sloppy function map. Same holds for |
8717 // GeneratorFunction / AsyncFunction and its initial map. | 8716 // GeneratorFunction / AsyncFunction and its initial map. |
8718 Object* constructor = map->GetConstructor(); | 8717 Object* constructor = map->GetConstructor(); |
8719 DCHECK(constructor->IsJSFunction()); | 8718 DCHECK(constructor->IsJSFunction()); |
8720 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || | 8719 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || |
8721 *map == *isolate->strict_function_map() || | 8720 *map == *isolate->strict_function_map() || |
8722 *map == *isolate->generator_function_map() || | 8721 *map == *isolate->generator_function_map() || |
8723 *map == *isolate->async_function_map()); | 8722 *map == *isolate->async_function_map()); |
8724 #endif | 8723 #endif |
8725 // Initial maps must always own their descriptors and it's descriptor array | 8724 // Initial maps must always own their descriptors and it's descriptor array |
8726 // does not contain descriptors that do not belong to the map. | 8725 // does not contain descriptors that do not belong to the map. |
8727 DCHECK(map->owns_descriptors()); | 8726 DCHECK(map->owns_descriptors()); |
8728 DCHECK_EQ(map->NumberOfOwnDescriptors(), | 8727 DCHECK_EQ(map->NumberOfOwnDescriptors(), |
8729 map->instance_descriptors()->number_of_descriptors()); | 8728 map->instance_descriptors()->number_of_descriptors()); |
| 8729 } |
| 8730 } // namespace |
8730 | 8731 |
| 8732 // static |
| 8733 Handle<Map> Map::CopyInitialMapNormalized(Handle<Map> map, |
| 8734 PropertyNormalizationMode mode) { |
| 8735 EnsureInitialMap(map); |
| 8736 return CopyNormalized(map, mode); |
| 8737 } |
| 8738 |
| 8739 // static |
| 8740 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, |
| 8741 int in_object_properties, |
| 8742 int unused_property_fields) { |
| 8743 EnsureInitialMap(map); |
8731 Handle<Map> result = RawCopy(map, instance_size); | 8744 Handle<Map> result = RawCopy(map, instance_size); |
8732 | 8745 |
8733 // Please note instance_type and instance_size are set when allocated. | 8746 // Please note instance_type and instance_size are set when allocated. |
8734 result->SetInObjectProperties(in_object_properties); | 8747 result->SetInObjectProperties(in_object_properties); |
8735 result->set_unused_property_fields(unused_property_fields); | 8748 result->set_unused_property_fields(unused_property_fields); |
8736 | 8749 |
8737 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 8750 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
8738 if (number_of_own_descriptors > 0) { | 8751 if (number_of_own_descriptors > 0) { |
8739 // The copy will use the same descriptors array. | 8752 // The copy will use the same descriptors array. |
8740 result->UpdateDescriptors(map->instance_descriptors(), | 8753 result->UpdateDescriptors(map->instance_descriptors(), |
(...skipping 11903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20644 // depend on this. | 20657 // depend on this. |
20645 return DICTIONARY_ELEMENTS; | 20658 return DICTIONARY_ELEMENTS; |
20646 } | 20659 } |
20647 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20660 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20648 return kind; | 20661 return kind; |
20649 } | 20662 } |
20650 } | 20663 } |
20651 | 20664 |
20652 } // namespace internal | 20665 } // namespace internal |
20653 } // namespace v8 | 20666 } // namespace v8 |
OLD | NEW |