| 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 8654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8665 // for the global object and its prototype chain, and excluding it saves | 8665 // for the global object and its prototype chain, and excluding it saves |
| 8666 // memory on the map transition tree. | 8666 // memory on the map transition tree. |
| 8667 | 8667 |
| 8668 // static | 8668 // static |
| 8669 Handle<Map> Map::TransitionToImmutableProto(Handle<Map> map) { | 8669 Handle<Map> Map::TransitionToImmutableProto(Handle<Map> map) { |
| 8670 Handle<Map> new_map = Map::Copy(map, "ImmutablePrototype"); | 8670 Handle<Map> new_map = Map::Copy(map, "ImmutablePrototype"); |
| 8671 new_map->set_immutable_proto(true); | 8671 new_map->set_immutable_proto(true); |
| 8672 return new_map; | 8672 return new_map; |
| 8673 } | 8673 } |
| 8674 | 8674 |
| 8675 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, | 8675 namespace { |
| 8676 int in_object_properties, | 8676 void EnsureInitialMap(Handle<Map> map) { |
| 8677 int unused_property_fields) { | |
| 8678 #ifdef DEBUG | 8677 #ifdef DEBUG |
| 8679 Isolate* isolate = map->GetIsolate(); | 8678 Isolate* isolate = map->GetIsolate(); |
| 8680 // Strict function maps have Function as a constructor but the | 8679 // Strict function maps have Function as a constructor but the |
| 8681 // Function's initial map is a sloppy function map. Same holds for | 8680 // Function's initial map is a sloppy function map. Same holds for |
| 8682 // GeneratorFunction / AsyncFunction and its initial map. | 8681 // GeneratorFunction / AsyncFunction and its initial map. |
| 8683 Object* constructor = map->GetConstructor(); | 8682 Object* constructor = map->GetConstructor(); |
| 8684 DCHECK(constructor->IsJSFunction()); | 8683 DCHECK(constructor->IsJSFunction()); |
| 8685 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || | 8684 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || |
| 8686 *map == *isolate->strict_function_map() || | 8685 *map == *isolate->strict_function_map() || |
| 8687 *map == *isolate->generator_function_map() || | 8686 *map == *isolate->generator_function_map() || |
| 8688 *map == *isolate->async_function_map()); | 8687 *map == *isolate->async_function_map()); |
| 8689 #endif | 8688 #endif |
| 8690 // Initial maps must always own their descriptors and it's descriptor array | 8689 // Initial maps must always own their descriptors and it's descriptor array |
| 8691 // does not contain descriptors that do not belong to the map. | 8690 // does not contain descriptors that do not belong to the map. |
| 8692 DCHECK(map->owns_descriptors()); | 8691 DCHECK(map->owns_descriptors()); |
| 8693 DCHECK_EQ(map->NumberOfOwnDescriptors(), | 8692 DCHECK_EQ(map->NumberOfOwnDescriptors(), |
| 8694 map->instance_descriptors()->number_of_descriptors()); | 8693 map->instance_descriptors()->number_of_descriptors()); |
| 8694 } |
| 8695 } // namespace |
| 8695 | 8696 |
| 8697 // static |
| 8698 Handle<Map> Map::CopyInitialMapNormalized(Handle<Map> map, |
| 8699 PropertyNormalizationMode mode) { |
| 8700 EnsureInitialMap(map); |
| 8701 return CopyNormalized(map, mode); |
| 8702 } |
| 8703 |
| 8704 // static |
| 8705 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, |
| 8706 int in_object_properties, |
| 8707 int unused_property_fields) { |
| 8708 EnsureInitialMap(map); |
| 8696 Handle<Map> result = RawCopy(map, instance_size); | 8709 Handle<Map> result = RawCopy(map, instance_size); |
| 8697 | 8710 |
| 8698 // Please note instance_type and instance_size are set when allocated. | 8711 // Please note instance_type and instance_size are set when allocated. |
| 8699 result->SetInObjectProperties(in_object_properties); | 8712 result->SetInObjectProperties(in_object_properties); |
| 8700 result->set_unused_property_fields(unused_property_fields); | 8713 result->set_unused_property_fields(unused_property_fields); |
| 8701 | 8714 |
| 8702 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 8715 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
| 8703 if (number_of_own_descriptors > 0) { | 8716 if (number_of_own_descriptors > 0) { |
| 8704 // The copy will use the same descriptors array. | 8717 // The copy will use the same descriptors array. |
| 8705 result->UpdateDescriptors(map->instance_descriptors(), | 8718 result->UpdateDescriptors(map->instance_descriptors(), |
| (...skipping 11581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20287 // depend on this. | 20300 // depend on this. |
| 20288 return DICTIONARY_ELEMENTS; | 20301 return DICTIONARY_ELEMENTS; |
| 20289 } | 20302 } |
| 20290 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20303 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20291 return kind; | 20304 return kind; |
| 20292 } | 20305 } |
| 20293 } | 20306 } |
| 20294 | 20307 |
| 20295 } // namespace internal | 20308 } // namespace internal |
| 20296 } // namespace v8 | 20309 } // namespace v8 |
| OLD | NEW |