[modules] Change ScriptOrModule to custom Struct

Due to caching issues we will not be able to store host-defined options
directly on the Script anymore. ScriptOrModule can thus no longer be
a i::Script.

NodeJS keeps weak references from ScriptOrModule to their import meta
data. This CL changes ScriptOrModule to be a temporary struct which has
a different lifetime. As a temporary fix until the API is fully updated
we introduce the v8_scriptormodule_legacy_lifetime compile-time flag.
It keeps references to ScriptOrModule alive on the Script to restore the
previous behavior (at an additional memory cost).

Bug: chromium:1244145
Change-Id: I1dc42d25930d7bc4f22ee3c9bba93d89425be406
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3211575
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77382}
This commit is contained in:
Camillo Bruni 2021-10-12 21:20:35 +02:00 committed by V8 LUCI CQ
parent c508ff8c6f
commit 52bb3cae7a
19 changed files with 268 additions and 194 deletions

View File

@ -343,6 +343,12 @@ declare_args() {
# Enable global allocation site tracking.
v8_allocation_site_tracking = true
# TODO(cbruni, v8:12302): Remove once API is migrated
# Enable legacy mode for ScriptOrModule's lifetime. By default it's a
# temporary object, if enabled it will be kept alive by the parent Script.
# This is only used by nodejs.
v8_scriptormodule_legacy_lifetime = false
# If enabled, the receiver is always included in the actual and formal
# parameter count of function with JS linkage.
# TODO(v8:11112): Remove once all architectures support the flag and it is
@ -962,6 +968,9 @@ config("features") {
if (v8_allocation_site_tracking) {
defines += [ "V8_ALLOCATION_SITE_TRACKING" ]
}
if (v8_scriptormodule_legacy_lifetime) {
defines += [ "V8_SCRIPTORMODULE_LEGACY_LIFETIME" ]
}
if (v8_advanced_bigint_algorithms) {
defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ]
}

View File

@ -111,7 +111,7 @@ MAKE_TO_LOCAL(CallableToLocal, JSReceiver, Function)
MAKE_TO_LOCAL(ToLocalPrimitive, Object, Primitive)
MAKE_TO_LOCAL(FixedArrayToLocal, FixedArray, FixedArray)
MAKE_TO_LOCAL(PrimitiveArrayToLocal, FixedArray, PrimitiveArray)
MAKE_TO_LOCAL(ScriptOrModuleToLocal, Script, ScriptOrModule)
MAKE_TO_LOCAL(ToLocal, ScriptOrModule, ScriptOrModule)
#undef MAKE_TO_LOCAL_TYPED_ARRAY
#undef MAKE_TO_LOCAL

View File

@ -2093,16 +2093,16 @@ MaybeLocal<Value> Script::Run(Local<Context> context) {
}
Local<Value> ScriptOrModule::GetResourceName() {
i::Handle<i::Script> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
i::Handle<i::ScriptOrModule> obj = Utils::OpenHandle(this);
i::Isolate* isolate = i::GetIsolateFromWritableObject(*obj);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
i::Handle<i::Object> val(obj->name(), isolate);
i::Handle<i::Object> val(obj->resource_name(), isolate);
return ToApiHandle<Value>(val);
}
Local<PrimitiveArray> ScriptOrModule::GetHostDefinedOptions() {
i::Handle<i::Script> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
i::Handle<i::ScriptOrModule> obj = Utils::OpenHandle(this);
i::Isolate* isolate = i::GetIsolateFromWritableObject(*obj);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
i::Handle<i::FixedArray> val(obj->host_defined_options(), isolate);
return ToApiHandle<PrimitiveArray>(val);
@ -2646,16 +2646,26 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
RETURN_ON_FAILED_EXECUTION(Function);
result = handle_scope.Escape(Utils::CallableToLocal(scoped_result));
}
// TODO(cbruni): remove script_or_module_out paramater
if (script_or_module_out != nullptr) {
i::Handle<i::JSFunction> function =
i::Handle<i::JSFunction>::cast(Utils::OpenHandle(*result));
i::Isolate* isolate = function->GetIsolate();
i::Handle<i::SharedFunctionInfo> shared(function->shared(), isolate);
i::Handle<i::Script> script(i::Script::cast(shared->script()), isolate);
*script_or_module_out = v8::Utils::ScriptOrModuleToLocal(script);
// TODO(cbruni, v8:12302): Avoid creating tempory ScriptOrModule objects.
auto script_or_module = i::Handle<i::ScriptOrModule>::cast(
isolate->factory()->NewStruct(i::SCRIPT_OR_MODULE_TYPE));
script_or_module->set_resource_name(script->name());
script_or_module->set_host_defined_options(script->host_defined_options());
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
i::Handle<i::ArrayList> list =
i::handle(script->script_or_modules(), isolate);
list = i::ArrayList::Add(isolate, list, script_or_module);
script->set_script_or_modules(*list);
#endif // V8_SCRIPTORMODULE_LEGACY_LIFETIME
*script_or_module_out = v8::Utils::ToLocal(script_or_module);
}
return result;
}

View File

@ -141,7 +141,7 @@ class RegisteredExtension {
V(Primitive, Object) \
V(PrimitiveArray, FixedArray) \
V(BigInt, BigInt) \
V(ScriptOrModule, Script) \
V(ScriptOrModule, ScriptOrModule) \
V(FixedArray, FixedArray) \
V(ModuleRequest, ModuleRequest) \
IF_WASM(V, WasmMemoryObject, WasmMemoryObject)
@ -254,8 +254,8 @@ class Utils {
v8::internal::Handle<v8::internal::FixedArray> obj);
static inline Local<PrimitiveArray> PrimitiveArrayToLocal(
v8::internal::Handle<v8::internal::FixedArray> obj);
static inline Local<ScriptOrModule> ScriptOrModuleToLocal(
v8::internal::Handle<v8::internal::Script> obj);
static inline Local<ScriptOrModule> ToLocal(
v8::internal::Handle<v8::internal::ScriptOrModule> obj);
#define DECLARE_OPEN_HANDLE(From, To) \
static inline v8::internal::Handle<v8::internal::To> OpenHandle( \

View File

@ -2079,6 +2079,12 @@ void AllocationMemento::AllocationMementoPrint(std::ostream& os) {
}
}
void ScriptOrModule::ScriptOrModulePrint(std::ostream& os) {
PrintHeader(os, "ScriptOrModule");
os << "\n - host_defined_options: " << Brief(host_defined_options());
os << "\n - resource_name: " << Brief(resource_name());
}
void Script::ScriptPrint(std::ostream& os) {
PrintHeader(os, "Script");
os << "\n - source: " << Brief(source());

View File

@ -4338,7 +4338,7 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
Handle<Script> referrer, Handle<Object> specifier,
MaybeHandle<Object> maybe_import_assertions_argument) {
v8::Local<v8::Context> api_context =
v8::Utils::ToLocal(Handle<Context>(native_context()));
v8::Utils::ToLocal(Handle<Context>::cast(native_context()));
if (host_import_module_dynamically_with_import_assertions_callback_ ==
nullptr) {
Handle<Object> exception =
@ -4357,21 +4357,25 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
v8::Local<v8::Promise> promise;
Handle<FixedArray> import_assertions_array;
if (GetImportAssertionsFromArgument(maybe_import_assertions_argument)
.ToHandle(&import_assertions_array)) {
ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
this, promise,
host_import_module_dynamically_with_import_assertions_callback_(
api_context, v8::Utils::ScriptOrModuleToLocal(referrer),
v8::Utils::ToLocal(specifier_str),
ToApiHandle<v8::FixedArray>(import_assertions_array)),
MaybeHandle<JSPromise>());
return v8::Utils::OpenHandle(*promise);
} else {
if (!GetImportAssertionsFromArgument(maybe_import_assertions_argument)
.ToHandle(&import_assertions_array)) {
Handle<Object> exception(pending_exception(), this);
clear_pending_exception();
return NewRejectedPromise(this, api_context, exception);
}
// TODO(cbruni, v8:12302): Avoid creating tempory ScriptOrModule objects.
auto script_or_module = i::Handle<i::ScriptOrModule>::cast(
this->factory()->NewStruct(i::SCRIPT_OR_MODULE_TYPE));
script_or_module->set_resource_name(referrer->name());
script_or_module->set_host_defined_options(referrer->host_defined_options());
ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
this, promise,
host_import_module_dynamically_with_import_assertions_callback_(
api_context, v8::Utils::ToLocal(script_or_module),
v8::Utils::ToLocal(specifier_str),
ToApiHandle<v8::FixedArray>(import_assertions_array)),
MaybeHandle<JSPromise>());
return v8::Utils::OpenHandle(*promise);
}
MaybeHandle<FixedArray> Isolate::GetImportAssertionsFromArgument(

View File

@ -228,6 +228,9 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId(
DCHECK(source->IsString() || source->IsUndefined());
// Create and initialize script object.
ReadOnlyRoots roots = read_only_roots();
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
Handle<ArrayList> list = NewArrayList(0);
#endif
Handle<Script> script = handle(
NewStructInternal<Script>(SCRIPT_TYPE, AllocationType::kOld), isolate());
{
@ -248,6 +251,9 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId(
SKIP_WRITE_BARRIER);
raw.set_flags(0);
raw.set_host_defined_options(roots.empty_fixed_array(), SKIP_WRITE_BARRIER);
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
raw.set_script_or_modules(*list);
#endif
}
if (script_id != Script::kTemporaryScriptId) {
@ -258,6 +264,15 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId(
return script;
}
template <typename Impl>
Handle<ArrayList> FactoryBase<Impl>::NewArrayList(int size) {
Handle<FixedArray> fixed_array = NewFixedArray(size + ArrayList::kFirstIndex);
fixed_array->set_map_no_write_barrier(read_only_roots().array_list_map());
Handle<ArrayList> result = Handle<ArrayList>::cast(fixed_array);
result->SetLength(0);
return result;
}
template <typename Impl>
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel) {

View File

@ -153,6 +153,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase
Handle<Script> NewScriptWithId(Handle<PrimitiveHeapObject> source,
int script_id);
Handle<ArrayList> NewArrayList(int size);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel);

View File

@ -1300,6 +1300,9 @@ void Factory::AddToScriptList(Handle<Script> script) {
Handle<Script> Factory::CloneScript(Handle<Script> script) {
Heap* heap = isolate()->heap();
int script_id = isolate()->GetNextScriptId();
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
Handle<ArrayList> list = ArrayList::New(isolate(), 0);
#endif
Handle<Script> new_script_handle =
Handle<Script>::cast(NewStruct(SCRIPT_TYPE, AllocationType::kOld));
{
@ -1321,7 +1324,11 @@ Handle<Script> Factory::CloneScript(Handle<Script> script) {
new_script.set_eval_from_position(old_script.eval_from_position());
new_script.set_flags(old_script.flags());
new_script.set_host_defined_options(old_script.host_defined_options());
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
new_script.set_script_or_modules(*list);
#endif
}
Handle<WeakArrayList> scripts = script_list();
scripts = WeakArrayList::AddToEnd(isolate(), scripts,
MaybeObjectHandle::Weak(new_script_handle));

View File

@ -480,12 +480,13 @@ class ArrayList : public TorqueGeneratedArrayList<ArrayList, FixedArray> {
static const int kHeaderFields = 1;
private:
static Handle<ArrayList> EnsureSpace(Isolate* isolate,
Handle<ArrayList> array, int length);
static const int kLengthIndex = 0;
static const int kFirstIndex = 1;
STATIC_ASSERT(kHeaderFields == kFirstIndex);
private:
static Handle<ArrayList> EnsureSpace(Isolate* isolate,
Handle<ArrayList> array, int length);
TQ_OBJECT_CONSTRUCTORS(ArrayList)
};

View File

@ -22,6 +22,7 @@ namespace internal {
TQ_OBJECT_CONSTRUCTORS_IMPL(Module)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSModuleNamespace)
TQ_OBJECT_CONSTRUCTORS_IMPL(ScriptOrModule)
NEVER_READ_ONLY_SPACE_IMPL(Module)
NEVER_READ_ONLY_SPACE_IMPL(ModuleRequest)

View File

@ -177,6 +177,13 @@ class JSModuleNamespace
TQ_OBJECT_CONSTRUCTORS(JSModuleNamespace)
};
class ScriptOrModule
: public TorqueGeneratedScriptOrModule<ScriptOrModule, Struct> {
public:
DECL_PRINTER(ScriptOrModule)
TQ_OBJECT_CONSTRUCTORS(ScriptOrModule)
};
} // namespace internal
} // namespace v8

View File

@ -18,3 +18,8 @@ extern class Module extends HeapObject {
}
extern class JSModuleNamespace extends JSSpecialObject { module: Module; }
extern class ScriptOrModule extends Struct {
resource_name: Object;
host_defined_options: FixedArray;
}

View File

@ -144,6 +144,7 @@ namespace internal {
V(_, REG_EXP_BOILERPLATE_DESCRIPTION_TYPE, RegExpBoilerplateDescription, \
regexp_boilerplate_description) \
V(_, SCRIPT_TYPE, Script, script) \
V(_, SCRIPT_OR_MODULE_TYPE, ScriptOrModule, script_or_module) \
V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \
module_info_entry) \
V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \

View File

@ -4014,13 +4014,7 @@ Handle<ArrayList> ArrayList::Add(Isolate* isolate, Handle<ArrayList> array,
// static
Handle<ArrayList> ArrayList::New(Isolate* isolate, int size) {
Handle<FixedArray> fixed_array =
isolate->factory()->NewFixedArray(size + kFirstIndex);
fixed_array->set_map_no_write_barrier(
ReadOnlyRoots(isolate).array_list_map());
Handle<ArrayList> result = Handle<ArrayList>::cast(fixed_array);
result->SetLength(0);
return result;
return isolate->factory()->NewArrayList(size);
}
Handle<FixedArray> ArrayList::Elements(Isolate* isolate,

View File

@ -59,4 +59,9 @@ extern class Script extends Struct {
// [host_defined_options]: Options defined by the embedder.
host_defined_options: FixedArray;
// TODO(cbruni, v8:12302): remove once module callback API is updated.
// Used to make sure we are backwards compatible with node to gaurantee
// the same lifetime for ScriptOrModule as the Script they originated.
@if(V8_SCRIPTORMODULE_LEGACY_LIFETIME) script_or_modules: ArrayList;
}

View File

@ -50,6 +50,11 @@ class BuildFlags : public ContextualClass<BuildFlags> {
build_flags_["TAGGED_SIZE_8_BYTES"] = TAGGED_SIZE_8_BYTES;
build_flags_["TRUE_FOR_TESTING"] = true;
build_flags_["FALSE_FOR_TESTING"] = false;
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
build_flags_["V8_SCRIPTORMODULE_LEGACY_LIFETIME"] = true;
#else
build_flags_["V8_SCRIPTORMODULE_LEGACY_LIFETIME"] = false;
#endif
}
static bool GetFlag(const std::string& name, const char* production) {
auto it = Get().build_flags_.find(name);

View File

@ -659,7 +659,7 @@ TEST(CompileFunctionInContextScriptOrigin) {
LocalContext env;
v8::ScriptOrigin origin(isolate, v8_str("test"), 22, 41);
v8::ScriptCompiler::Source script_source(v8_str("throw new Error()"), origin);
Local<ScriptOrModule> script;
Local<v8::ScriptOrModule> script;
v8::Local<v8::Function> fun =
v8::ScriptCompiler::CompileFunctionInContext(
env.local(), &script_source, 0, nullptr, 0, nullptr,

View File

@ -73,87 +73,88 @@ INSTANCE_TYPES = {
109: "PROTOTYPE_INFO_TYPE",
110: "REG_EXP_BOILERPLATE_DESCRIPTION_TYPE",
111: "SCRIPT_TYPE",
112: "SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE",
113: "STACK_FRAME_INFO_TYPE",
114: "TEMPLATE_OBJECT_DESCRIPTION_TYPE",
115: "TUPLE2_TYPE",
116: "WASM_EXCEPTION_TAG_TYPE",
117: "WASM_INDIRECT_FUNCTION_TABLE_TYPE",
118: "FIXED_ARRAY_TYPE",
119: "HASH_TABLE_TYPE",
120: "EPHEMERON_HASH_TABLE_TYPE",
121: "GLOBAL_DICTIONARY_TYPE",
122: "NAME_DICTIONARY_TYPE",
123: "NUMBER_DICTIONARY_TYPE",
124: "ORDERED_HASH_MAP_TYPE",
125: "ORDERED_HASH_SET_TYPE",
126: "ORDERED_NAME_DICTIONARY_TYPE",
127: "SIMPLE_NUMBER_DICTIONARY_TYPE",
128: "CLOSURE_FEEDBACK_CELL_ARRAY_TYPE",
129: "OBJECT_BOILERPLATE_DESCRIPTION_TYPE",
130: "SCRIPT_CONTEXT_TABLE_TYPE",
131: "BYTE_ARRAY_TYPE",
132: "BYTECODE_ARRAY_TYPE",
133: "FIXED_DOUBLE_ARRAY_TYPE",
134: "INTERNAL_CLASS_WITH_SMI_ELEMENTS_TYPE",
135: "SLOPPY_ARGUMENTS_ELEMENTS_TYPE",
136: "AWAIT_CONTEXT_TYPE",
137: "BLOCK_CONTEXT_TYPE",
138: "CATCH_CONTEXT_TYPE",
139: "DEBUG_EVALUATE_CONTEXT_TYPE",
140: "EVAL_CONTEXT_TYPE",
141: "FUNCTION_CONTEXT_TYPE",
142: "MODULE_CONTEXT_TYPE",
143: "NATIVE_CONTEXT_TYPE",
144: "SCRIPT_CONTEXT_TYPE",
145: "WITH_CONTEXT_TYPE",
146: "EXPORTED_SUB_CLASS_BASE_TYPE",
147: "EXPORTED_SUB_CLASS_TYPE",
148: "EXPORTED_SUB_CLASS2_TYPE",
149: "SMALL_ORDERED_HASH_MAP_TYPE",
150: "SMALL_ORDERED_HASH_SET_TYPE",
151: "SMALL_ORDERED_NAME_DICTIONARY_TYPE",
152: "DESCRIPTOR_ARRAY_TYPE",
153: "STRONG_DESCRIPTOR_ARRAY_TYPE",
154: "SOURCE_TEXT_MODULE_TYPE",
155: "SYNTHETIC_MODULE_TYPE",
156: "UNCOMPILED_DATA_WITH_PREPARSE_DATA_TYPE",
157: "UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_TYPE",
158: "WEAK_FIXED_ARRAY_TYPE",
159: "TRANSITION_ARRAY_TYPE",
160: "CALL_REF_DATA_TYPE",
161: "CELL_TYPE",
162: "CODE_TYPE",
163: "CODE_DATA_CONTAINER_TYPE",
164: "COVERAGE_INFO_TYPE",
165: "EMBEDDER_DATA_ARRAY_TYPE",
166: "FEEDBACK_METADATA_TYPE",
167: "FEEDBACK_VECTOR_TYPE",
168: "FILLER_TYPE",
169: "FREE_SPACE_TYPE",
170: "INTERNAL_CLASS_TYPE",
171: "INTERNAL_CLASS_WITH_STRUCT_ELEMENTS_TYPE",
172: "MAP_TYPE",
173: "MEGA_DOM_HANDLER_TYPE",
174: "ON_HEAP_BASIC_BLOCK_PROFILER_DATA_TYPE",
175: "PREPARSE_DATA_TYPE",
176: "PROPERTY_ARRAY_TYPE",
177: "PROPERTY_CELL_TYPE",
178: "SCOPE_INFO_TYPE",
179: "SHARED_FUNCTION_INFO_TYPE",
180: "SMI_BOX_TYPE",
181: "SMI_PAIR_TYPE",
182: "SORT_STATE_TYPE",
183: "SWISS_NAME_DICTIONARY_TYPE",
184: "WEAK_ARRAY_LIST_TYPE",
185: "WEAK_CELL_TYPE",
186: "WASM_ARRAY_TYPE",
187: "WASM_STRUCT_TYPE",
188: "JS_PROXY_TYPE",
112: "SCRIPT_OR_MODULE_TYPE",
113: "SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE",
114: "STACK_FRAME_INFO_TYPE",
115: "TEMPLATE_OBJECT_DESCRIPTION_TYPE",
116: "TUPLE2_TYPE",
117: "WASM_EXCEPTION_TAG_TYPE",
118: "WASM_INDIRECT_FUNCTION_TABLE_TYPE",
119: "FIXED_ARRAY_TYPE",
120: "HASH_TABLE_TYPE",
121: "EPHEMERON_HASH_TABLE_TYPE",
122: "GLOBAL_DICTIONARY_TYPE",
123: "NAME_DICTIONARY_TYPE",
124: "NUMBER_DICTIONARY_TYPE",
125: "ORDERED_HASH_MAP_TYPE",
126: "ORDERED_HASH_SET_TYPE",
127: "ORDERED_NAME_DICTIONARY_TYPE",
128: "SIMPLE_NUMBER_DICTIONARY_TYPE",
129: "CLOSURE_FEEDBACK_CELL_ARRAY_TYPE",
130: "OBJECT_BOILERPLATE_DESCRIPTION_TYPE",
131: "SCRIPT_CONTEXT_TABLE_TYPE",
132: "BYTE_ARRAY_TYPE",
133: "BYTECODE_ARRAY_TYPE",
134: "FIXED_DOUBLE_ARRAY_TYPE",
135: "INTERNAL_CLASS_WITH_SMI_ELEMENTS_TYPE",
136: "SLOPPY_ARGUMENTS_ELEMENTS_TYPE",
137: "AWAIT_CONTEXT_TYPE",
138: "BLOCK_CONTEXT_TYPE",
139: "CATCH_CONTEXT_TYPE",
140: "DEBUG_EVALUATE_CONTEXT_TYPE",
141: "EVAL_CONTEXT_TYPE",
142: "FUNCTION_CONTEXT_TYPE",
143: "MODULE_CONTEXT_TYPE",
144: "NATIVE_CONTEXT_TYPE",
145: "SCRIPT_CONTEXT_TYPE",
146: "WITH_CONTEXT_TYPE",
147: "EXPORTED_SUB_CLASS_BASE_TYPE",
148: "EXPORTED_SUB_CLASS_TYPE",
149: "EXPORTED_SUB_CLASS2_TYPE",
150: "SMALL_ORDERED_HASH_MAP_TYPE",
151: "SMALL_ORDERED_HASH_SET_TYPE",
152: "SMALL_ORDERED_NAME_DICTIONARY_TYPE",
153: "DESCRIPTOR_ARRAY_TYPE",
154: "STRONG_DESCRIPTOR_ARRAY_TYPE",
155: "SOURCE_TEXT_MODULE_TYPE",
156: "SYNTHETIC_MODULE_TYPE",
157: "UNCOMPILED_DATA_WITH_PREPARSE_DATA_TYPE",
158: "UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_TYPE",
159: "WEAK_FIXED_ARRAY_TYPE",
160: "TRANSITION_ARRAY_TYPE",
161: "CALL_REF_DATA_TYPE",
162: "CELL_TYPE",
163: "CODE_TYPE",
164: "CODE_DATA_CONTAINER_TYPE",
165: "COVERAGE_INFO_TYPE",
166: "EMBEDDER_DATA_ARRAY_TYPE",
167: "FEEDBACK_METADATA_TYPE",
168: "FEEDBACK_VECTOR_TYPE",
169: "FILLER_TYPE",
170: "FREE_SPACE_TYPE",
171: "INTERNAL_CLASS_TYPE",
172: "INTERNAL_CLASS_WITH_STRUCT_ELEMENTS_TYPE",
173: "MAP_TYPE",
174: "MEGA_DOM_HANDLER_TYPE",
175: "ON_HEAP_BASIC_BLOCK_PROFILER_DATA_TYPE",
176: "PREPARSE_DATA_TYPE",
177: "PROPERTY_ARRAY_TYPE",
178: "PROPERTY_CELL_TYPE",
179: "SCOPE_INFO_TYPE",
180: "SHARED_FUNCTION_INFO_TYPE",
181: "SMI_BOX_TYPE",
182: "SMI_PAIR_TYPE",
183: "SORT_STATE_TYPE",
184: "SWISS_NAME_DICTIONARY_TYPE",
185: "WEAK_ARRAY_LIST_TYPE",
186: "WEAK_CELL_TYPE",
187: "WASM_ARRAY_TYPE",
188: "WASM_STRUCT_TYPE",
189: "JS_PROXY_TYPE",
1057: "JS_OBJECT_TYPE",
189: "JS_GLOBAL_OBJECT_TYPE",
190: "JS_GLOBAL_PROXY_TYPE",
191: "JS_MODULE_NAMESPACE_TYPE",
190: "JS_GLOBAL_OBJECT_TYPE",
191: "JS_GLOBAL_PROXY_TYPE",
192: "JS_MODULE_NAMESPACE_TYPE",
1040: "JS_SPECIAL_API_OBJECT_TYPE",
1041: "JS_PRIMITIVE_WRAPPER_TYPE",
1058: "JS_API_OBJECT_TYPE",
@ -247,81 +248,81 @@ INSTANCE_TYPES = {
# List of known V8 maps.
KNOWN_MAPS = {
("read_only_space", 0x02119): (172, "MetaMap"),
("read_only_space", 0x02119): (173, "MetaMap"),
("read_only_space", 0x02141): (67, "NullMap"),
("read_only_space", 0x02169): (153, "StrongDescriptorArrayMap"),
("read_only_space", 0x02191): (158, "WeakFixedArrayMap"),
("read_only_space", 0x02169): (154, "StrongDescriptorArrayMap"),
("read_only_space", 0x02191): (159, "WeakFixedArrayMap"),
("read_only_space", 0x021d1): (100, "EnumCacheMap"),
("read_only_space", 0x02205): (118, "FixedArrayMap"),
("read_only_space", 0x02205): (119, "FixedArrayMap"),
("read_only_space", 0x02251): (8, "OneByteInternalizedStringMap"),
("read_only_space", 0x0229d): (169, "FreeSpaceMap"),
("read_only_space", 0x022c5): (168, "OnePointerFillerMap"),
("read_only_space", 0x022ed): (168, "TwoPointerFillerMap"),
("read_only_space", 0x0229d): (170, "FreeSpaceMap"),
("read_only_space", 0x022c5): (169, "OnePointerFillerMap"),
("read_only_space", 0x022ed): (169, "TwoPointerFillerMap"),
("read_only_space", 0x02315): (67, "UninitializedMap"),
("read_only_space", 0x0238d): (67, "UndefinedMap"),
("read_only_space", 0x023d1): (66, "HeapNumberMap"),
("read_only_space", 0x02405): (67, "TheHoleMap"),
("read_only_space", 0x02465): (67, "BooleanMap"),
("read_only_space", 0x02509): (131, "ByteArrayMap"),
("read_only_space", 0x02531): (118, "FixedCOWArrayMap"),
("read_only_space", 0x02559): (119, "HashTableMap"),
("read_only_space", 0x02509): (132, "ByteArrayMap"),
("read_only_space", 0x02531): (119, "FixedCOWArrayMap"),
("read_only_space", 0x02559): (120, "HashTableMap"),
("read_only_space", 0x02581): (64, "SymbolMap"),
("read_only_space", 0x025a9): (40, "OneByteStringMap"),
("read_only_space", 0x025d1): (178, "ScopeInfoMap"),
("read_only_space", 0x025f9): (179, "SharedFunctionInfoMap"),
("read_only_space", 0x02621): (162, "CodeMap"),
("read_only_space", 0x02649): (161, "CellMap"),
("read_only_space", 0x02671): (177, "GlobalPropertyCellMap"),
("read_only_space", 0x025d1): (179, "ScopeInfoMap"),
("read_only_space", 0x025f9): (180, "SharedFunctionInfoMap"),
("read_only_space", 0x02621): (163, "CodeMap"),
("read_only_space", 0x02649): (162, "CellMap"),
("read_only_space", 0x02671): (178, "GlobalPropertyCellMap"),
("read_only_space", 0x02699): (70, "ForeignMap"),
("read_only_space", 0x026c1): (159, "TransitionArrayMap"),
("read_only_space", 0x026c1): (160, "TransitionArrayMap"),
("read_only_space", 0x026e9): (45, "ThinOneByteStringMap"),
("read_only_space", 0x02711): (167, "FeedbackVectorMap"),
("read_only_space", 0x02711): (168, "FeedbackVectorMap"),
("read_only_space", 0x02749): (67, "ArgumentsMarkerMap"),
("read_only_space", 0x027a9): (67, "ExceptionMap"),
("read_only_space", 0x02805): (67, "TerminationExceptionMap"),
("read_only_space", 0x0286d): (67, "OptimizedOutMap"),
("read_only_space", 0x028cd): (67, "StaleRegisterMap"),
("read_only_space", 0x0292d): (130, "ScriptContextTableMap"),
("read_only_space", 0x02955): (128, "ClosureFeedbackCellArrayMap"),
("read_only_space", 0x0297d): (166, "FeedbackMetadataArrayMap"),
("read_only_space", 0x029a5): (118, "ArrayListMap"),
("read_only_space", 0x0292d): (131, "ScriptContextTableMap"),
("read_only_space", 0x02955): (129, "ClosureFeedbackCellArrayMap"),
("read_only_space", 0x0297d): (167, "FeedbackMetadataArrayMap"),
("read_only_space", 0x029a5): (119, "ArrayListMap"),
("read_only_space", 0x029cd): (65, "BigIntMap"),
("read_only_space", 0x029f5): (129, "ObjectBoilerplateDescriptionMap"),
("read_only_space", 0x02a1d): (132, "BytecodeArrayMap"),
("read_only_space", 0x02a45): (163, "CodeDataContainerMap"),
("read_only_space", 0x02a6d): (164, "CoverageInfoMap"),
("read_only_space", 0x02a95): (133, "FixedDoubleArrayMap"),
("read_only_space", 0x02abd): (121, "GlobalDictionaryMap"),
("read_only_space", 0x029f5): (130, "ObjectBoilerplateDescriptionMap"),
("read_only_space", 0x02a1d): (133, "BytecodeArrayMap"),
("read_only_space", 0x02a45): (164, "CodeDataContainerMap"),
("read_only_space", 0x02a6d): (165, "CoverageInfoMap"),
("read_only_space", 0x02a95): (134, "FixedDoubleArrayMap"),
("read_only_space", 0x02abd): (122, "GlobalDictionaryMap"),
("read_only_space", 0x02ae5): (101, "ManyClosuresCellMap"),
("read_only_space", 0x02b0d): (173, "MegaDomHandlerMap"),
("read_only_space", 0x02b35): (118, "ModuleInfoMap"),
("read_only_space", 0x02b5d): (122, "NameDictionaryMap"),
("read_only_space", 0x02b0d): (174, "MegaDomHandlerMap"),
("read_only_space", 0x02b35): (119, "ModuleInfoMap"),
("read_only_space", 0x02b5d): (123, "NameDictionaryMap"),
("read_only_space", 0x02b85): (101, "NoClosuresCellMap"),
("read_only_space", 0x02bad): (123, "NumberDictionaryMap"),
("read_only_space", 0x02bad): (124, "NumberDictionaryMap"),
("read_only_space", 0x02bd5): (101, "OneClosureCellMap"),
("read_only_space", 0x02bfd): (124, "OrderedHashMapMap"),
("read_only_space", 0x02c25): (125, "OrderedHashSetMap"),
("read_only_space", 0x02c4d): (126, "OrderedNameDictionaryMap"),
("read_only_space", 0x02c75): (175, "PreparseDataMap"),
("read_only_space", 0x02c9d): (176, "PropertyArrayMap"),
("read_only_space", 0x02bfd): (125, "OrderedHashMapMap"),
("read_only_space", 0x02c25): (126, "OrderedHashSetMap"),
("read_only_space", 0x02c4d): (127, "OrderedNameDictionaryMap"),
("read_only_space", 0x02c75): (176, "PreparseDataMap"),
("read_only_space", 0x02c9d): (177, "PropertyArrayMap"),
("read_only_space", 0x02cc5): (97, "SideEffectCallHandlerInfoMap"),
("read_only_space", 0x02ced): (97, "SideEffectFreeCallHandlerInfoMap"),
("read_only_space", 0x02d15): (97, "NextCallSideEffectFreeCallHandlerInfoMap"),
("read_only_space", 0x02d3d): (127, "SimpleNumberDictionaryMap"),
("read_only_space", 0x02d65): (149, "SmallOrderedHashMapMap"),
("read_only_space", 0x02d8d): (150, "SmallOrderedHashSetMap"),
("read_only_space", 0x02db5): (151, "SmallOrderedNameDictionaryMap"),
("read_only_space", 0x02ddd): (154, "SourceTextModuleMap"),
("read_only_space", 0x02e05): (183, "SwissNameDictionaryMap"),
("read_only_space", 0x02e2d): (155, "SyntheticModuleMap"),
("read_only_space", 0x02d3d): (128, "SimpleNumberDictionaryMap"),
("read_only_space", 0x02d65): (150, "SmallOrderedHashMapMap"),
("read_only_space", 0x02d8d): (151, "SmallOrderedHashSetMap"),
("read_only_space", 0x02db5): (152, "SmallOrderedNameDictionaryMap"),
("read_only_space", 0x02ddd): (155, "SourceTextModuleMap"),
("read_only_space", 0x02e05): (184, "SwissNameDictionaryMap"),
("read_only_space", 0x02e2d): (156, "SyntheticModuleMap"),
("read_only_space", 0x02e55): (72, "WasmCapiFunctionDataMap"),
("read_only_space", 0x02e7d): (73, "WasmExportedFunctionDataMap"),
("read_only_space", 0x02ea5): (74, "WasmJSFunctionDataMap"),
("read_only_space", 0x02ecd): (75, "WasmTypeInfoMap"),
("read_only_space", 0x02ef5): (184, "WeakArrayListMap"),
("read_only_space", 0x02f1d): (120, "EphemeronHashTableMap"),
("read_only_space", 0x02f45): (165, "EmbedderDataArrayMap"),
("read_only_space", 0x02f6d): (185, "WeakCellMap"),
("read_only_space", 0x02ef5): (185, "WeakArrayListMap"),
("read_only_space", 0x02f1d): (121, "EphemeronHashTableMap"),
("read_only_space", 0x02f45): (166, "EmbedderDataArrayMap"),
("read_only_space", 0x02f6d): (186, "WeakCellMap"),
("read_only_space", 0x02f95): (32, "StringMap"),
("read_only_space", 0x02fbd): (41, "ConsOneByteStringMap"),
("read_only_space", 0x02fe5): (33, "ConsStringMap"),
@ -369,38 +370,39 @@ KNOWN_MAPS = {
("read_only_space", 0x05fd5): (109, "PrototypeInfoMap"),
("read_only_space", 0x05ffd): (110, "RegExpBoilerplateDescriptionMap"),
("read_only_space", 0x06025): (111, "ScriptMap"),
("read_only_space", 0x0604d): (112, "SourceTextModuleInfoEntryMap"),
("read_only_space", 0x06075): (113, "StackFrameInfoMap"),
("read_only_space", 0x0609d): (114, "TemplateObjectDescriptionMap"),
("read_only_space", 0x060c5): (115, "Tuple2Map"),
("read_only_space", 0x060ed): (116, "WasmExceptionTagMap"),
("read_only_space", 0x06115): (117, "WasmIndirectFunctionTableMap"),
("read_only_space", 0x0613d): (135, "SloppyArgumentsElementsMap"),
("read_only_space", 0x06165): (152, "DescriptorArrayMap"),
("read_only_space", 0x0618d): (157, "UncompiledDataWithoutPreparseDataMap"),
("read_only_space", 0x061b5): (156, "UncompiledDataWithPreparseDataMap"),
("read_only_space", 0x061dd): (174, "OnHeapBasicBlockProfilerDataMap"),
("read_only_space", 0x06205): (170, "InternalClassMap"),
("read_only_space", 0x0622d): (181, "SmiPairMap"),
("read_only_space", 0x06255): (180, "SmiBoxMap"),
("read_only_space", 0x0627d): (146, "ExportedSubClassBaseMap"),
("read_only_space", 0x062a5): (147, "ExportedSubClassMap"),
("read_only_space", 0x062cd): (68, "AbstractInternalClassSubclass1Map"),
("read_only_space", 0x062f5): (69, "AbstractInternalClassSubclass2Map"),
("read_only_space", 0x0631d): (134, "InternalClassWithSmiElementsMap"),
("read_only_space", 0x06345): (171, "InternalClassWithStructElementsMap"),
("read_only_space", 0x0636d): (148, "ExportedSubClass2Map"),
("read_only_space", 0x06395): (182, "SortStateMap"),
("read_only_space", 0x063bd): (160, "CallRefDataMap"),
("read_only_space", 0x063e5): (90, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x0640d): (90, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x06435): (81, "LoadHandler1Map"),
("read_only_space", 0x0645d): (81, "LoadHandler2Map"),
("read_only_space", 0x06485): (81, "LoadHandler3Map"),
("read_only_space", 0x064ad): (82, "StoreHandler0Map"),
("read_only_space", 0x064d5): (82, "StoreHandler1Map"),
("read_only_space", 0x064fd): (82, "StoreHandler2Map"),
("read_only_space", 0x06525): (82, "StoreHandler3Map"),
("read_only_space", 0x0604d): (112, "ScriptOrModuleMap"),
("read_only_space", 0x06075): (113, "SourceTextModuleInfoEntryMap"),
("read_only_space", 0x0609d): (114, "StackFrameInfoMap"),
("read_only_space", 0x060c5): (115, "TemplateObjectDescriptionMap"),
("read_only_space", 0x060ed): (116, "Tuple2Map"),
("read_only_space", 0x06115): (117, "WasmExceptionTagMap"),
("read_only_space", 0x0613d): (118, "WasmIndirectFunctionTableMap"),
("read_only_space", 0x06165): (136, "SloppyArgumentsElementsMap"),
("read_only_space", 0x0618d): (153, "DescriptorArrayMap"),
("read_only_space", 0x061b5): (158, "UncompiledDataWithoutPreparseDataMap"),
("read_only_space", 0x061dd): (157, "UncompiledDataWithPreparseDataMap"),
("read_only_space", 0x06205): (175, "OnHeapBasicBlockProfilerDataMap"),
("read_only_space", 0x0622d): (171, "InternalClassMap"),
("read_only_space", 0x06255): (182, "SmiPairMap"),
("read_only_space", 0x0627d): (181, "SmiBoxMap"),
("read_only_space", 0x062a5): (147, "ExportedSubClassBaseMap"),
("read_only_space", 0x062cd): (148, "ExportedSubClassMap"),
("read_only_space", 0x062f5): (68, "AbstractInternalClassSubclass1Map"),
("read_only_space", 0x0631d): (69, "AbstractInternalClassSubclass2Map"),
("read_only_space", 0x06345): (135, "InternalClassWithSmiElementsMap"),
("read_only_space", 0x0636d): (172, "InternalClassWithStructElementsMap"),
("read_only_space", 0x06395): (149, "ExportedSubClass2Map"),
("read_only_space", 0x063bd): (183, "SortStateMap"),
("read_only_space", 0x063e5): (161, "CallRefDataMap"),
("read_only_space", 0x0640d): (90, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x06435): (90, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x0645d): (81, "LoadHandler1Map"),
("read_only_space", 0x06485): (81, "LoadHandler2Map"),
("read_only_space", 0x064ad): (81, "LoadHandler3Map"),
("read_only_space", 0x064d5): (82, "StoreHandler0Map"),
("read_only_space", 0x064fd): (82, "StoreHandler1Map"),
("read_only_space", 0x06525): (82, "StoreHandler2Map"),
("read_only_space", 0x0654d): (82, "StoreHandler3Map"),
("map_space", 0x02119): (1057, "ExternalMap"),
("map_space", 0x02141): (2114, "JSMessageObjectMap"),
}