diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp index d3d962b8ce..fe01816ef3 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp @@ -162,7 +162,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector([&](auto& global_section) { for (auto& entry : global_section.entries()) { @@ -491,7 +491,7 @@ Optional AbstractMachine::allocate_all_final_phase(Module co Result AbstractMachine::invoke(FunctionAddress address, Vector arguments) { - BytecodeInterpreter interpreter; + BytecodeInterpreter interpreter(m_stack_info); return invoke(interpreter, address, move(arguments)); } diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h index dac570e96f..a97c61286b 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h @@ -11,6 +11,7 @@ #include #include #include +#include #include // NOTE: Special case for Wasm::Result. @@ -607,6 +608,7 @@ private: Optional allocate_all_initial_phase(Module const&, ModuleInstance&, Vector&, Vector& global_values); Optional allocate_all_final_phase(Module const&, ModuleInstance&, Vector>& elements); Store m_store; + StackInfo m_stack_info; bool m_should_limit_instruction_count { false }; }; diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h index 9cb1385d30..7206301f52 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h @@ -13,6 +13,11 @@ namespace Wasm { struct BytecodeInterpreter : public Interpreter { + explicit BytecodeInterpreter(StackInfo const& stack_info) + : m_stack_info(stack_info) + { + } + virtual void interpret(Configuration&) override; virtual ~BytecodeInterpreter() override = default; virtual bool did_trap() const override { return !m_trap.has(); } @@ -72,10 +77,14 @@ protected: } Variant m_trap; - StackInfo m_stack_info; + StackInfo const& m_stack_info; }; struct DebuggerBytecodeInterpreter : public BytecodeInterpreter { + DebuggerBytecodeInterpreter(StackInfo const& stack_info) + : BytecodeInterpreter(stack_info) + { + } virtual ~DebuggerBytecodeInterpreter() override = default; Function pre_interpret_hook; diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp index 06604f5f02..01d6cf2e5a 100644 --- a/Userland/Utilities/wasm.cpp +++ b/Userland/Utilities/wasm.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -25,7 +26,8 @@ static OwnPtr g_stdout {}; static OwnPtr g_printer {}; static bool g_continue { false }; static void (*old_signal)(int); -static Wasm::DebuggerBytecodeInterpreter g_interpreter; +static StackInfo g_stack_info; +static Wasm::DebuggerBytecodeInterpreter g_interpreter(g_stack_info); static void sigint_handler(int) {