mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 10:25:10 +00:00
LibWasm: Create AK::StackInfo once per AbstractMachine
This makes test-wasm about 20% faster on my Linux machine :^)
This commit is contained in:
parent
4cc1de1b03
commit
f5bf53bc99
4 changed files with 17 additions and 4 deletions
|
@ -162,7 +162,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
||||||
auxiliary_instance.globals().append(*ptr);
|
auxiliary_instance.globals().append(*ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
BytecodeInterpreter interpreter;
|
BytecodeInterpreter interpreter(m_stack_info);
|
||||||
|
|
||||||
module.for_each_section_of_type<GlobalSection>([&](auto& global_section) {
|
module.for_each_section_of_type<GlobalSection>([&](auto& global_section) {
|
||||||
for (auto& entry : global_section.entries()) {
|
for (auto& entry : global_section.entries()) {
|
||||||
|
@ -491,7 +491,7 @@ Optional<InstantiationError> AbstractMachine::allocate_all_final_phase(Module co
|
||||||
|
|
||||||
Result AbstractMachine::invoke(FunctionAddress address, Vector<Value> arguments)
|
Result AbstractMachine::invoke(FunctionAddress address, Vector<Value> arguments)
|
||||||
{
|
{
|
||||||
BytecodeInterpreter interpreter;
|
BytecodeInterpreter interpreter(m_stack_info);
|
||||||
return invoke(interpreter, address, move(arguments));
|
return invoke(interpreter, address, move(arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <AK/HashTable.h>
|
#include <AK/HashTable.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/Result.h>
|
#include <AK/Result.h>
|
||||||
|
#include <AK/StackInfo.h>
|
||||||
#include <LibWasm/Types.h>
|
#include <LibWasm/Types.h>
|
||||||
|
|
||||||
// NOTE: Special case for Wasm::Result.
|
// NOTE: Special case for Wasm::Result.
|
||||||
|
@ -607,6 +608,7 @@ private:
|
||||||
Optional<InstantiationError> allocate_all_initial_phase(Module const&, ModuleInstance&, Vector<ExternValue>&, Vector<Value>& global_values);
|
Optional<InstantiationError> allocate_all_initial_phase(Module const&, ModuleInstance&, Vector<ExternValue>&, Vector<Value>& global_values);
|
||||||
Optional<InstantiationError> allocate_all_final_phase(Module const&, ModuleInstance&, Vector<Vector<Reference>>& elements);
|
Optional<InstantiationError> allocate_all_final_phase(Module const&, ModuleInstance&, Vector<Vector<Reference>>& elements);
|
||||||
Store m_store;
|
Store m_store;
|
||||||
|
StackInfo m_stack_info;
|
||||||
bool m_should_limit_instruction_count { false };
|
bool m_should_limit_instruction_count { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
namespace Wasm {
|
namespace Wasm {
|
||||||
|
|
||||||
struct BytecodeInterpreter : public Interpreter {
|
struct BytecodeInterpreter : public Interpreter {
|
||||||
|
explicit BytecodeInterpreter(StackInfo const& stack_info)
|
||||||
|
: m_stack_info(stack_info)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual void interpret(Configuration&) override;
|
virtual void interpret(Configuration&) override;
|
||||||
virtual ~BytecodeInterpreter() override = default;
|
virtual ~BytecodeInterpreter() override = default;
|
||||||
virtual bool did_trap() const override { return !m_trap.has<Empty>(); }
|
virtual bool did_trap() const override { return !m_trap.has<Empty>(); }
|
||||||
|
@ -72,10 +77,14 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant<Trap, JS::Completion, Empty> m_trap;
|
Variant<Trap, JS::Completion, Empty> m_trap;
|
||||||
StackInfo m_stack_info;
|
StackInfo const& m_stack_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebuggerBytecodeInterpreter : public BytecodeInterpreter {
|
struct DebuggerBytecodeInterpreter : public BytecodeInterpreter {
|
||||||
|
DebuggerBytecodeInterpreter(StackInfo const& stack_info)
|
||||||
|
: BytecodeInterpreter(stack_info)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~DebuggerBytecodeInterpreter() override = default;
|
virtual ~DebuggerBytecodeInterpreter() override = default;
|
||||||
|
|
||||||
Function<bool(Configuration&, InstructionPointer&, Instruction const&)> pre_interpret_hook;
|
Function<bool(Configuration&, InstructionPointer&, Instruction const&)> pre_interpret_hook;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/MemoryStream.h>
|
#include <AK/MemoryStream.h>
|
||||||
|
#include <AK/StackInfo.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/MappedFile.h>
|
#include <LibCore/MappedFile.h>
|
||||||
|
@ -25,7 +26,8 @@ static OwnPtr<Stream> g_stdout {};
|
||||||
static OwnPtr<Wasm::Printer> g_printer {};
|
static OwnPtr<Wasm::Printer> g_printer {};
|
||||||
static bool g_continue { false };
|
static bool g_continue { false };
|
||||||
static void (*old_signal)(int);
|
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)
|
static void sigint_handler(int)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue