diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index 1bce070009..84e75791ab 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -305,7 +305,7 @@ ThrowCompletionOr 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 diff --git a/Libraries/LibJS/Bytecode/Interpreter.h b/Libraries/LibJS/Bytecode/Interpreter.h index 8760ac36e9..c1064fd304 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.h +++ b/Libraries/LibJS/Bytecode/Interpreter.h @@ -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 m_scheduled_jump; diff --git a/Libraries/LibJS/Runtime/ExecutionContext.h b/Libraries/LibJS/Runtime/ExecutionContext.h index 6b6c791aeb..ab378ec0a4 100644 --- a/Libraries/LibJS/Runtime/ExecutionContext.h +++ b/Libraries/LibJS/Runtime/ExecutionContext.h @@ -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 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 cached_source_range; @@ -66,10 +70,6 @@ public: GC::Ptr 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 registers_and_constants_and_locals_and_arguments_span() { return { registers_and_constants_and_locals_and_arguments(), registers_and_constants_and_locals_and_arguments_count }; diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cpp index 0b917b0450..f80ec75756 100644 --- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -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();