LibJS: Move all per-frame state from Interpreter to ExecutionContext

This simplifies function entry/exit and lets us just walk away from the
used ExecutionContext instead of resetting a bunch of its state when
returning control to the caller.
This commit is contained in:
Andreas Kling 2025-10-29 09:16:25 +01:00 committed by Andreas Kling
parent 59ce6c9b41
commit a7d13b107e
Notes: github-actions[bot] 2025-10-29 20:21:57 +00:00
3 changed files with 36 additions and 39 deletions

View file

@ -25,9 +25,9 @@ public:
explicit Interpreter(VM&);
~Interpreter();
[[nodiscard]] Realm& realm() { return *m_realm; }
[[nodiscard]] Object& global_object() { return *m_global_object; }
[[nodiscard]] DeclarativeEnvironment& global_declarative_environment() { return *m_global_declarative_environment; }
[[nodiscard]] Realm& realm() { return *m_running_execution_context->realm; }
[[nodiscard]] Object& global_object() { return *m_running_execution_context->global_object; }
[[nodiscard]] DeclarativeEnvironment& global_declarative_environment() { return *m_running_execution_context->global_declarative_environment; }
VM& vm() { return m_vm; }
VM const& vm() const { return m_vm; }
@ -50,11 +50,11 @@ public:
ALWAYS_INLINE Value& saved_return_value() { return reg(Register::saved_return_value()); }
Value& reg(Register const& r)
{
return m_registers_and_constants_and_locals_arguments.data()[r.index()];
return m_running_execution_context->registers_and_constants_and_locals_arguments.data()[r.index()];
}
Value reg(Register const& r) const
{
return m_registers_and_constants_and_locals_arguments.data()[r.index()];
return m_running_execution_context->registers_and_constants_and_locals_arguments.data()[r.index()];
}
[[nodiscard]] Value get(Operand) const;
@ -75,8 +75,8 @@ public:
void enter_object_environment(Object&);
Executable& current_executable() { return *m_current_executable; }
Executable const& current_executable() const { return *m_current_executable; }
Executable& current_executable() { return *m_running_execution_context->executable; }
Executable const& current_executable() const { return *m_running_execution_context->executable; }
ExecutionContext& running_execution_context() { return *m_running_execution_context; }
@ -98,14 +98,7 @@ private:
[[nodiscard]] HandleExceptionResponse handle_exception(u32& program_counter, Value exception);
VM& m_vm;
Optional<size_t> m_scheduled_jump;
GC::Ptr<Executable> m_current_executable { nullptr };
GC::Ptr<Realm> m_realm { nullptr };
GC::Ptr<Object> m_global_object { nullptr };
GC::Ptr<DeclarativeEnvironment> m_global_declarative_environment { nullptr };
Span<Value> m_registers_and_constants_and_locals_arguments;
ExecutionContext* m_running_execution_context { nullptr };
ReadonlySpan<Utf16FlyString> m_identifier_table;
};
JS_API extern bool g_dump_bytecode;