LibWasm: Make BytecodeInterpreter overrides final

This gives us free devirtualization of some hot calls inside the
bytecode interpreter. Most notably the did_trap() checks.

Modest performance improvement on the https://figma.com/ landing page.
This commit is contained in:
Andreas Kling 2024-08-20 10:27:41 +02:00 committed by Andreas Kling
commit 2f3128333d
Notes: github-actions[bot] 2024-08-20 10:02:41 +00:00

View file

@ -18,18 +18,18 @@ struct BytecodeInterpreter : public Interpreter {
{ {
} }
virtual void interpret(Configuration&) override; virtual void interpret(Configuration&) final;
virtual ~BytecodeInterpreter() override = default; virtual ~BytecodeInterpreter() override = default;
virtual bool did_trap() const override { return !m_trap.has<Empty>(); } virtual bool did_trap() const final { return !m_trap.has<Empty>(); }
virtual ByteString trap_reason() const override virtual ByteString trap_reason() const final
{ {
return m_trap.visit( return m_trap.visit(
[](Empty) -> ByteString { VERIFY_NOT_REACHED(); }, [](Empty) -> ByteString { VERIFY_NOT_REACHED(); },
[](Trap const& trap) { return trap.reason; }, [](Trap const& trap) { return trap.reason; },
[](JS::Completion const& completion) { return completion.value()->to_string_without_side_effects().to_byte_string(); }); [](JS::Completion const& completion) { return completion.value()->to_string_without_side_effects().to_byte_string(); });
} }
virtual void clear_trap() override { m_trap = Empty {}; } virtual void clear_trap() final { m_trap = Empty {}; }
struct CallFrameHandle { struct CallFrameHandle {
explicit CallFrameHandle(BytecodeInterpreter& interpreter, Configuration& configuration) explicit CallFrameHandle(BytecodeInterpreter& interpreter, Configuration& configuration)