LibJS: Shrink ExecutionContext by replacing ScriptOrModule with Cell*

Replace the 16-byte Variant<Empty, GC::Ref<Script>, GC::Ref<Module>>
with a simple 8-byte GC::Ptr<Cell> that points to either a Script or
Module (or is null for Empty).

A helper function script_or_module_from_cell() converts back to the
full ScriptOrModule variant when needed (e.g. in
VM::get_active_script_or_module).
This commit is contained in:
Andreas Kling
2026-03-08 13:29:49 +01:00
committed by Andreas Kling
parent c8ad07dece
commit d3495c62a7
Notes: github-actions[bot] 2026-03-11 12:35:02 +00:00
16 changed files with 60 additions and 50 deletions

View File

@@ -167,7 +167,9 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(
unsafe_set_shape(realm()->intrinsics().normal_function_shape());
// 15. Set F.[[ScriptOrModule]] to GetActiveScriptOrModule().
m_script_or_module = vm().get_active_script_or_module();
vm().get_active_script_or_module().visit(
[](Empty) {},
[&](auto& ref) { m_script_or_module = ref.ptr(); });
}
void ECMAScriptFunctionObject::initialize(Realm& realm)
@@ -396,11 +398,7 @@ void ECMAScriptFunctionObject::visit_edges(Visitor& visitor)
visitor.visit(private_element.value);
}
m_script_or_module.visit(
[](Empty) {},
[&](auto& script_or_module) {
visitor.visit(script_or_module);
});
visitor.visit(m_script_or_module);
}
// 10.2.7 MakeMethod ( F, homeObject ), https://tc39.es/ecma262/#sec-makemethod