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

@@ -114,7 +114,7 @@ public:
// This is used by LibWeb to disassociate event handler attribute callback functions from the nearest script on the call stack.
// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler Step 3.11
void set_script_or_module(ScriptOrModule script_or_module) { m_script_or_module = move(script_or_module); }
void set_script_or_module(GC::Ptr<Cell> script_or_module) { m_script_or_module = script_or_module; }
Variant<PropertyKey, PrivateName, Empty> const& class_field_initializer_name() const { return shared_data().m_class_field_initializer_name; }
@@ -151,7 +151,7 @@ private:
// Internal Slots of ECMAScript Function Objects, https://tc39.es/ecma262/#table-internal-slots-of-ecmascript-function-objects
GC::Ptr<Environment> m_environment; // [[Environment]]
GC::Ptr<PrivateEnvironment> m_private_environment; // [[PrivateEnvironment]]
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
GC::Ptr<Cell> m_script_or_module; // [[ScriptOrModule]]
GC::Ptr<Object> m_home_object; // [[HomeObject]]
struct ClassData {
Vector<ClassFieldDefinition> fields; // [[Fields]]