diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp index 49704fddd4..210d73e487 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp @@ -107,15 +107,15 @@ InstantiationResult AbstractMachine::instantiate(const Module& module, Vector([&](auto& global_section) { for (auto& entry : global_section.entries()) { - auto frame = make( - auxiliary_instance, - Vector {}, - entry.expression(), - 1); Configuration config { m_store }; config.pre_interpret_hook = &pre_interpret_hook; config.post_interpret_hook = &post_interpret_hook; - config.set_frame(move(frame)); + config.set_frame(Frame { + auxiliary_instance, + Vector {}, + entry.expression(), + 1, + }); auto result = config.execute(); // What if this traps? if (result.is_trap()) @@ -139,15 +139,15 @@ InstantiationResult AbstractMachine::instantiate(const Module& module, Vector( - main_module_instance, - Vector {}, - data.offset, - 1); Configuration config { m_store }; config.pre_interpret_hook = &pre_interpret_hook; config.post_interpret_hook = &post_interpret_hook; - config.set_frame(move(frame)); + config.set_frame(Frame { + main_module_instance, + Vector {}, + data.offset, + 1, + }); auto result = config.execute(); size_t offset = 0; result.values().first().value().visit( diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h index 346f93dee9..0b786c457c 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h @@ -392,8 +392,6 @@ private: }; class Frame { - AK_MAKE_NONCOPYABLE(Frame); - public: explicit Frame(const ModuleInstance& module, Vector locals, const Expression& expression, size_t arity) : m_module(module) @@ -418,7 +416,7 @@ private: class Stack { public: - using EntryType = Variant>; + using EntryType = Variant; Stack() = default; [[nodiscard]] bool is_empty() const { return m_data.is_empty(); } @@ -428,9 +426,10 @@ public: auto size() const { return m_data.size(); } auto& entries() const { return m_data; } + auto& entries() { return m_data; } private: - Vector m_data; + Vector m_data; }; using InstantiationResult = AK::Result, InstantiationError>; diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp index 5bc8628008..b73f25261e 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp @@ -35,13 +35,12 @@ Result Configuration::call(FunctionAddress address, Vector arguments) for (auto& type : wasm_function->code().locals()) locals.empend(type, 0ull); - auto frame = make( + set_frame(Frame { wasm_function->module(), move(locals), wasm_function->code().body(), - wasm_function->type().results().size()); - - set_frame(move(frame)); + wasm_function->type().results().size(), + }); return execute(); } @@ -61,8 +60,8 @@ Result Configuration::execute() return Trap {}; Vector results; - results.ensure_capacity(m_current_frame->arity()); - for (size_t i = 0; i < m_current_frame->arity(); ++i) + results.ensure_capacity(frame().arity()); + for (size_t i = 0; i < frame().arity(); ++i) results.append(move(stack().pop().get())); auto label = stack().pop(); // ASSERT: label == current frame @@ -83,9 +82,9 @@ void Configuration::dump_stack() dbgln(" *{}", v.value()); }); }, - [](const NonnullOwnPtr& f) { - dbgln(" frame({})", f->arity()); - for (auto& local : f->locals()) { + [](const Frame& f) { + dbgln(" frame({})", f.arity()); + for (auto& local : f.locals()) { local.value().visit([](const T& v) { if constexpr (IsIntegral || IsFloatingPoint) dbgln(" {}", v); diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h index 8b792c1535..70658c447b 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h @@ -18,14 +18,15 @@ public: } Optional