| 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 3972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12631 bool CanSubclassHaveInobjectProperties(InstanceType instance_type) { | 12640 bool CanSubclassHaveInobjectProperties(InstanceType instance_type) { |
| 12632 switch (instance_type) { | 12641 switch (instance_type) { |
| 12633 case JS_API_OBJECT_TYPE: | 12642 case JS_API_OBJECT_TYPE: |
| 12634 case JS_ARRAY_BUFFER_TYPE: | 12643 case JS_ARRAY_BUFFER_TYPE: |
| 12635 case JS_ARRAY_TYPE: | 12644 case JS_ARRAY_TYPE: |
| 12636 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 12645 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 12637 case JS_DATA_VIEW_TYPE: | 12646 case JS_DATA_VIEW_TYPE: |
| 12638 case JS_DATE_TYPE: | 12647 case JS_DATE_TYPE: |
| 12639 case JS_FUNCTION_TYPE: | 12648 case JS_FUNCTION_TYPE: |
| 12640 case JS_GENERATOR_OBJECT_TYPE: | 12649 case JS_GENERATOR_OBJECT_TYPE: |
| 12650 case JS_ASYNC_GENERATOR_OBJECT_TYPE: |
| 12651 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: |
| 12641 case JS_MAP_ITERATOR_TYPE: | 12652 case JS_MAP_ITERATOR_TYPE: |
| 12642 case JS_MAP_TYPE: | 12653 case JS_MAP_TYPE: |
| 12643 case JS_MESSAGE_OBJECT_TYPE: | 12654 case JS_MESSAGE_OBJECT_TYPE: |
| 12644 case JS_OBJECT_TYPE: | 12655 case JS_OBJECT_TYPE: |
| 12645 case JS_ERROR_TYPE: | 12656 case JS_ERROR_TYPE: |
| 12646 case JS_ARGUMENTS_TYPE: | 12657 case JS_ARGUMENTS_TYPE: |
| 12647 case JS_PROMISE_TYPE: | 12658 case JS_PROMISE_TYPE: |
| 12648 case JS_REGEXP_TYPE: | 12659 case JS_REGEXP_TYPE: |
| 12649 case JS_SET_ITERATOR_TYPE: | 12660 case JS_SET_ITERATOR_TYPE: |
| 12650 case JS_SET_TYPE: | 12661 case JS_SET_TYPE: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12704 Isolate* isolate = function->GetIsolate(); | 12715 Isolate* isolate = function->GetIsolate(); |
| 12705 | 12716 |
| 12706 // The constructor should be compiled for the optimization hints to be | 12717 // The constructor should be compiled for the optimization hints to be |
| 12707 // available. | 12718 // available. |
| 12708 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); | 12719 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); |
| 12709 | 12720 |
| 12710 // First create a new map with the size and number of in-object properties | 12721 // First create a new map with the size and number of in-object properties |
| 12711 // suggested by the function. | 12722 // suggested by the function. |
| 12712 InstanceType instance_type; | 12723 InstanceType instance_type; |
| 12713 if (IsResumableFunction(function->shared()->kind())) { | 12724 if (IsResumableFunction(function->shared()->kind())) { |
| 12714 instance_type = JS_GENERATOR_OBJECT_TYPE; | 12725 instance_type = IsAsyncGeneratorFunction(function->shared()->kind()) |
| 12726 ? JS_ASYNC_GENERATOR_OBJECT_TYPE |
| 12727 : JS_GENERATOR_OBJECT_TYPE; |
| 12715 } else { | 12728 } else { |
| 12716 instance_type = JS_OBJECT_TYPE; | 12729 instance_type = JS_OBJECT_TYPE; |
| 12717 } | 12730 } |
| 12718 int instance_size; | 12731 int instance_size; |
| 12719 int in_object_properties; | 12732 int in_object_properties; |
| 12720 function->CalculateInstanceSize(instance_type, 0, &instance_size, | 12733 function->CalculateInstanceSize(instance_type, 0, &instance_size, |
| 12721 &in_object_properties); | 12734 &in_object_properties); |
| 12722 | 12735 |
| 12723 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); | 12736 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); |
| 12724 | 12737 |
| (...skipping 6554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19279 Isolate* isolate = cell->GetIsolate(); | 19292 Isolate* isolate = cell->GetIsolate(); |
| 19280 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19293 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19281 isolate, DependentCode::kPropertyCellChangedGroup); | 19294 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19282 } | 19295 } |
| 19283 } | 19296 } |
| 19284 | 19297 |
| 19285 int JSGeneratorObject::source_position() const { | 19298 int JSGeneratorObject::source_position() const { |
| 19286 CHECK(is_suspended()); | 19299 CHECK(is_suspended()); |
| 19287 DCHECK(function()->shared()->HasBytecodeArray()); | 19300 DCHECK(function()->shared()->HasBytecodeArray()); |
| 19288 DCHECK(!function()->shared()->HasBaselineCode()); | 19301 DCHECK(!function()->shared()->HasBaselineCode()); |
| 19289 int code_offset = Smi::cast(input_or_debug_pos())->value(); | 19302 |
| 19303 int code_offset; |
| 19304 const JSAsyncGeneratorObject* async = |
| 19305 IsJSAsyncGeneratorObject() ? JSAsyncGeneratorObject::cast(this) : nullptr; |
| 19306 if (async != nullptr && async->awaited_promise()->IsJSPromise()) { |
| 19307 code_offset = Smi::cast(async->await_input())->value(); |
| 19308 } else { |
| 19309 code_offset = Smi::cast(input_or_debug_pos())->value(); |
| 19310 } |
| 19311 |
| 19290 // The stored bytecode offset is relative to a different base than what | 19312 // The stored bytecode offset is relative to a different base than what |
| 19291 // is used in the source position table, hence the subtraction. | 19313 // is used in the source position table, hence the subtraction. |
| 19292 code_offset -= BytecodeArray::kHeaderSize - kHeapObjectTag; | 19314 code_offset -= BytecodeArray::kHeaderSize - kHeapObjectTag; |
| 19293 AbstractCode* code = | 19315 AbstractCode* code = |
| 19294 AbstractCode::cast(function()->shared()->bytecode_array()); | 19316 AbstractCode::cast(function()->shared()->bytecode_array()); |
| 19295 return code->SourcePosition(code_offset); | 19317 return code->SourcePosition(code_offset); |
| 19296 } | 19318 } |
| 19297 | 19319 |
| 19298 // static | 19320 // static |
| 19299 AccessCheckInfo* AccessCheckInfo::Get(Isolate* isolate, | 19321 AccessCheckInfo* AccessCheckInfo::Get(Isolate* isolate, |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19953 // depend on this. | 19975 // depend on this. |
| 19954 return DICTIONARY_ELEMENTS; | 19976 return DICTIONARY_ELEMENTS; |
| 19955 } | 19977 } |
| 19956 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 19978 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 19957 return kind; | 19979 return kind; |
| 19958 } | 19980 } |
| 19959 } | 19981 } |
| 19960 | 19982 |
| 19961 } // namespace internal | 19983 } // namespace internal |
| 19962 } // namespace v8 | 19984 } // namespace v8 |
| OLD | NEW |