Commit a9fed96c authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[parser] Make PreParsedScopeData array-like

Make PreParsedScopeData a new array-like instance type, which holds its
child data inline, rather than indirecting to a FixedArray. Should save
one map word per PreParsedScopeData.

TBR=jarin@chromium.org

Bug: chromium:818642
Change-Id: I72dc21160ed9781ad12b18559468f6cce56886fa
Reviewed-on: https://chromium-review.googlesource.com/1127055Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54349}
parent 39177148
...@@ -34,57 +34,58 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; ...@@ -34,57 +34,58 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
TypedArraySpeciesProtector) \ TypedArraySpeciesProtector) \
V(StoreHandler0Map, store_handler0_map, StoreHandler0Map) V(StoreHandler0Map, store_handler0_map, StoreHandler0Map)
#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ #define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \
V(AccessorInfoMap, accessor_info_map, AccessorInfoMap) \ V(AccessorInfoMap, accessor_info_map, AccessorInfoMap) \
V(AccessorPairMap, accessor_pair_map, AccessorPairMap) \ V(AccessorPairMap, accessor_pair_map, AccessorPairMap) \
V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \ V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \
V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \ V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \
AllocationSiteWithoutWeakNextMap) \ AllocationSiteWithoutWeakNextMap) \
V(BooleanMap, boolean_map, BooleanMap) \ V(BooleanMap, boolean_map, BooleanMap) \
V(CodeMap, code_map, CodeMap) \ V(CodeMap, code_map, CodeMap) \
V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \ V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \
V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ V(EmptySlowElementDictionary, empty_slow_element_dictionary, \
EmptySlowElementDictionary) \ EmptySlowElementDictionary) \
V(empty_string, empty_string, EmptyString) \ V(empty_string, empty_string, EmptyString) \
V(EmptyWeakCell, empty_weak_cell, EmptyWeakCell) \ V(EmptyWeakCell, empty_weak_cell, EmptyWeakCell) \
V(FalseValue, false_value, False) \ V(FalseValue, false_value, False) \
V(FeedbackVectorMap, feedback_vector_map, FeedbackVectorMap) \ V(FeedbackVectorMap, feedback_vector_map, FeedbackVectorMap) \
V(FixedArrayMap, fixed_array_map, FixedArrayMap) \ V(FixedArrayMap, fixed_array_map, FixedArrayMap) \
V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \ V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \
V(FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArrayMap) \ V(FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArrayMap) \
V(FunctionTemplateInfoMap, function_template_info_map, \ V(FunctionTemplateInfoMap, function_template_info_map, \
FunctionTemplateInfoMap) \ FunctionTemplateInfoMap) \
V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \ V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \
V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \ V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \
V(HeapNumberMap, heap_number_map, HeapNumberMap) \ V(HeapNumberMap, heap_number_map, HeapNumberMap) \
V(iterator_symbol, iterator_symbol, IteratorSymbol) \ V(iterator_symbol, iterator_symbol, IteratorSymbol) \
V(length_string, length_string, LengthString) \ V(length_string, length_string, LengthString) \
V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \ V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \
V(MetaMap, meta_map, MetaMap) \ V(MetaMap, meta_map, MetaMap) \
V(MinusZeroValue, minus_zero_value, MinusZero) \ V(MinusZeroValue, minus_zero_value, MinusZero) \
V(MutableHeapNumberMap, mutable_heap_number_map, MutableHeapNumberMap) \ V(MutableHeapNumberMap, mutable_heap_number_map, MutableHeapNumberMap) \
V(NanValue, nan_value, Nan) \ V(NanValue, nan_value, Nan) \
V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \ V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \
V(NullValue, null_value, Null) \ V(NullValue, null_value, Null) \
V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \ V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \
V(prototype_string, prototype_string, PrototypeString) \ V(PreParsedScopeDataMap, pre_parsed_scope_data_map, PreParsedScopeDataMap) \
V(SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfoMap) \ V(prototype_string, prototype_string, PrototypeString) \
V(SymbolMap, symbol_map, SymbolMap) \ V(SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfoMap) \
V(TheHoleValue, the_hole_value, TheHole) \ V(SymbolMap, symbol_map, SymbolMap) \
V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \ V(TheHoleValue, the_hole_value, TheHole) \
V(TrueValue, true_value, True) \ V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \
V(Tuple2Map, tuple2_map, Tuple2Map) \ V(TrueValue, true_value, True) \
V(Tuple3Map, tuple3_map, Tuple3Map) \ V(Tuple2Map, tuple2_map, Tuple2Map) \
V(ArrayBoilerplateDescriptionMap, array_boilerplate_description_map, \ V(Tuple3Map, tuple3_map, Tuple3Map) \
ArrayBoilerplateDescriptionMap) \ V(ArrayBoilerplateDescriptionMap, array_boilerplate_description_map, \
V(UncompiledDataWithoutPreParsedScopeMap, \ ArrayBoilerplateDescriptionMap) \
uncompiled_data_without_pre_parsed_scope_map, \ V(UncompiledDataWithoutPreParsedScopeMap, \
UncompiledDataWithoutPreParsedScopeMap) \ uncompiled_data_without_pre_parsed_scope_map, \
V(UncompiledDataWithPreParsedScopeMap, \ UncompiledDataWithoutPreParsedScopeMap) \
uncompiled_data_with_pre_parsed_scope_map, \ V(UncompiledDataWithPreParsedScopeMap, \
UncompiledDataWithPreParsedScopeMap) \ uncompiled_data_with_pre_parsed_scope_map, \
V(UndefinedValue, undefined_value, Undefined) \ UncompiledDataWithPreParsedScopeMap) \
V(WeakCellMap, weak_cell_map, WeakCellMap) \ V(UndefinedValue, undefined_value, Undefined) \
V(WeakCellMap, weak_cell_map, WeakCellMap) \
V(WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArrayMap) V(WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArrayMap)
#define HEAP_IMMOVABLE_OBJECT_LIST(V) \ #define HEAP_IMMOVABLE_OBJECT_LIST(V) \
......
...@@ -295,6 +295,7 @@ Type::bitset BitsetType::Lub(HeapObjectType const& type) { ...@@ -295,6 +295,7 @@ Type::bitset BitsetType::Lub(HeapObjectType const& type) {
case MODULE_TYPE: case MODULE_TYPE:
case MODULE_INFO_ENTRY_TYPE: case MODULE_INFO_ENTRY_TYPE:
case CELL_TYPE: case CELL_TYPE:
case PRE_PARSED_SCOPE_DATA_TYPE:
case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE:
case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE:
return kOtherInternal; return kOtherInternal;
......
...@@ -2487,11 +2487,15 @@ Handle<ModuleInfo> Factory::NewModuleInfo() { ...@@ -2487,11 +2487,15 @@ Handle<ModuleInfo> Factory::NewModuleInfo() {
ModuleInfo::kLength, TENURED); ModuleInfo::kLength, TENURED);
} }
Handle<PreParsedScopeData> Factory::NewPreParsedScopeData() { Handle<PreParsedScopeData> Factory::NewPreParsedScopeData(int length) {
Handle<PreParsedScopeData> result = int size = PreParsedScopeData::SizeFor(length);
Handle<PreParsedScopeData>::cast(NewStruct(TUPLE2_TYPE, TENURED)); Handle<PreParsedScopeData> result(
PreParsedScopeData::cast(AllocateRawWithImmortalMap(
size, TENURED, *pre_parsed_scope_data_map())),
isolate());
result->set_scope_data(PodArray<uint8_t>::cast(*empty_byte_array())); result->set_scope_data(PodArray<uint8_t>::cast(*empty_byte_array()));
result->set_child_data(*empty_fixed_array()); result->set_length(length);
MemsetPointer(result->child_data_start(), *null_value(), length);
return result; return result;
} }
......
...@@ -717,7 +717,7 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -717,7 +717,7 @@ class V8_EXPORT_PRIVATE Factory {
Handle<ModuleInfo> NewModuleInfo(); Handle<ModuleInfo> NewModuleInfo();
Handle<PreParsedScopeData> NewPreParsedScopeData(); Handle<PreParsedScopeData> NewPreParsedScopeData(int length);
Handle<UncompiledDataWithoutPreParsedScope> Handle<UncompiledDataWithoutPreParsedScope>
NewUncompiledDataWithoutPreParsedScope(int32_t start_position, NewUncompiledDataWithoutPreParsedScope(int32_t start_position,
......
...@@ -129,6 +129,7 @@ using v8::MemoryPressureLevel; ...@@ -129,6 +129,7 @@ using v8::MemoryPressureLevel;
V(OptimizedOut) \ V(OptimizedOut) \
V(OrderedHashMapMap) \ V(OrderedHashMapMap) \
V(OrderedHashSetMap) \ V(OrderedHashSetMap) \
V(PreParsedScopeDataMap) \
V(PropertyArrayMap) \ V(PropertyArrayMap) \
V(ScopeInfoMap) \ V(ScopeInfoMap) \
V(ScriptContextMap) \ V(ScriptContextMap) \
......
...@@ -48,6 +48,7 @@ class UncompiledDataWithPreParsedScope; ...@@ -48,6 +48,7 @@ class UncompiledDataWithPreParsedScope;
V(JSWeakCollection) \ V(JSWeakCollection) \
V(Map) \ V(Map) \
V(Oddball) \ V(Oddball) \
V(PreParsedScopeData) \
V(PropertyArray) \ V(PropertyArray) \
V(PropertyCell) \ V(PropertyCell) \
V(PrototypeInfo) \ V(PrototypeInfo) \
......
...@@ -498,6 +498,7 @@ bool Heap::CreateInitialMaps() { ...@@ -498,6 +498,7 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize, ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
next_call_side_effect_free_call_handler_info) 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, ALLOCATE_MAP(UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE,
UncompiledDataWithoutPreParsedScope::kSize, UncompiledDataWithoutPreParsedScope::kSize,
uncompiled_data_without_pre_parsed_scope) uncompiled_data_without_pre_parsed_scope)
......
...@@ -388,6 +388,24 @@ class FeedbackVector::BodyDescriptor final : public BodyDescriptorBase { ...@@ -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 <typename ObjectVisitor>
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 { class PrototypeInfo::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(Map* map, HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
...@@ -760,6 +778,9 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) { ...@@ -760,6 +778,9 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
case CODE_DATA_CONTAINER_TYPE: case CODE_DATA_CONTAINER_TYPE:
return Op::template apply<CodeDataContainer::BodyDescriptor>(p1, p2, p3, return Op::template apply<CodeDataContainer::BodyDescriptor>(p1, p2, p3,
p4); p4);
case PRE_PARSED_SCOPE_DATA_TYPE:
return Op::template apply<PreParsedScopeData::BodyDescriptor>(p1, p2, p3,
p4);
case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE:
return Op::template apply< return Op::template apply<
UncompiledDataWithPreParsedScope::BodyDescriptor>(p1, p2, p3, p4); UncompiledDataWithPreParsedScope::BodyDescriptor>(p1, p2, p3, p4);
......
...@@ -318,6 +318,9 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) { ...@@ -318,6 +318,9 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
case FOREIGN_TYPE: case FOREIGN_TYPE:
Foreign::cast(this)->ForeignVerify(isolate); Foreign::cast(this)->ForeignVerify(isolate);
break; break;
case PRE_PARSED_SCOPE_DATA_TYPE:
PreParsedScopeData::cast(this)->PreParsedScopeDataVerify(isolate);
break;
case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE:
UncompiledDataWithoutPreParsedScope::cast(this) UncompiledDataWithoutPreParsedScope::cast(this)
->UncompiledDataWithoutPreParsedScopeVerify(isolate); ->UncompiledDataWithoutPreParsedScopeVerify(isolate);
...@@ -1783,7 +1786,13 @@ void StackFrameInfo::StackFrameInfoVerify(Isolate* isolate) { ...@@ -1783,7 +1786,13 @@ void StackFrameInfo::StackFrameInfoVerify(Isolate* isolate) {
void PreParsedScopeData::PreParsedScopeDataVerify(Isolate* isolate) { void PreParsedScopeData::PreParsedScopeDataVerify(Isolate* isolate) {
CHECK(IsPreParsedScopeData()); CHECK(IsPreParsedScopeData());
CHECK(scope_data()->IsByteArray()); 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( void UncompiledDataWithPreParsedScope::UncompiledDataWithPreParsedScopeVerify(
......
...@@ -157,6 +157,7 @@ namespace internal { ...@@ -157,6 +157,7 @@ namespace internal {
V(FEEDBACK_CELL_TYPE) \ V(FEEDBACK_CELL_TYPE) \
V(FEEDBACK_VECTOR_TYPE) \ V(FEEDBACK_VECTOR_TYPE) \
V(LOAD_HANDLER_TYPE) \ V(LOAD_HANDLER_TYPE) \
V(PRE_PARSED_SCOPE_DATA_TYPE) \
V(PROPERTY_ARRAY_TYPE) \ V(PROPERTY_ARRAY_TYPE) \
V(PROPERTY_CELL_TYPE) \ V(PROPERTY_CELL_TYPE) \
V(SHARED_FUNCTION_INFO_TYPE) \ V(SHARED_FUNCTION_INFO_TYPE) \
......
...@@ -131,7 +131,7 @@ TYPE_CHECKER(NumberDictionary, NUMBER_DICTIONARY_TYPE) ...@@ -131,7 +131,7 @@ TYPE_CHECKER(NumberDictionary, NUMBER_DICTIONARY_TYPE)
TYPE_CHECKER(Oddball, ODDBALL_TYPE) TYPE_CHECKER(Oddball, ODDBALL_TYPE)
TYPE_CHECKER(OrderedHashMap, ORDERED_HASH_MAP_TYPE) TYPE_CHECKER(OrderedHashMap, ORDERED_HASH_MAP_TYPE)
TYPE_CHECKER(OrderedHashSet, ORDERED_HASH_SET_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(PropertyArray, PROPERTY_ARRAY_TYPE)
TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE) TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
TYPE_CHECKER(PropertyDescriptorObject, FIXED_ARRAY_TYPE) TYPE_CHECKER(PropertyDescriptorObject, FIXED_ARRAY_TYPE)
...@@ -2366,6 +2366,10 @@ int HeapObject::SizeFromMap(Map* map) const { ...@@ -2366,6 +2366,10 @@ int HeapObject::SizeFromMap(Map* map) const {
if (instance_type == BIGINT_TYPE) { if (instance_type == BIGINT_TYPE) {
return BigInt::SizeFor(reinterpret_cast<const BigInt*>(this)->length()); return BigInt::SizeFor(reinterpret_cast<const BigInt*>(this)->length());
} }
if (instance_type == PRE_PARSED_SCOPE_DATA_TYPE) {
return PreParsedScopeData::SizeFor(
reinterpret_cast<const PreParsedScopeData*>(this)->length());
}
DCHECK(instance_type == CODE_TYPE); DCHECK(instance_type == CODE_TYPE);
return reinterpret_cast<const Code*>(this)->CodeSize(); return reinterpret_cast<const Code*>(this)->CodeSize();
} }
......
...@@ -262,6 +262,9 @@ void HeapObject::HeapObjectPrint(Isolate* isolate, ...@@ -262,6 +262,9 @@ void HeapObject::HeapObjectPrint(Isolate* isolate,
case CALL_HANDLER_INFO_TYPE: case CALL_HANDLER_INFO_TYPE:
CallHandlerInfo::cast(this)->CallHandlerInfoPrint(os); CallHandlerInfo::cast(this)->CallHandlerInfoPrint(os);
break; break;
case PRE_PARSED_SCOPE_DATA_TYPE:
PreParsedScopeData::cast(this)->PreParsedScopeDataPrint(os);
break;
case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE:
UncompiledDataWithoutPreParsedScope::cast(this) UncompiledDataWithoutPreParsedScope::cast(this)
->UncompiledDataWithoutPreParsedScopePrint(os); ->UncompiledDataWithoutPreParsedScopePrint(os);
...@@ -2110,7 +2113,10 @@ void LayoutDescriptor::Print(std::ostream& os) { // NOLINT ...@@ -2110,7 +2113,10 @@ void LayoutDescriptor::Print(std::ostream& os) { // NOLINT
void PreParsedScopeData::PreParsedScopeDataPrint(std::ostream& os) { // NOLINT void PreParsedScopeData::PreParsedScopeDataPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PreParsedScopeData"); HeapObject::PrintHeader(os, "PreParsedScopeData");
os << "\n - scope_data: " << Brief(scope_data()); 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"; os << "\n";
} }
......
...@@ -3093,6 +3093,9 @@ VisitorId Map::GetVisitorId(Map* map) { ...@@ -3093,6 +3093,9 @@ VisitorId Map::GetVisitorId(Map* map) {
case WASM_INSTANCE_TYPE: case WASM_INSTANCE_TYPE:
return kVisitWasmInstanceObject; return kVisitWasmInstanceObject;
case PRE_PARSED_SCOPE_DATA_TYPE:
return kVisitPreParsedScopeData;
case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE:
return kVisitUncompiledDataWithPreParsedScope; return kVisitUncompiledDataWithPreParsedScope;
...@@ -3431,6 +3434,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT ...@@ -3431,6 +3434,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT) TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT)
#undef TYPED_ARRAY_SHORT_PRINT #undef TYPED_ARRAY_SHORT_PRINT
case PRE_PARSED_SCOPE_DATA_TYPE: {
PreParsedScopeData* data = PreParsedScopeData::cast(this);
os << "<PreParsedScopeData[" << data->length() << "]>";
break;
}
case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: { case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: {
UncompiledDataWithoutPreParsedScope* data = UncompiledDataWithoutPreParsedScope* data =
UncompiledDataWithoutPreParsedScope::cast(this); UncompiledDataWithoutPreParsedScope::cast(this);
......
...@@ -169,10 +169,10 @@ ...@@ -169,10 +169,10 @@
// - PromiseResolveThenableJobTask // - PromiseResolveThenableJobTask
// - Module // - Module
// - ModuleInfoEntry // - ModuleInfoEntry
// - PreParsedScopeData
// - WeakCell // - WeakCell
// - FeedbackCell // - FeedbackCell
// - FeedbackVector // - FeedbackVector
// - PreParsedScopeData
// - UncompiledData // - UncompiledData
// - UncompiledDataWithoutPreParsedScope // - UncompiledDataWithoutPreParsedScope
// - UncompiledDataWithPreParsedScope // - UncompiledDataWithPreParsedScope
...@@ -522,6 +522,7 @@ enum InstanceType : uint16_t { ...@@ -522,6 +522,7 @@ enum InstanceType : uint16_t {
FEEDBACK_CELL_TYPE, FEEDBACK_CELL_TYPE,
FEEDBACK_VECTOR_TYPE, FEEDBACK_VECTOR_TYPE,
LOAD_HANDLER_TYPE, LOAD_HANDLER_TYPE,
PRE_PARSED_SCOPE_DATA_TYPE,
PROPERTY_ARRAY_TYPE, PROPERTY_ARRAY_TYPE,
PROPERTY_CELL_TYPE, PROPERTY_CELL_TYPE,
SHARED_FUNCTION_INFO_TYPE, SHARED_FUNCTION_INFO_TYPE,
...@@ -703,6 +704,7 @@ class ModuleInfoEntry; ...@@ -703,6 +704,7 @@ class ModuleInfoEntry;
class ObjectHashTable; class ObjectHashTable;
class ObjectTemplateInfo; class ObjectTemplateInfo;
class ObjectVisitor; class ObjectVisitor;
class PreParsedScopeData;
class PropertyCell; class PropertyCell;
class PropertyDescriptor; class PropertyDescriptor;
class RootVisitor; class RootVisitor;
......
...@@ -44,6 +44,7 @@ namespace internal { ...@@ -44,6 +44,7 @@ namespace internal {
V(Map) \ V(Map) \
V(NativeContext) \ V(NativeContext) \
V(Oddball) \ V(Oddball) \
V(PreParsedScopeData) \
V(PropertyArray) \ V(PropertyArray) \
V(PropertyCell) \ V(PropertyCell) \
V(PrototypeInfo) \ V(PrototypeInfo) \
......
...@@ -20,7 +20,28 @@ namespace internal { ...@@ -20,7 +20,28 @@ namespace internal {
CAST_ACCESSOR(PreParsedScopeData) CAST_ACCESSOR(PreParsedScopeData)
ACCESSORS(PreParsedScopeData, scope_data, PodArray<uint8_t>, kScopeDataOffset) ACCESSORS(PreParsedScopeData, scope_data, PodArray<uint8_t>, 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);
}
CAST_ACCESSOR(UncompiledData) CAST_ACCESSOR(UncompiledData)
INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset) INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset)
......
...@@ -22,19 +22,41 @@ class WasmExportedFunctionData; ...@@ -22,19 +22,41 @@ class WasmExportedFunctionData;
// Data collected by the pre-parser storing information about scopes and inner // Data collected by the pre-parser storing information about scopes and inner
// functions. // functions.
class PreParsedScopeData : public Struct { class PreParsedScopeData : public HeapObject {
public: public:
DECL_ACCESSORS(scope_data, PodArray<uint8_t>) DECL_ACCESSORS(scope_data, PodArray<uint8_t>)
DECL_ACCESSORS(child_data, FixedArray) DECL_INT_ACCESSORS(length)
static const int kScopeDataOffset = Struct::kHeaderSize; inline Object* child_data(int index) const;
static const int kChildDataOffset = kScopeDataOffset + kPointerSize; inline void set_child_data(int index, Object* value,
static const int kSize = kChildDataOffset + kPointerSize; WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline Object** child_data_start() const;
DECL_CAST(PreParsedScopeData) DECL_CAST(PreParsedScopeData)
DECL_PRINTER(PreParsedScopeData) DECL_PRINTER(PreParsedScopeData)
DECL_VERIFIER(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: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PreParsedScopeData); DISALLOW_IMPLICIT_CONSTRUCTORS(PreParsedScopeData);
}; };
......
...@@ -292,30 +292,22 @@ MaybeHandle<PreParsedScopeData> ProducedPreParsedScopeData::Serialize( ...@@ -292,30 +292,22 @@ MaybeHandle<PreParsedScopeData> ProducedPreParsedScopeData::Serialize(
return MaybeHandle<PreParsedScopeData>(); return MaybeHandle<PreParsedScopeData>();
} }
Handle<PreParsedScopeData> data = isolate->factory()->NewPreParsedScopeData(); int child_data_length = static_cast<int>(data_for_inner_functions_.size());
Handle<PreParsedScopeData> data =
isolate->factory()->NewPreParsedScopeData(child_data_length);
Handle<PodArray<uint8_t>> scope_data_array = byte_data_->Serialize(isolate); Handle<PodArray<uint8_t>> scope_data_array = byte_data_->Serialize(isolate);
data->set_scope_data(*scope_data_array); data->set_scope_data(*scope_data_array);
int child_data_length = static_cast<int>(data_for_inner_functions_.size()); int i = 0;
if (child_data_length == 0) { for (const auto& item : data_for_inner_functions_) {
data->set_child_data(*(isolate->factory()->empty_fixed_array())); Handle<PreParsedScopeData> child_data;
} else { if (item->Serialize(isolate).ToHandle(&child_data)) {
Handle<FixedArray> child_array = data->set_child_data(i, *child_data);
isolate->factory()->NewFixedArray(child_data_length, TENURED); } else {
int i = 0; DCHECK(data->child_data(i)->IsNull());
for (const auto& item : data_for_inner_functions_) {
MaybeHandle<PreParsedScopeData> maybe_child_data =
item->Serialize(isolate);
if (maybe_child_data.is_null()) {
child_array->set(i++, *(isolate->factory()->null_value()));
} else {
Handle<PreParsedScopeData> child_data =
maybe_child_data.ToHandleChecked();
child_array->set(i++, *child_data);
}
} }
data->set_child_data(*child_array); i++;
} }
return data; return data;
...@@ -525,9 +517,8 @@ ConsumedPreParsedScopeData::GetDataForSkippableFunction( ...@@ -525,9 +517,8 @@ ConsumedPreParsedScopeData::GetDataForSkippableFunction(
// Retrieve the corresponding PreParsedScopeData and associate it to the // Retrieve the corresponding PreParsedScopeData and associate it to the
// skipped function. If the skipped functions contains inner functions, those // skipped function. If the skipped functions contains inner functions, those
// can be skipped when the skipped function is eagerly parsed. // can be skipped when the skipped function is eagerly parsed.
FixedArray* children = data_->child_data(); CHECK_GT(data_->length(), child_index_);
CHECK_GT(children->length(), child_index_); Object* child_data = data_->child_data(child_index_++);
Object* child_data = children->get(child_index_++);
if (!child_data->IsPreParsedScopeData()) { if (!child_data->IsPreParsedScopeData()) {
return nullptr; return nullptr;
} }
......
...@@ -89,6 +89,7 @@ namespace internal { ...@@ -89,6 +89,7 @@ namespace internal {
V(Map, one_closure_cell_map, OneClosureCellMap) \ V(Map, one_closure_cell_map, OneClosureCellMap) \
V(Map, ordered_hash_map_map, OrderedHashMapMap) \ V(Map, ordered_hash_map_map, OrderedHashMapMap) \
V(Map, ordered_hash_set_map, OrderedHashSetMap) \ V(Map, ordered_hash_set_map, OrderedHashSetMap) \
V(Map, pre_parsed_scope_data_map, PreParsedScopeDataMap) \
V(Map, property_array_map, PropertyArrayMap) \ V(Map, property_array_map, PropertyArrayMap) \
V(Map, side_effect_call_handler_info_map, SideEffectCallHandlerInfoMap) \ V(Map, side_effect_call_handler_info_map, SideEffectCallHandlerInfoMap) \
V(Map, side_effect_free_call_handler_info_map, \ V(Map, side_effect_free_call_handler_info_map, \
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment