LibJS: Shrink two u64 fields in ExecutionContext to u32

To shrink ExecutionContext, these two fields are made 32-bit:

- skip_when_determining_incumbent_counter
- program_counter
This commit is contained in:
Andreas Kling 2025-10-29 08:42:30 +01:00 committed by Andreas Kling
parent 4c7ffc0552
commit 59ce6c9b41
4 changed files with 12 additions and 10 deletions

View File

@ -305,7 +305,7 @@ ThrowCompletionOr<Value> Interpreter::run(SourceTextModule& module)
return js_undefined();
}
NEVER_INLINE Interpreter::HandleExceptionResponse Interpreter::handle_exception(size_t& program_counter, Value exception)
NEVER_INLINE Interpreter::HandleExceptionResponse Interpreter::handle_exception(u32& program_counter, Value exception)
{
reg(Register::exception()) = exception;
m_scheduled_jump = {};
@ -349,7 +349,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point)
auto& executable = current_executable();
auto const* bytecode = executable.bytecode.data();
size_t& program_counter = running_execution_context.program_counter;
u32& program_counter = running_execution_context.program_counter;
program_counter = entry_point;
// Declare a lookup table for computed goto with each of the `handle_*` labels

View File

@ -95,7 +95,7 @@ private:
ExitFromExecutable,
ContinueInThisExecutable,
};
[[nodiscard]] HandleExceptionResponse handle_exception(size_t& program_counter, Value exception);
[[nodiscard]] HandleExceptionResponse handle_exception(u32& program_counter, Value exception);
VM& m_vm;
Optional<size_t> m_scheduled_jump;

View File

@ -58,7 +58,11 @@ public:
// Non-standard: This points at something that owns this ExecutionContext, in case it needs to be protected from GC.
GC::Ptr<Cell> context_owner;
size_t program_counter { 0 };
u32 program_counter { 0 };
// https://html.spec.whatwg.org/multipage/webappapis.html#skip-when-determining-incumbent-counter
// FIXME: Move this out of LibJS (e.g. by using the CustomData concept), as it's used exclusively by LibWeb.
u32 skip_when_determining_incumbent_counter { 0 };
mutable RefPtr<CachedSourceRange> cached_source_range;
@ -66,10 +70,6 @@ public:
GC::Ptr<Bytecode::Executable> executable;
// https://html.spec.whatwg.org/multipage/webappapis.html#skip-when-determining-incumbent-counter
// FIXME: Move this out of LibJS (e.g. by using the CustomData concept), as it's used exclusively by LibWeb.
size_t skip_when_determining_incumbent_counter { 0 };
Span<Value> registers_and_constants_and_locals_and_arguments_span()
{
return { registers_and_constants_and_locals_and_arguments(), registers_and_constants_and_locals_and_arguments_count };

View File

@ -207,8 +207,9 @@ void prepare_to_run_callback(JS::Realm& realm)
auto* context = top_most_script_having_execution_context(vm);
// 3. If context is not null, increment context's skip-when-determining-incumbent counter.
if (context)
if (context) {
context->skip_when_determining_incumbent_counter++;
}
}
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
@ -265,8 +266,9 @@ void clean_up_after_running_callback(JS::Realm const& realm)
auto* context = top_most_script_having_execution_context(vm);
// 2. If context is not null, decrement context's skip-when-determining-incumbent counter.
if (context)
if (context) {
context->skip_when_determining_incumbent_counter--;
}
// 3. Assert: the topmost entry of the backup incumbent realm stack is realm.
auto& event_loop = HTML::main_thread_event_loop();