diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-05-24 21:24:28 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-05-27 17:28:41 +0430 |
commit | 477ab6dc4cc91225b334cc550f8d6b79b997d536 (patch) | |
tree | 043440adf57f55d834eb990df619f00868c721b6 /Userland/Libraries/LibWasm | |
parent | 85794f8244706ad125ff936616edbcbac9ea4540 (diff) | |
download | serenity-477ab6dc4cc91225b334cc550f8d6b79b997d536.zip |
LibWasm: Let the interpreter itself manage the call frame
Diffstat (limited to 'Userland/Libraries/LibWasm')
-rw-r--r-- | Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp index 45942f4dc0..5fee8c1aa7 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp @@ -128,7 +128,7 @@ void BytecodeInterpreter::call_address(Configuration& configuration, FunctionAdd Result result { Trap {} }; { - Configuration::CallFrameHandle handle { configuration }; + CallFrameHandle handle { *this, configuration }; result = configuration.call(*this, address, move(args)); } @@ -437,7 +437,10 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi for (size_t i = 0; i < frame.arity(); ++i) results.prepend(configuration.stack().pop()); // drop all locals +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" Optional<Label> last_label; +#pragma GCC diagnostic pop for (; !configuration.stack().is_empty();) { auto entry = configuration.stack().pop(); if (entry.has<Label>()) { diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h index cbe37862a8..73ab26c1ff 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h @@ -23,6 +23,19 @@ struct BytecodeInterpreter : public Interpreter { virtual bool did_trap() const override { return m_do_trap; } virtual void clear_trap() override { m_do_trap = false; } + struct CallFrameHandle { + explicit CallFrameHandle(BytecodeInterpreter& interpreter, Configuration& configuration) + : m_configuration_handle(configuration) + , m_interpreter(interpreter) + { + } + + ~CallFrameHandle() = default; + + Configuration::CallFrameHandle m_configuration_handle; + BytecodeInterpreter& m_interpreter; + }; + protected: virtual void interpret(Configuration&, InstructionPointer&, const Instruction&); void branch_to_label(Configuration&, LabelIndex); |