| 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 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 } | 2754 } |
| 2755 accumulator->Add(" (SharedFunctionInfo %p)", | 2755 accumulator->Add(" (SharedFunctionInfo %p)", |
| 2756 reinterpret_cast<void*>(function->shared())); | 2756 reinterpret_cast<void*>(function->shared())); |
| 2757 accumulator->Put('>'); | 2757 accumulator->Put('>'); |
| 2758 break; | 2758 break; |
| 2759 } | 2759 } |
| 2760 case JS_GENERATOR_OBJECT_TYPE: { | 2760 case JS_GENERATOR_OBJECT_TYPE: { |
| 2761 accumulator->Add("<JS Generator>"); | 2761 accumulator->Add("<JS Generator>"); |
| 2762 break; | 2762 break; |
| 2763 } | 2763 } |
| 2764 case JS_ASYNC_GENERATOR_OBJECT_TYPE: { |
| 2765 accumulator->Add("<JS AsyncGenerator>"); |
| 2766 break; |
| 2767 } |
| 2768 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: { |
| 2769 accumulator->Add("<JS AsyncFromSyncIterator>"); |
| 2770 break; |
| 2771 } |
| 2764 // All other JSObjects are rather similar to each other (JSObject, | 2772 // All other JSObjects are rather similar to each other (JSObject, |
| 2765 // JSGlobalProxy, JSGlobalObject, JSUndetectable, JSValue). | 2773 // JSGlobalProxy, JSGlobalObject, JSUndetectable, JSValue). |
| 2766 default: { | 2774 default: { |
| 2767 Map* map_of_this = map(); | 2775 Map* map_of_this = map(); |
| 2768 Heap* heap = GetHeap(); | 2776 Heap* heap = GetHeap(); |
| 2769 Object* constructor = map_of_this->GetConstructor(); | 2777 Object* constructor = map_of_this->GetConstructor(); |
| 2770 bool printed = false; | 2778 bool printed = false; |
| 2771 if (constructor->IsHeapObject() && | 2779 if (constructor->IsHeapObject() && |
| 2772 !heap->Contains(HeapObject::cast(constructor))) { | 2780 !heap->Contains(HeapObject::cast(constructor))) { |
| 2773 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); | 2781 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); |
| (...skipping 5864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8638 #ifdef DEBUG | 8646 #ifdef DEBUG |
| 8639 Isolate* isolate = map->GetIsolate(); | 8647 Isolate* isolate = map->GetIsolate(); |
| 8640 // Strict function maps have Function as a constructor but the | 8648 // Strict function maps have Function as a constructor but the |
| 8641 // Function's initial map is a sloppy function map. Same holds for | 8649 // Function's initial map is a sloppy function map. Same holds for |
| 8642 // GeneratorFunction / AsyncFunction and its initial map. | 8650 // GeneratorFunction / AsyncFunction and its initial map. |
| 8643 Object* constructor = map->GetConstructor(); | 8651 Object* constructor = map->GetConstructor(); |
| 8644 DCHECK(constructor->IsJSFunction()); | 8652 DCHECK(constructor->IsJSFunction()); |
| 8645 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || | 8653 DCHECK(*map == JSFunction::cast(constructor)->initial_map() || |
| 8646 *map == *isolate->strict_function_map() || | 8654 *map == *isolate->strict_function_map() || |
| 8647 *map == *isolate->generator_function_map() || | 8655 *map == *isolate->generator_function_map() || |
| 8648 *map == *isolate->async_function_map()); | 8656 *map == *isolate->async_function_map() || |
| 8657 *map == *isolate->async_generator_function_map()); |
| 8649 #endif | 8658 #endif |
| 8650 // Initial maps must always own their descriptors and it's descriptor array | 8659 // Initial maps must always own their descriptors and it's descriptor array |
| 8651 // does not contain descriptors that do not belong to the map. | 8660 // does not contain descriptors that do not belong to the map. |
| 8652 DCHECK(map->owns_descriptors()); | 8661 DCHECK(map->owns_descriptors()); |
| 8653 DCHECK_EQ(map->NumberOfOwnDescriptors(), | 8662 DCHECK_EQ(map->NumberOfOwnDescriptors(), |
| 8654 map->instance_descriptors()->number_of_descriptors()); | 8663 map->instance_descriptors()->number_of_descriptors()); |
| 8655 | 8664 |
| 8656 Handle<Map> result = RawCopy(map, instance_size); | 8665 Handle<Map> result = RawCopy(map, instance_size); |
| 8657 | 8666 |
| 8658 // Please note instance_type and instance_size are set when allocated. | 8667 // Please note instance_type and instance_size are set when allocated. |
| (...skipping 3945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12604 bool CanSubclassHaveInobjectProperties(InstanceType instance_type) { | 12613 bool CanSubclassHaveInobjectProperties(InstanceType instance_type) { |
| 12605 switch (instance_type) { | 12614 switch (instance_type) { |
| 12606 case JS_API_OBJECT_TYPE: | 12615 case JS_API_OBJECT_TYPE: |
| 12607 case JS_ARRAY_BUFFER_TYPE: | 12616 case JS_ARRAY_BUFFER_TYPE: |
| 12608 case JS_ARRAY_TYPE: | 12617 case JS_ARRAY_TYPE: |
| 12609 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 12618 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 12610 case JS_DATA_VIEW_TYPE: | 12619 case JS_DATA_VIEW_TYPE: |
| 12611 case JS_DATE_TYPE: | 12620 case JS_DATE_TYPE: |
| 12612 case JS_FUNCTION_TYPE: | 12621 case JS_FUNCTION_TYPE: |
| 12613 case JS_GENERATOR_OBJECT_TYPE: | 12622 case JS_GENERATOR_OBJECT_TYPE: |
| 12623 case JS_ASYNC_GENERATOR_OBJECT_TYPE: |
| 12624 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: |
| 12614 case JS_MAP_ITERATOR_TYPE: | 12625 case JS_MAP_ITERATOR_TYPE: |
| 12615 case JS_MAP_TYPE: | 12626 case JS_MAP_TYPE: |
| 12616 case JS_MESSAGE_OBJECT_TYPE: | 12627 case JS_MESSAGE_OBJECT_TYPE: |
| 12617 case JS_OBJECT_TYPE: | 12628 case JS_OBJECT_TYPE: |
| 12618 case JS_ERROR_TYPE: | 12629 case JS_ERROR_TYPE: |
| 12619 case JS_ARGUMENTS_TYPE: | 12630 case JS_ARGUMENTS_TYPE: |
| 12620 case JS_PROMISE_TYPE: | 12631 case JS_PROMISE_TYPE: |
| 12621 case JS_REGEXP_TYPE: | 12632 case JS_REGEXP_TYPE: |
| 12622 case JS_SET_ITERATOR_TYPE: | 12633 case JS_SET_ITERATOR_TYPE: |
| 12623 case JS_SET_TYPE: | 12634 case JS_SET_TYPE: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12677 Isolate* isolate = function->GetIsolate(); | 12688 Isolate* isolate = function->GetIsolate(); |
| 12678 | 12689 |
| 12679 // The constructor should be compiled for the optimization hints to be | 12690 // The constructor should be compiled for the optimization hints to be |
| 12680 // available. | 12691 // available. |
| 12681 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); | 12692 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); |
| 12682 | 12693 |
| 12683 // First create a new map with the size and number of in-object properties | 12694 // First create a new map with the size and number of in-object properties |
| 12684 // suggested by the function. | 12695 // suggested by the function. |
| 12685 InstanceType instance_type; | 12696 InstanceType instance_type; |
| 12686 if (IsResumableFunction(function->shared()->kind())) { | 12697 if (IsResumableFunction(function->shared()->kind())) { |
| 12687 instance_type = JS_GENERATOR_OBJECT_TYPE; | 12698 instance_type = IsAsyncGeneratorFunction(function->shared()->kind()) |
| 12699 ? JS_ASYNC_GENERATOR_OBJECT_TYPE |
| 12700 : JS_GENERATOR_OBJECT_TYPE; |
| 12688 } else { | 12701 } else { |
| 12689 instance_type = JS_OBJECT_TYPE; | 12702 instance_type = JS_OBJECT_TYPE; |
| 12690 } | 12703 } |
| 12691 int instance_size; | 12704 int instance_size; |
| 12692 int in_object_properties; | 12705 int in_object_properties; |
| 12693 function->CalculateInstanceSize(instance_type, 0, &instance_size, | 12706 function->CalculateInstanceSize(instance_type, 0, &instance_size, |
| 12694 &in_object_properties); | 12707 &in_object_properties); |
| 12695 | 12708 |
| 12696 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); | 12709 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); |
| 12697 | 12710 |
| (...skipping 7175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19873 // depend on this. | 19886 // depend on this. |
| 19874 return DICTIONARY_ELEMENTS; | 19887 return DICTIONARY_ELEMENTS; |
| 19875 } | 19888 } |
| 19876 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 19889 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 19877 return kind; | 19890 return kind; |
| 19878 } | 19891 } |
| 19879 } | 19892 } |
| 19880 | 19893 |
| 19881 } // namespace internal | 19894 } // namespace internal |
| 19882 } // namespace v8 | 19895 } // namespace v8 |
| OLD | NEW |