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 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2753 } | 2753 } |
2754 accumulator->Add(" (SharedFunctionInfo %p)", | 2754 accumulator->Add(" (SharedFunctionInfo %p)", |
2755 reinterpret_cast<void*>(function->shared())); | 2755 reinterpret_cast<void*>(function->shared())); |
2756 accumulator->Put('>'); | 2756 accumulator->Put('>'); |
2757 break; | 2757 break; |
2758 } | 2758 } |
2759 case JS_GENERATOR_OBJECT_TYPE: { | 2759 case JS_GENERATOR_OBJECT_TYPE: { |
2760 accumulator->Add("<JS Generator>"); | 2760 accumulator->Add("<JS Generator>"); |
2761 break; | 2761 break; |
2762 } | 2762 } |
| 2763 case JS_ASYNC_GENERATOR_OBJECT_TYPE: { |
| 2764 accumulator->Add("<JS AsyncGenerator>"); |
| 2765 break; |
| 2766 } |
| 2767 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: { |
| 2768 accumulator->Add("<JS AsyncFromSyncIterator>"); |
| 2769 break; |
| 2770 } |
2763 // All other JSObjects are rather similar to each other (JSObject, | 2771 // All other JSObjects are rather similar to each other (JSObject, |
2764 // JSGlobalProxy, JSGlobalObject, JSUndetectable, JSValue). | 2772 // JSGlobalProxy, JSGlobalObject, JSUndetectable, JSValue). |
2765 default: { | 2773 default: { |
2766 Map* map_of_this = map(); | 2774 Map* map_of_this = map(); |
2767 Heap* heap = GetHeap(); | 2775 Heap* heap = GetHeap(); |
2768 Object* constructor = map_of_this->GetConstructor(); | 2776 Object* constructor = map_of_this->GetConstructor(); |
2769 bool printed = false; | 2777 bool printed = false; |
2770 if (constructor->IsHeapObject() && | 2778 if (constructor->IsHeapObject() && |
2771 !heap->Contains(HeapObject::cast(constructor))) { | 2779 !heap->Contains(HeapObject::cast(constructor))) { |
2772 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); | 2780 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); |
(...skipping 6486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9259 #ifdef DEBUG | 9267 #ifdef DEBUG |
9260 Isolate* isolate = map->GetIsolate(); | 9268 Isolate* isolate = map->GetIsolate(); |
9261 // Strict function maps have Function as a constructor but the | 9269 // Strict function maps have Function as a constructor but the |
9262 // Function's initial map is a sloppy function map. Same holds for | 9270 // Function's initial map is a sloppy function map. Same holds for |
9263 // GeneratorFunction / AsyncFunction and its initial map. | 9271 // GeneratorFunction / AsyncFunction and its initial map. |
9264 Object* constructor = map->GetConstructor(); | 9272 Object* constructor = map->GetConstructor(); |
9265 DCHECK(constructor->IsJSFunction()); | 9273 DCHECK(constructor->IsJSFunction()); |
9266 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || | 9274 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || |
9267 *map == *isolate->strict_function_map() || | 9275 *map == *isolate->strict_function_map() || |
9268 *map == *isolate->generator_function_map() || | 9276 *map == *isolate->generator_function_map() || |
9269 *map == *isolate->async_function_map()); | 9277 *map == *isolate->async_function_map() || |
| 9278 *map == *isolate->async_generator_function_map()); |
9270 #endif | 9279 #endif |
9271 // Initial maps must always own their descriptors and it's descriptor array | 9280 // Initial maps must always own their descriptors and it's descriptor array |
9272 // does not contain descriptors that do not belong to the map. | 9281 // does not contain descriptors that do not belong to the map. |
9273 DCHECK(map->owns_descriptors()); | 9282 DCHECK(map->owns_descriptors()); |
9274 DCHECK_EQ(map->NumberOfOwnDescriptors(), | 9283 DCHECK_EQ(map->NumberOfOwnDescriptors(), |
9275 map->instance_descriptors()->number_of_descriptors()); | 9284 map->instance_descriptors()->number_of_descriptors()); |
9276 | 9285 |
9277 Handle<Map> result = RawCopy(map, instance_size); | 9286 Handle<Map> result = RawCopy(map, instance_size); |
9278 | 9287 |
9279 // Please note instance_type and instance_size are set when allocated. | 9288 // Please note instance_type and instance_size are set when allocated. |
(...skipping 3942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13222 bool CanSubclassHaveInobjectProperties(InstanceType instance_type) { | 13231 bool CanSubclassHaveInobjectProperties(InstanceType instance_type) { |
13223 switch (instance_type) { | 13232 switch (instance_type) { |
13224 case JS_API_OBJECT_TYPE: | 13233 case JS_API_OBJECT_TYPE: |
13225 case JS_ARRAY_BUFFER_TYPE: | 13234 case JS_ARRAY_BUFFER_TYPE: |
13226 case JS_ARRAY_TYPE: | 13235 case JS_ARRAY_TYPE: |
13227 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 13236 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
13228 case JS_DATA_VIEW_TYPE: | 13237 case JS_DATA_VIEW_TYPE: |
13229 case JS_DATE_TYPE: | 13238 case JS_DATE_TYPE: |
13230 case JS_FUNCTION_TYPE: | 13239 case JS_FUNCTION_TYPE: |
13231 case JS_GENERATOR_OBJECT_TYPE: | 13240 case JS_GENERATOR_OBJECT_TYPE: |
| 13241 case JS_ASYNC_GENERATOR_OBJECT_TYPE: |
| 13242 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: |
13232 case JS_MAP_ITERATOR_TYPE: | 13243 case JS_MAP_ITERATOR_TYPE: |
13233 case JS_MAP_TYPE: | 13244 case JS_MAP_TYPE: |
13234 case JS_MESSAGE_OBJECT_TYPE: | 13245 case JS_MESSAGE_OBJECT_TYPE: |
13235 case JS_OBJECT_TYPE: | 13246 case JS_OBJECT_TYPE: |
13236 case JS_ERROR_TYPE: | 13247 case JS_ERROR_TYPE: |
13237 case JS_ARGUMENTS_TYPE: | 13248 case JS_ARGUMENTS_TYPE: |
13238 case JS_PROMISE_TYPE: | 13249 case JS_PROMISE_TYPE: |
13239 case JS_REGEXP_TYPE: | 13250 case JS_REGEXP_TYPE: |
13240 case JS_SET_ITERATOR_TYPE: | 13251 case JS_SET_ITERATOR_TYPE: |
13241 case JS_SET_TYPE: | 13252 case JS_SET_TYPE: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13295 Isolate* isolate = function->GetIsolate(); | 13306 Isolate* isolate = function->GetIsolate(); |
13296 | 13307 |
13297 // The constructor should be compiled for the optimization hints to be | 13308 // The constructor should be compiled for the optimization hints to be |
13298 // available. | 13309 // available. |
13299 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); | 13310 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); |
13300 | 13311 |
13301 // First create a new map with the size and number of in-object properties | 13312 // First create a new map with the size and number of in-object properties |
13302 // suggested by the function. | 13313 // suggested by the function. |
13303 InstanceType instance_type; | 13314 InstanceType instance_type; |
13304 if (IsResumableFunction(function->shared()->kind())) { | 13315 if (IsResumableFunction(function->shared()->kind())) { |
13305 instance_type = JS_GENERATOR_OBJECT_TYPE; | 13316 instance_type = IsAsyncGeneratorFunction(function->shared()->kind()) |
| 13317 ? JS_ASYNC_GENERATOR_OBJECT_TYPE |
| 13318 : JS_GENERATOR_OBJECT_TYPE; |
13306 } else { | 13319 } else { |
13307 instance_type = JS_OBJECT_TYPE; | 13320 instance_type = JS_OBJECT_TYPE; |
13308 } | 13321 } |
13309 int instance_size; | 13322 int instance_size; |
13310 int in_object_properties; | 13323 int in_object_properties; |
13311 function->CalculateInstanceSize(instance_type, 0, &instance_size, | 13324 function->CalculateInstanceSize(instance_type, 0, &instance_size, |
13312 &in_object_properties); | 13325 &in_object_properties); |
13313 | 13326 |
13314 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); | 13327 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); |
13315 | 13328 |
(...skipping 7175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20491 // depend on this. | 20504 // depend on this. |
20492 return DICTIONARY_ELEMENTS; | 20505 return DICTIONARY_ELEMENTS; |
20493 } | 20506 } |
20494 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20507 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20495 return kind; | 20508 return kind; |
20496 } | 20509 } |
20497 } | 20510 } |
20498 | 20511 |
20499 } // namespace internal | 20512 } // namespace internal |
20500 } // namespace v8 | 20513 } // namespace v8 |
OLD | NEW |