From 1f0c67cc12b8640b196c39f7d860ab137a593b68 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 29 Apr 2025 16:08:42 +0200 Subject: [PATCH] Revert "LibJS: Add StackFrame to avoid indirection in VM register access" This reverts commit 36bb2824a67c21a481955a2699b47862976fe692. Although this was faster on my M3 MacBook Pro, other Apple machines disagree, including our benchmark runner. So let's revert it. --- Libraries/LibJS/Bytecode/Interpreter.cpp | 779 +++++++++++------------ Libraries/LibJS/Bytecode/Interpreter.h | 3 + Libraries/LibJS/Bytecode/Op.h | 280 ++++---- Libraries/LibJS/Forward.h | 1 - 4 files changed, 532 insertions(+), 531 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index 323443c22d8..960c85fcdb1 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -67,23 +67,6 @@ namespace JS::Bytecode { bool g_dump_bytecode = false; -class StackFrame { -public: - [[nodiscard]] ALWAYS_INLINE Value get(Operand op) const - { - return values()[op.index()]; - } - - ALWAYS_INLINE void set(Operand op, Value value) - { - values()[op.index()] = value; - } - -private: - [[nodiscard]] ALWAYS_INLINE Value* values() { return reinterpret_cast(this); } - [[nodiscard]] ALWAYS_INLINE Value const* values() const { return reinterpret_cast(this); } -}; - static ByteString format_operand(StringView name, Operand operand, Bytecode::Executable const& executable) { StringBuilder builder; @@ -202,6 +185,16 @@ Interpreter::~Interpreter() { } +ALWAYS_INLINE Value Interpreter::get(Operand op) const +{ + return m_registers_and_constants_and_locals_arguments.data()[op.index()]; +} + +ALWAYS_INLINE void Interpreter::set(Operand op, Value value) +{ + m_registers_and_constants_and_locals_arguments.data()[op.index()] = value; +} + ALWAYS_INLINE Value Interpreter::do_yield(Value value, Optional