diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h index 2260b09f1b..d7be1d5bd5 100644 --- a/src/code-stub-assembler.h +++ b/src/code-stub-assembler.h @@ -34,57 +34,58 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; TypedArraySpeciesProtector) \ V(StoreHandler0Map, store_handler0_map, StoreHandler0Map) -#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ - V(AccessorInfoMap, accessor_info_map, AccessorInfoMap) \ - V(AccessorPairMap, accessor_pair_map, AccessorPairMap) \ - V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \ - V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \ - AllocationSiteWithoutWeakNextMap) \ - V(BooleanMap, boolean_map, BooleanMap) \ - V(CodeMap, code_map, CodeMap) \ - V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \ - V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ - EmptySlowElementDictionary) \ - V(empty_string, empty_string, EmptyString) \ - V(EmptyWeakCell, empty_weak_cell, EmptyWeakCell) \ - V(FalseValue, false_value, False) \ - V(FeedbackVectorMap, feedback_vector_map, FeedbackVectorMap) \ - V(FixedArrayMap, fixed_array_map, FixedArrayMap) \ - V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \ - V(FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArrayMap) \ - V(FunctionTemplateInfoMap, function_template_info_map, \ - FunctionTemplateInfoMap) \ - V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \ - V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \ - V(HeapNumberMap, heap_number_map, HeapNumberMap) \ - V(iterator_symbol, iterator_symbol, IteratorSymbol) \ - V(length_string, length_string, LengthString) \ - V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \ - V(MetaMap, meta_map, MetaMap) \ - V(MinusZeroValue, minus_zero_value, MinusZero) \ - V(MutableHeapNumberMap, mutable_heap_number_map, MutableHeapNumberMap) \ - V(NanValue, nan_value, Nan) \ - V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \ - V(NullValue, null_value, Null) \ - V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \ - V(prototype_string, prototype_string, PrototypeString) \ - V(SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfoMap) \ - V(SymbolMap, symbol_map, SymbolMap) \ - V(TheHoleValue, the_hole_value, TheHole) \ - V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \ - V(TrueValue, true_value, True) \ - V(Tuple2Map, tuple2_map, Tuple2Map) \ - V(Tuple3Map, tuple3_map, Tuple3Map) \ - V(ArrayBoilerplateDescriptionMap, array_boilerplate_description_map, \ - ArrayBoilerplateDescriptionMap) \ - V(UncompiledDataWithoutPreParsedScopeMap, \ - uncompiled_data_without_pre_parsed_scope_map, \ - UncompiledDataWithoutPreParsedScopeMap) \ - V(UncompiledDataWithPreParsedScopeMap, \ - uncompiled_data_with_pre_parsed_scope_map, \ - UncompiledDataWithPreParsedScopeMap) \ - V(UndefinedValue, undefined_value, Undefined) \ - V(WeakCellMap, weak_cell_map, WeakCellMap) \ +#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ + V(AccessorInfoMap, accessor_info_map, AccessorInfoMap) \ + V(AccessorPairMap, accessor_pair_map, AccessorPairMap) \ + V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \ + V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \ + AllocationSiteWithoutWeakNextMap) \ + V(BooleanMap, boolean_map, BooleanMap) \ + V(CodeMap, code_map, CodeMap) \ + V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \ + V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ + EmptySlowElementDictionary) \ + V(empty_string, empty_string, EmptyString) \ + V(EmptyWeakCell, empty_weak_cell, EmptyWeakCell) \ + V(FalseValue, false_value, False) \ + V(FeedbackVectorMap, feedback_vector_map, FeedbackVectorMap) \ + V(FixedArrayMap, fixed_array_map, FixedArrayMap) \ + V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \ + V(FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArrayMap) \ + V(FunctionTemplateInfoMap, function_template_info_map, \ + FunctionTemplateInfoMap) \ + V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \ + V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \ + V(HeapNumberMap, heap_number_map, HeapNumberMap) \ + V(iterator_symbol, iterator_symbol, IteratorSymbol) \ + V(length_string, length_string, LengthString) \ + V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \ + V(MetaMap, meta_map, MetaMap) \ + V(MinusZeroValue, minus_zero_value, MinusZero) \ + V(MutableHeapNumberMap, mutable_heap_number_map, MutableHeapNumberMap) \ + V(NanValue, nan_value, Nan) \ + V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \ + V(NullValue, null_value, Null) \ + V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \ + V(PreParsedScopeDataMap, pre_parsed_scope_data_map, PreParsedScopeDataMap) \ + V(prototype_string, prototype_string, PrototypeString) \ + V(SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfoMap) \ + V(SymbolMap, symbol_map, SymbolMap) \ + V(TheHoleValue, the_hole_value, TheHole) \ + V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \ + V(TrueValue, true_value, True) \ + V(Tuple2Map, tuple2_map, Tuple2Map) \ + V(Tuple3Map, tuple3_map, Tuple3Map) \ + V(ArrayBoilerplateDescriptionMap, array_boilerplate_description_map, \ + ArrayBoilerplateDescriptionMap) \ + V(UncompiledDataWithoutPreParsedScopeMap, \ + uncompiled_data_without_pre_parsed_scope_map, \ + UncompiledDataWithoutPreParsedScopeMap) \ + V(UncompiledDataWithPreParsedScopeMap, \ + uncompiled_data_with_pre_parsed_scope_map, \ + UncompiledDataWithPreParsedScopeMap) \ + V(UndefinedValue, undefined_value, Undefined) \ + V(WeakCellMap, weak_cell_map, WeakCellMap) \ V(WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArrayMap) #define HEAP_IMMOVABLE_OBJECT_LIST(V) \ diff --git a/src/compiler/types.cc b/src/compiler/types.cc index 420a923b14..0af70027b3 100644 --- a/src/compiler/types.cc +++ b/src/compiler/types.cc @@ -296,6 +296,7 @@ Type::bitset BitsetType::Lub(HeapObjectType const& type) { case MODULE_TYPE: case MODULE_INFO_ENTRY_TYPE: case CELL_TYPE: + case PRE_PARSED_SCOPE_DATA_TYPE: case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: return kOtherInternal; diff --git a/src/heap/factory.cc b/src/heap/factory.cc index 3e72c1384f..ba104278e6 100644 --- a/src/heap/factory.cc +++ b/src/heap/factory.cc @@ -2498,11 +2498,17 @@ Handle Factory::NewModuleInfo() { ModuleInfo::kLength, TENURED); } -Handle Factory::NewPreParsedScopeData() { - Handle result = - Handle::cast(NewStruct(TUPLE2_TYPE, TENURED)); +Handle Factory::NewPreParsedScopeData(int length) { + int size = PreParsedScopeData::SizeFor(length); + Handle result( + PreParsedScopeData::cast(AllocateRawWithImmortalMap( + size, TENURED, *pre_parsed_scope_data_map())), + isolate()); result->set_scope_data(PodArray::cast(*empty_byte_array())); - result->set_child_data(*empty_fixed_array()); + result->set_length(length); + MemsetPointer(result->child_data_start(), *null_value(), length); + + result->clear_padding(); return result; } diff --git a/src/heap/factory.h b/src/heap/factory.h index 58374be372..21e3036c8f 100644 --- a/src/heap/factory.h +++ b/src/heap/factory.h @@ -724,7 +724,7 @@ class V8_EXPORT_PRIVATE Factory { Handle NewModuleInfo(); - Handle NewPreParsedScopeData(); + Handle NewPreParsedScopeData(int length); Handle NewUncompiledDataWithoutPreParsedScope(int32_t start_position, diff --git a/src/heap/heap.h b/src/heap/heap.h index 471fa95b7f..596546c1c6 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -129,6 +129,7 @@ using v8::MemoryPressureLevel; V(OptimizedOut) \ V(OrderedHashMapMap) \ V(OrderedHashSetMap) \ + V(PreParsedScopeDataMap) \ V(PropertyArrayMap) \ V(ScopeInfoMap) \ V(ScriptContextMap) \ diff --git a/src/heap/objects-visiting.h b/src/heap/objects-visiting.h index 410dbeba9f..cdb7c917b0 100644 --- a/src/heap/objects-visiting.h +++ b/src/heap/objects-visiting.h @@ -48,6 +48,7 @@ class UncompiledDataWithPreParsedScope; V(JSWeakCollection) \ V(Map) \ V(Oddball) \ + V(PreParsedScopeData) \ V(PropertyArray) \ V(PropertyCell) \ V(PrototypeInfo) \ diff --git a/src/heap/setup-heap-internal.cc b/src/heap/setup-heap-internal.cc index 38eb0efcb8..58f7ba435a 100644 --- a/src/heap/setup-heap-internal.cc +++ b/src/heap/setup-heap-internal.cc @@ -498,6 +498,7 @@ bool Heap::CreateInitialMaps() { ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize, next_call_side_effect_free_call_handler_info) + ALLOCATE_VARSIZE_MAP(PRE_PARSED_SCOPE_DATA_TYPE, pre_parsed_scope_data) ALLOCATE_MAP(UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE, UncompiledDataWithoutPreParsedScope::kSize, uncompiled_data_without_pre_parsed_scope) diff --git a/src/objects-body-descriptors-inl.h b/src/objects-body-descriptors-inl.h index e882335dc0..d4ee72654f 100644 --- a/src/objects-body-descriptors-inl.h +++ b/src/objects-body-descriptors-inl.h @@ -388,6 +388,24 @@ class FeedbackVector::BodyDescriptor final : public BodyDescriptorBase { } }; +class PreParsedScopeData::BodyDescriptor final : public BodyDescriptorBase { + public: + static bool IsValidSlot(Map* map, HeapObject* obj, int offset) { + return offset == kScopeDataOffset || offset >= kChildDataStartOffset; + } + + template + static inline void IterateBody(Map* map, HeapObject* obj, int object_size, + ObjectVisitor* v) { + IteratePointer(obj, kScopeDataOffset, v); + IteratePointers(obj, kChildDataStartOffset, object_size, v); + } + + static inline int SizeOf(Map* map, HeapObject* obj) { + return PreParsedScopeData::SizeFor(PreParsedScopeData::cast(obj)->length()); + } +}; + class PrototypeInfo::BodyDescriptor final : public BodyDescriptorBase { public: static bool IsValidSlot(Map* map, HeapObject* obj, int offset) { @@ -761,6 +779,9 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) { case CODE_DATA_CONTAINER_TYPE: return Op::template apply(p1, p2, p3, p4); + case PRE_PARSED_SCOPE_DATA_TYPE: + return Op::template apply(p1, p2, p3, + p4); case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: return Op::template apply< UncompiledDataWithPreParsedScope::BodyDescriptor>(p1, p2, p3, p4); diff --git a/src/objects-debug.cc b/src/objects-debug.cc index dca45ba0bb..e70082b82b 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -321,6 +321,9 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) { case FOREIGN_TYPE: Foreign::cast(this)->ForeignVerify(isolate); break; + case PRE_PARSED_SCOPE_DATA_TYPE: + PreParsedScopeData::cast(this)->PreParsedScopeDataVerify(isolate); + break; case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: UncompiledDataWithoutPreParsedScope::cast(this) ->UncompiledDataWithoutPreParsedScopeVerify(isolate); @@ -1789,7 +1792,13 @@ void StackFrameInfo::StackFrameInfoVerify(Isolate* isolate) { void PreParsedScopeData::PreParsedScopeDataVerify(Isolate* isolate) { CHECK(IsPreParsedScopeData()); CHECK(scope_data()->IsByteArray()); - CHECK(child_data()->IsFixedArray()); + CHECK_GE(length(), 0); + + for (int i = 0; i < length(); ++i) { + Object* child = child_data(i); + CHECK(child->IsPreParsedScopeData() || child->IsNull()); + VerifyPointer(child); + } } void UncompiledDataWithPreParsedScope::UncompiledDataWithPreParsedScopeVerify( diff --git a/src/objects-definitions.h b/src/objects-definitions.h index a16158f657..5e922a487c 100644 --- a/src/objects-definitions.h +++ b/src/objects-definitions.h @@ -157,6 +157,7 @@ namespace internal { V(FEEDBACK_CELL_TYPE) \ V(FEEDBACK_VECTOR_TYPE) \ V(LOAD_HANDLER_TYPE) \ + V(PRE_PARSED_SCOPE_DATA_TYPE) \ V(PROPERTY_ARRAY_TYPE) \ V(PROPERTY_CELL_TYPE) \ V(SHARED_FUNCTION_INFO_TYPE) \ diff --git a/src/objects-inl.h b/src/objects-inl.h index 7013ec9dc4..da688dc895 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -131,7 +131,7 @@ TYPE_CHECKER(NumberDictionary, NUMBER_DICTIONARY_TYPE) TYPE_CHECKER(Oddball, ODDBALL_TYPE) TYPE_CHECKER(OrderedHashMap, ORDERED_HASH_MAP_TYPE) TYPE_CHECKER(OrderedHashSet, ORDERED_HASH_SET_TYPE) -TYPE_CHECKER(PreParsedScopeData, TUPLE2_TYPE) +TYPE_CHECKER(PreParsedScopeData, PRE_PARSED_SCOPE_DATA_TYPE) TYPE_CHECKER(PropertyArray, PROPERTY_ARRAY_TYPE) TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE) TYPE_CHECKER(PropertyDescriptorObject, FIXED_ARRAY_TYPE) @@ -2367,6 +2367,10 @@ int HeapObject::SizeFromMap(Map* map) const { if (instance_type == BIGINT_TYPE) { return BigInt::SizeFor(reinterpret_cast(this)->length()); } + if (instance_type == PRE_PARSED_SCOPE_DATA_TYPE) { + return PreParsedScopeData::SizeFor( + reinterpret_cast(this)->length()); + } DCHECK(instance_type == CODE_TYPE); return reinterpret_cast(this)->CodeSize(); } diff --git a/src/objects-printer.cc b/src/objects-printer.cc index 9b0a1ec7d7..e8755dd42c 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -265,6 +265,9 @@ void HeapObject::HeapObjectPrint(Isolate* isolate, case CALL_HANDLER_INFO_TYPE: CallHandlerInfo::cast(this)->CallHandlerInfoPrint(os); break; + case PRE_PARSED_SCOPE_DATA_TYPE: + PreParsedScopeData::cast(this)->PreParsedScopeDataPrint(os); + break; case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: UncompiledDataWithoutPreParsedScope::cast(this) ->UncompiledDataWithoutPreParsedScopePrint(os); @@ -2127,7 +2130,10 @@ void LayoutDescriptor::Print(std::ostream& os) { // NOLINT void PreParsedScopeData::PreParsedScopeDataPrint(std::ostream& os) { // NOLINT HeapObject::PrintHeader(os, "PreParsedScopeData"); os << "\n - scope_data: " << Brief(scope_data()); - os << "\n - child_data: " << Brief(child_data()); + os << "\n - length: " << length(); + for (int i = 0; i < length(); ++i) { + os << "\n - [" << i << "]: " << Brief(child_data(i)); + } os << "\n"; } diff --git a/src/objects.cc b/src/objects.cc index c86f8979c2..c927e0db37 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -3104,6 +3104,9 @@ VisitorId Map::GetVisitorId(Map* map) { case WASM_INSTANCE_TYPE: return kVisitWasmInstanceObject; + case PRE_PARSED_SCOPE_DATA_TYPE: + return kVisitPreParsedScopeData; + case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: return kVisitUncompiledDataWithPreParsedScope; @@ -3435,6 +3438,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT) #undef TYPED_ARRAY_SHORT_PRINT + case PRE_PARSED_SCOPE_DATA_TYPE: { + PreParsedScopeData* data = PreParsedScopeData::cast(this); + os << "length() << "]>"; + break; + } + case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: { UncompiledDataWithoutPreParsedScope* data = UncompiledDataWithoutPreParsedScope::cast(this); diff --git a/src/objects.h b/src/objects.h index 6e0279db34..40a6408430 100644 --- a/src/objects.h +++ b/src/objects.h @@ -170,10 +170,10 @@ // - PromiseResolveThenableJobTask // - Module // - ModuleInfoEntry -// - PreParsedScopeData // - WeakCell // - FeedbackCell // - FeedbackVector +// - PreParsedScopeData // - UncompiledData // - UncompiledDataWithoutPreParsedScope // - UncompiledDataWithPreParsedScope @@ -523,6 +523,7 @@ enum InstanceType : uint16_t { FEEDBACK_CELL_TYPE, FEEDBACK_VECTOR_TYPE, LOAD_HANDLER_TYPE, + PRE_PARSED_SCOPE_DATA_TYPE, PROPERTY_ARRAY_TYPE, PROPERTY_CELL_TYPE, SHARED_FUNCTION_INFO_TYPE, @@ -706,6 +707,7 @@ class ModuleInfoEntry; class ObjectHashTable; class ObjectTemplateInfo; class ObjectVisitor; +class PreParsedScopeData; class PropertyCell; class PropertyDescriptor; class RootVisitor; diff --git a/src/objects/map.h b/src/objects/map.h index c3f8a33d85..1d1f72ab9c 100644 --- a/src/objects/map.h +++ b/src/objects/map.h @@ -44,6 +44,7 @@ namespace internal { V(Map) \ V(NativeContext) \ V(Oddball) \ + V(PreParsedScopeData) \ V(PropertyArray) \ V(PropertyCell) \ V(PrototypeInfo) \ diff --git a/src/objects/shared-function-info-inl.h b/src/objects/shared-function-info-inl.h index e4a4d22f83..415c9397be 100644 --- a/src/objects/shared-function-info-inl.h +++ b/src/objects/shared-function-info-inl.h @@ -20,7 +20,37 @@ namespace internal { CAST_ACCESSOR(PreParsedScopeData) ACCESSORS(PreParsedScopeData, scope_data, PodArray, kScopeDataOffset) -ACCESSORS(PreParsedScopeData, child_data, FixedArray, kChildDataOffset) +INT_ACCESSORS(PreParsedScopeData, length, kLengthOffset) + +Object* PreParsedScopeData::child_data(int index) const { + DCHECK_GE(index, 0); + DCHECK_LT(index, this->length()); + int offset = kChildDataStartOffset + index * kPointerSize; + return RELAXED_READ_FIELD(this, offset); +} + +void PreParsedScopeData::set_child_data(int index, Object* value, + WriteBarrierMode mode) { + DCHECK_GE(index, 0); + DCHECK_LT(index, this->length()); + int offset = kChildDataStartOffset + index * kPointerSize; + RELAXED_WRITE_FIELD(this, offset, value); + CONDITIONAL_WRITE_BARRIER(Heap::FromWritableHeapObject(this), this, offset, + value, mode); +} + +Object** PreParsedScopeData::child_data_start() const { + return HeapObject::RawField(this, kChildDataStartOffset); +} + +void PreParsedScopeData::clear_padding() { + // For archs where kIntSize < kPointerSize, there will be padding between the + // length field and the start of the child data. + if (kUnalignedChildDataStartOffset < kChildDataStartOffset) { + memset(reinterpret_cast(address() + kUnalignedChildDataStartOffset), + 0, kChildDataStartOffset - kUnalignedChildDataStartOffset); + } +} CAST_ACCESSOR(UncompiledData) INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset) diff --git a/src/objects/shared-function-info.h b/src/objects/shared-function-info.h index b6fa3ddc8c..07b7cdad42 100644 --- a/src/objects/shared-function-info.h +++ b/src/objects/shared-function-info.h @@ -22,19 +22,44 @@ class WasmExportedFunctionData; // Data collected by the pre-parser storing information about scopes and inner // functions. -class PreParsedScopeData : public Struct { +class PreParsedScopeData : public HeapObject { public: DECL_ACCESSORS(scope_data, PodArray) - DECL_ACCESSORS(child_data, FixedArray) + DECL_INT_ACCESSORS(length) - static const int kScopeDataOffset = Struct::kHeaderSize; - static const int kChildDataOffset = kScopeDataOffset + kPointerSize; - static const int kSize = kChildDataOffset + kPointerSize; + inline Object* child_data(int index) const; + inline void set_child_data(int index, Object* value, + WriteBarrierMode mode = UPDATE_WRITE_BARRIER); + + inline Object** child_data_start() const; + + // Clear uninitialized padding space. + inline void clear_padding(); DECL_CAST(PreParsedScopeData) DECL_PRINTER(PreParsedScopeData) DECL_VERIFIER(PreParsedScopeData) +#define PRE_PARSED_SCOPE_DATA_FIELDS(V) \ + V(kScopeDataOffset, kPointerSize) \ + V(kLengthOffset, kIntSize) \ + V(kUnalignedChildDataStartOffset, 0) + + DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, + PRE_PARSED_SCOPE_DATA_FIELDS) +#undef PRE_PARSED_SCOPE_DATA_FIELDS + + static const int kChildDataStartOffset = + POINTER_SIZE_ALIGN(kUnalignedChildDataStartOffset); + + class BodyDescriptor; + // No weak fields. + typedef BodyDescriptor BodyDescriptorWeak; + + static constexpr int SizeFor(int length) { + return kChildDataStartOffset + length * kPointerSize; + } + private: DISALLOW_IMPLICIT_CONSTRUCTORS(PreParsedScopeData); }; diff --git a/src/parsing/preparsed-scope-data.cc b/src/parsing/preparsed-scope-data.cc index 3b5105b4a8..8a70ca440b 100644 --- a/src/parsing/preparsed-scope-data.cc +++ b/src/parsing/preparsed-scope-data.cc @@ -292,30 +292,22 @@ MaybeHandle ProducedPreParsedScopeData::Serialize( return MaybeHandle(); } - Handle data = isolate->factory()->NewPreParsedScopeData(); + int child_data_length = static_cast(data_for_inner_functions_.size()); + Handle data = + isolate->factory()->NewPreParsedScopeData(child_data_length); Handle> scope_data_array = byte_data_->Serialize(isolate); data->set_scope_data(*scope_data_array); - int child_data_length = static_cast(data_for_inner_functions_.size()); - if (child_data_length == 0) { - data->set_child_data(*(isolate->factory()->empty_fixed_array())); - } else { - Handle child_array = - isolate->factory()->NewFixedArray(child_data_length, TENURED); - int i = 0; - for (const auto& item : data_for_inner_functions_) { - MaybeHandle maybe_child_data = - item->Serialize(isolate); - if (maybe_child_data.is_null()) { - child_array->set(i++, *(isolate->factory()->null_value())); - } else { - Handle child_data = - maybe_child_data.ToHandleChecked(); - child_array->set(i++, *child_data); - } + int i = 0; + for (const auto& item : data_for_inner_functions_) { + Handle child_data; + if (item->Serialize(isolate).ToHandle(&child_data)) { + data->set_child_data(i, *child_data); + } else { + DCHECK(data->child_data(i)->IsNull()); } - data->set_child_data(*child_array); + i++; } return data; @@ -525,9 +517,8 @@ ConsumedPreParsedScopeData::GetDataForSkippableFunction( // Retrieve the corresponding PreParsedScopeData and associate it to the // skipped function. If the skipped functions contains inner functions, those // can be skipped when the skipped function is eagerly parsed. - FixedArray* children = data_->child_data(); - CHECK_GT(children->length(), child_index_); - Object* child_data = children->get(child_index_++); + CHECK_GT(data_->length(), child_index_); + Object* child_data = data_->child_data(child_index_++); if (!child_data->IsPreParsedScopeData()) { return nullptr; } diff --git a/src/roots.h b/src/roots.h index 4e676b456e..5818e3c3ac 100644 --- a/src/roots.h +++ b/src/roots.h @@ -89,6 +89,7 @@ namespace internal { V(Map, one_closure_cell_map, OneClosureCellMap) \ V(Map, ordered_hash_map_map, OrderedHashMapMap) \ V(Map, ordered_hash_set_map, OrderedHashSetMap) \ + V(Map, pre_parsed_scope_data_map, PreParsedScopeDataMap) \ V(Map, property_array_map, PropertyArrayMap) \ V(Map, side_effect_call_handler_info_map, SideEffectCallHandlerInfoMap) \ V(Map, side_effect_free_call_handler_info_map, \ diff --git a/tools/v8heapconst.py b/tools/v8heapconst.py index b818073d75..56a74c208c 100644 --- a/tools/v8heapconst.py +++ b/tools/v8heapconst.py @@ -114,16 +114,17 @@ INSTANCE_TYPES = { 210: "FEEDBACK_CELL_TYPE", 211: "FEEDBACK_VECTOR_TYPE", 212: "LOAD_HANDLER_TYPE", - 213: "PROPERTY_ARRAY_TYPE", - 214: "PROPERTY_CELL_TYPE", - 215: "SHARED_FUNCTION_INFO_TYPE", - 216: "SMALL_ORDERED_HASH_MAP_TYPE", - 217: "SMALL_ORDERED_HASH_SET_TYPE", - 218: "STORE_HANDLER_TYPE", - 219: "UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE", - 220: "UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE", - 221: "WEAK_CELL_TYPE", - 222: "WEAK_ARRAY_LIST_TYPE", + 213: "PRE_PARSED_SCOPE_DATA_TYPE", + 214: "PROPERTY_ARRAY_TYPE", + 215: "PROPERTY_CELL_TYPE", + 216: "SHARED_FUNCTION_INFO_TYPE", + 217: "SMALL_ORDERED_HASH_MAP_TYPE", + 218: "SMALL_ORDERED_HASH_SET_TYPE", + 219: "STORE_HANDLER_TYPE", + 220: "UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE", + 221: "UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE", + 222: "WEAK_CELL_TYPE", + 223: "WEAK_ARRAY_LIST_TYPE", 1024: "JS_PROXY_TYPE", 1025: "JS_GLOBAL_OBJECT_TYPE", 1026: "JS_GLOBAL_PROXY_TYPE", @@ -176,7 +177,7 @@ KNOWN_MAPS = { ("RO_SPACE", 0x022e1): (131, "NullMap"), ("RO_SPACE", 0x02359): (205, "DescriptorArrayMap"), ("RO_SPACE", 0x023c1): (182, "FixedArrayMap"), - ("RO_SPACE", 0x02429): (221, "WeakCellMap"), + ("RO_SPACE", 0x02429): (222, "WeakCellMap"), ("RO_SPACE", 0x024d1): (152, "OnePointerFillerMap"), ("RO_SPACE", 0x02539): (152, "TwoPointerFillerMap"), ("RO_SPACE", 0x025d1): (131, "UninitializedMap"), @@ -191,11 +192,11 @@ KNOWN_MAPS = { ("RO_SPACE", 0x02b41): (128, "SymbolMap"), ("RO_SPACE", 0x02ba9): (72, "OneByteStringMap"), ("RO_SPACE", 0x02c11): (193, "ScopeInfoMap"), - ("RO_SPACE", 0x02c79): (215, "SharedFunctionInfoMap"), + ("RO_SPACE", 0x02c79): (216, "SharedFunctionInfoMap"), ("RO_SPACE", 0x02ce1): (133, "CodeMap"), ("RO_SPACE", 0x02d49): (199, "FunctionContextMap"), ("RO_SPACE", 0x02db1): (208, "CellMap"), - ("RO_SPACE", 0x02e19): (214, "GlobalPropertyCellMap"), + ("RO_SPACE", 0x02e19): (215, "GlobalPropertyCellMap"), ("RO_SPACE", 0x02e81): (135, "ForeignMap"), ("RO_SPACE", 0x02ee9): (206, "TransitionArrayMap"), ("RO_SPACE", 0x02f51): (211, "FeedbackVectorMap"), @@ -230,83 +231,84 @@ KNOWN_MAPS = { ("RO_SPACE", 0x03ce9): (210, "OneClosureCellMap"), ("RO_SPACE", 0x03d51): (185, "OrderedHashMapMap"), ("RO_SPACE", 0x03db9): (186, "OrderedHashSetMap"), - ("RO_SPACE", 0x03e21): (213, "PropertyArrayMap"), - ("RO_SPACE", 0x03e89): (207, "SideEffectCallHandlerInfoMap"), - ("RO_SPACE", 0x03ef1): (207, "SideEffectFreeCallHandlerInfoMap"), - ("RO_SPACE", 0x03f59): (207, "NextCallSideEffectFreeCallHandlerInfoMap"), - ("RO_SPACE", 0x03fc1): (190, "SimpleNumberDictionaryMap"), - ("RO_SPACE", 0x04029): (182, "SloppyArgumentsElementsMap"), - ("RO_SPACE", 0x04091): (216, "SmallOrderedHashMapMap"), - ("RO_SPACE", 0x040f9): (217, "SmallOrderedHashSetMap"), - ("RO_SPACE", 0x04161): (191, "StringTableMap"), - ("RO_SPACE", 0x041c9): (219, "UncompiledDataWithoutPreParsedScopeMap"), - ("RO_SPACE", 0x04231): (220, "UncompiledDataWithPreParsedScopeMap"), - ("RO_SPACE", 0x04299): (204, "WeakFixedArrayMap"), - ("RO_SPACE", 0x04301): (222, "WeakArrayListMap"), - ("RO_SPACE", 0x04369): (192, "EphemeronHashTableMap"), - ("RO_SPACE", 0x043d1): (106, "NativeSourceStringMap"), - ("RO_SPACE", 0x04439): (64, "StringMap"), - ("RO_SPACE", 0x044a1): (73, "ConsOneByteStringMap"), - ("RO_SPACE", 0x04509): (65, "ConsStringMap"), - ("RO_SPACE", 0x04571): (77, "ThinOneByteStringMap"), - ("RO_SPACE", 0x045d9): (69, "ThinStringMap"), - ("RO_SPACE", 0x04641): (67, "SlicedStringMap"), - ("RO_SPACE", 0x046a9): (75, "SlicedOneByteStringMap"), - ("RO_SPACE", 0x04711): (66, "ExternalStringMap"), - ("RO_SPACE", 0x04779): (82, "ExternalStringWithOneByteDataMap"), - ("RO_SPACE", 0x047e1): (74, "ExternalOneByteStringMap"), - ("RO_SPACE", 0x04849): (98, "ShortExternalStringMap"), - ("RO_SPACE", 0x048b1): (114, "ShortExternalStringWithOneByteDataMap"), - ("RO_SPACE", 0x04919): (0, "InternalizedStringMap"), - ("RO_SPACE", 0x04981): (2, "ExternalInternalizedStringMap"), - ("RO_SPACE", 0x049e9): (18, "ExternalInternalizedStringWithOneByteDataMap"), - ("RO_SPACE", 0x04a51): (10, "ExternalOneByteInternalizedStringMap"), - ("RO_SPACE", 0x04ab9): (34, "ShortExternalInternalizedStringMap"), - ("RO_SPACE", 0x04b21): (50, "ShortExternalInternalizedStringWithOneByteDataMap"), - ("RO_SPACE", 0x04b89): (42, "ShortExternalOneByteInternalizedStringMap"), - ("RO_SPACE", 0x04bf1): (106, "ShortExternalOneByteStringMap"), - ("RO_SPACE", 0x04c59): (140, "FixedUint8ArrayMap"), - ("RO_SPACE", 0x04cc1): (139, "FixedInt8ArrayMap"), - ("RO_SPACE", 0x04d29): (142, "FixedUint16ArrayMap"), - ("RO_SPACE", 0x04d91): (141, "FixedInt16ArrayMap"), - ("RO_SPACE", 0x04df9): (144, "FixedUint32ArrayMap"), - ("RO_SPACE", 0x04e61): (143, "FixedInt32ArrayMap"), - ("RO_SPACE", 0x04ec9): (145, "FixedFloat32ArrayMap"), - ("RO_SPACE", 0x04f31): (146, "FixedFloat64ArrayMap"), - ("RO_SPACE", 0x04f99): (147, "FixedUint8ClampedArrayMap"), - ("RO_SPACE", 0x05001): (149, "FixedBigUint64ArrayMap"), - ("RO_SPACE", 0x05069): (148, "FixedBigInt64ArrayMap"), - ("RO_SPACE", 0x050d1): (131, "SelfReferenceMarkerMap"), - ("RO_SPACE", 0x05151): (171, "Tuple2Map"), - ("RO_SPACE", 0x054a1): (161, "InterceptorInfoMap"), - ("RO_SPACE", 0x055c1): (169, "ScriptMap"), - ("RO_SPACE", 0x09fb9): (154, "AccessorInfoMap"), - ("RO_SPACE", 0x0a021): (153, "AccessCheckInfoMap"), - ("RO_SPACE", 0x0a089): (155, "AccessorPairMap"), - ("RO_SPACE", 0x0a0f1): (156, "AliasedArgumentsEntryMap"), - ("RO_SPACE", 0x0a159): (157, "AllocationMementoMap"), - ("RO_SPACE", 0x0a1c1): (158, "AsyncGeneratorRequestMap"), - ("RO_SPACE", 0x0a229): (159, "DebugInfoMap"), - ("RO_SPACE", 0x0a291): (160, "FunctionTemplateInfoMap"), - ("RO_SPACE", 0x0a2f9): (162, "InterpreterDataMap"), - ("RO_SPACE", 0x0a361): (163, "ModuleInfoEntryMap"), - ("RO_SPACE", 0x0a3c9): (164, "ModuleMap"), - ("RO_SPACE", 0x0a431): (165, "ObjectTemplateInfoMap"), - ("RO_SPACE", 0x0a499): (166, "PromiseCapabilityMap"), - ("RO_SPACE", 0x0a501): (167, "PromiseReactionMap"), - ("RO_SPACE", 0x0a569): (168, "PrototypeInfoMap"), - ("RO_SPACE", 0x0a5d1): (170, "StackFrameInfoMap"), - ("RO_SPACE", 0x0a639): (172, "Tuple3Map"), - ("RO_SPACE", 0x0a6a1): (173, "ArrayBoilerplateDescriptionMap"), - ("RO_SPACE", 0x0a709): (174, "WasmDebugInfoMap"), - ("RO_SPACE", 0x0a771): (175, "WasmExportedFunctionDataMap"), - ("RO_SPACE", 0x0a7d9): (176, "CallableTaskMap"), - ("RO_SPACE", 0x0a841): (177, "CallbackTaskMap"), - ("RO_SPACE", 0x0a8a9): (178, "PromiseFulfillReactionJobTaskMap"), - ("RO_SPACE", 0x0a911): (179, "PromiseRejectReactionJobTaskMap"), - ("RO_SPACE", 0x0a979): (180, "PromiseResolveThenableJobTaskMap"), - ("RO_SPACE", 0x0a9e1): (181, "AllocationSiteMap"), + ("RO_SPACE", 0x03e21): (213, "PreParsedScopeDataMap"), + ("RO_SPACE", 0x03e89): (214, "PropertyArrayMap"), + ("RO_SPACE", 0x03ef1): (207, "SideEffectCallHandlerInfoMap"), + ("RO_SPACE", 0x03f59): (207, "SideEffectFreeCallHandlerInfoMap"), + ("RO_SPACE", 0x03fc1): (207, "NextCallSideEffectFreeCallHandlerInfoMap"), + ("RO_SPACE", 0x04029): (190, "SimpleNumberDictionaryMap"), + ("RO_SPACE", 0x04091): (182, "SloppyArgumentsElementsMap"), + ("RO_SPACE", 0x040f9): (217, "SmallOrderedHashMapMap"), + ("RO_SPACE", 0x04161): (218, "SmallOrderedHashSetMap"), + ("RO_SPACE", 0x041c9): (191, "StringTableMap"), + ("RO_SPACE", 0x04231): (220, "UncompiledDataWithoutPreParsedScopeMap"), + ("RO_SPACE", 0x04299): (221, "UncompiledDataWithPreParsedScopeMap"), + ("RO_SPACE", 0x04301): (204, "WeakFixedArrayMap"), + ("RO_SPACE", 0x04369): (223, "WeakArrayListMap"), + ("RO_SPACE", 0x043d1): (192, "EphemeronHashTableMap"), + ("RO_SPACE", 0x04439): (106, "NativeSourceStringMap"), + ("RO_SPACE", 0x044a1): (64, "StringMap"), + ("RO_SPACE", 0x04509): (73, "ConsOneByteStringMap"), + ("RO_SPACE", 0x04571): (65, "ConsStringMap"), + ("RO_SPACE", 0x045d9): (77, "ThinOneByteStringMap"), + ("RO_SPACE", 0x04641): (69, "ThinStringMap"), + ("RO_SPACE", 0x046a9): (67, "SlicedStringMap"), + ("RO_SPACE", 0x04711): (75, "SlicedOneByteStringMap"), + ("RO_SPACE", 0x04779): (66, "ExternalStringMap"), + ("RO_SPACE", 0x047e1): (82, "ExternalStringWithOneByteDataMap"), + ("RO_SPACE", 0x04849): (74, "ExternalOneByteStringMap"), + ("RO_SPACE", 0x048b1): (98, "ShortExternalStringMap"), + ("RO_SPACE", 0x04919): (114, "ShortExternalStringWithOneByteDataMap"), + ("RO_SPACE", 0x04981): (0, "InternalizedStringMap"), + ("RO_SPACE", 0x049e9): (2, "ExternalInternalizedStringMap"), + ("RO_SPACE", 0x04a51): (18, "ExternalInternalizedStringWithOneByteDataMap"), + ("RO_SPACE", 0x04ab9): (10, "ExternalOneByteInternalizedStringMap"), + ("RO_SPACE", 0x04b21): (34, "ShortExternalInternalizedStringMap"), + ("RO_SPACE", 0x04b89): (50, "ShortExternalInternalizedStringWithOneByteDataMap"), + ("RO_SPACE", 0x04bf1): (42, "ShortExternalOneByteInternalizedStringMap"), + ("RO_SPACE", 0x04c59): (106, "ShortExternalOneByteStringMap"), + ("RO_SPACE", 0x04cc1): (140, "FixedUint8ArrayMap"), + ("RO_SPACE", 0x04d29): (139, "FixedInt8ArrayMap"), + ("RO_SPACE", 0x04d91): (142, "FixedUint16ArrayMap"), + ("RO_SPACE", 0x04df9): (141, "FixedInt16ArrayMap"), + ("RO_SPACE", 0x04e61): (144, "FixedUint32ArrayMap"), + ("RO_SPACE", 0x04ec9): (143, "FixedInt32ArrayMap"), + ("RO_SPACE", 0x04f31): (145, "FixedFloat32ArrayMap"), + ("RO_SPACE", 0x04f99): (146, "FixedFloat64ArrayMap"), + ("RO_SPACE", 0x05001): (147, "FixedUint8ClampedArrayMap"), + ("RO_SPACE", 0x05069): (149, "FixedBigUint64ArrayMap"), + ("RO_SPACE", 0x050d1): (148, "FixedBigInt64ArrayMap"), + ("RO_SPACE", 0x05139): (131, "SelfReferenceMarkerMap"), + ("RO_SPACE", 0x051b9): (171, "Tuple2Map"), + ("RO_SPACE", 0x05509): (161, "InterceptorInfoMap"), + ("RO_SPACE", 0x05629): (169, "ScriptMap"), + ("RO_SPACE", 0x0a021): (154, "AccessorInfoMap"), + ("RO_SPACE", 0x0a089): (153, "AccessCheckInfoMap"), + ("RO_SPACE", 0x0a0f1): (155, "AccessorPairMap"), + ("RO_SPACE", 0x0a159): (156, "AliasedArgumentsEntryMap"), + ("RO_SPACE", 0x0a1c1): (157, "AllocationMementoMap"), + ("RO_SPACE", 0x0a229): (158, "AsyncGeneratorRequestMap"), + ("RO_SPACE", 0x0a291): (159, "DebugInfoMap"), + ("RO_SPACE", 0x0a2f9): (160, "FunctionTemplateInfoMap"), + ("RO_SPACE", 0x0a361): (162, "InterpreterDataMap"), + ("RO_SPACE", 0x0a3c9): (163, "ModuleInfoEntryMap"), + ("RO_SPACE", 0x0a431): (164, "ModuleMap"), + ("RO_SPACE", 0x0a499): (165, "ObjectTemplateInfoMap"), + ("RO_SPACE", 0x0a501): (166, "PromiseCapabilityMap"), + ("RO_SPACE", 0x0a569): (167, "PromiseReactionMap"), + ("RO_SPACE", 0x0a5d1): (168, "PrototypeInfoMap"), + ("RO_SPACE", 0x0a639): (170, "StackFrameInfoMap"), + ("RO_SPACE", 0x0a6a1): (172, "Tuple3Map"), + ("RO_SPACE", 0x0a709): (173, "ArrayBoilerplateDescriptionMap"), + ("RO_SPACE", 0x0a771): (174, "WasmDebugInfoMap"), + ("RO_SPACE", 0x0a7d9): (175, "WasmExportedFunctionDataMap"), + ("RO_SPACE", 0x0a841): (176, "CallableTaskMap"), + ("RO_SPACE", 0x0a8a9): (177, "CallbackTaskMap"), + ("RO_SPACE", 0x0a911): (178, "PromiseFulfillReactionJobTaskMap"), + ("RO_SPACE", 0x0a979): (179, "PromiseRejectReactionJobTaskMap"), + ("RO_SPACE", 0x0a9e1): (180, "PromiseResolveThenableJobTaskMap"), ("RO_SPACE", 0x0aa49): (181, "AllocationSiteMap"), + ("RO_SPACE", 0x0aab1): (181, "AllocationSiteMap"), ("MAP_SPACE", 0x02201): (1057, "ExternalMap"), ("MAP_SPACE", 0x02259): (1072, "JSMessageObjectMap"), } @@ -330,26 +332,26 @@ KNOWN_OBJECTS = { ("RO_SPACE", 0x03149): "TerminationException", ("RO_SPACE", 0x03211): "OptimizedOut", ("RO_SPACE", 0x032d1): "StaleRegister", - ("RO_SPACE", 0x051c9): "EmptyByteArray", - ("RO_SPACE", 0x051f1): "EmptyFixedUint8Array", - ("RO_SPACE", 0x05211): "EmptyFixedInt8Array", - ("RO_SPACE", 0x05231): "EmptyFixedUint16Array", - ("RO_SPACE", 0x05251): "EmptyFixedInt16Array", - ("RO_SPACE", 0x05271): "EmptyFixedUint32Array", - ("RO_SPACE", 0x05291): "EmptyFixedInt32Array", - ("RO_SPACE", 0x052b1): "EmptyFixedFloat32Array", - ("RO_SPACE", 0x052d1): "EmptyFixedFloat64Array", - ("RO_SPACE", 0x052f1): "EmptyFixedUint8ClampedArray", - ("RO_SPACE", 0x05351): "EmptySloppyArgumentsElements", - ("RO_SPACE", 0x05371): "EmptySlowElementDictionary", - ("RO_SPACE", 0x053b9): "EmptyOrderedHashMap", - ("RO_SPACE", 0x053e1): "EmptyOrderedHashSet", - ("RO_SPACE", 0x05419): "EmptyPropertyCell", - ("RO_SPACE", 0x05441): "EmptyWeakCell", - ("RO_SPACE", 0x05531): "InfinityValue", - ("RO_SPACE", 0x05541): "MinusZeroValue", - ("RO_SPACE", 0x05551): "MinusInfinityValue", - ("RO_SPACE", 0x05561): "SelfReferenceMarker", + ("RO_SPACE", 0x05231): "EmptyByteArray", + ("RO_SPACE", 0x05259): "EmptyFixedUint8Array", + ("RO_SPACE", 0x05279): "EmptyFixedInt8Array", + ("RO_SPACE", 0x05299): "EmptyFixedUint16Array", + ("RO_SPACE", 0x052b9): "EmptyFixedInt16Array", + ("RO_SPACE", 0x052d9): "EmptyFixedUint32Array", + ("RO_SPACE", 0x052f9): "EmptyFixedInt32Array", + ("RO_SPACE", 0x05319): "EmptyFixedFloat32Array", + ("RO_SPACE", 0x05339): "EmptyFixedFloat64Array", + ("RO_SPACE", 0x05359): "EmptyFixedUint8ClampedArray", + ("RO_SPACE", 0x053b9): "EmptySloppyArgumentsElements", + ("RO_SPACE", 0x053d9): "EmptySlowElementDictionary", + ("RO_SPACE", 0x05421): "EmptyOrderedHashMap", + ("RO_SPACE", 0x05449): "EmptyOrderedHashSet", + ("RO_SPACE", 0x05481): "EmptyPropertyCell", + ("RO_SPACE", 0x054a9): "EmptyWeakCell", + ("RO_SPACE", 0x05599): "InfinityValue", + ("RO_SPACE", 0x055a9): "MinusZeroValue", + ("RO_SPACE", 0x055b9): "MinusInfinityValue", + ("RO_SPACE", 0x055c9): "SelfReferenceMarker", ("OLD_SPACE", 0x02211): "EmptyScript", ("OLD_SPACE", 0x02291): "ManyClosuresCell", ("OLD_SPACE", 0x022b1): "NoElementsProtector",