From 2f3128333dcd5a781f35272800631d6cf03803ad Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 20 Aug 2024 10:27:41 +0200 Subject: [PATCH] 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. --- .../LibWasm/AbstractMachine/BytecodeInterpreter.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h index 18234c56ee5..459807ac1e7 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h @@ -18,18 +18,18 @@ struct BytecodeInterpreter : public Interpreter { { } - virtual void interpret(Configuration&) override; + virtual void interpret(Configuration&) final; virtual ~BytecodeInterpreter() override = default; - virtual bool did_trap() const override { return !m_trap.has(); } - virtual ByteString trap_reason() const override + virtual bool did_trap() const final { return !m_trap.has(); } + virtual ByteString trap_reason() const final { return m_trap.visit( [](Empty) -> ByteString { VERIFY_NOT_REACHED(); }, [](Trap const& trap) { return trap.reason; }, [](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 { explicit CallFrameHandle(BytecodeInterpreter& interpreter, Configuration& configuration)