From cba80580e26a6abd966303a9637bfd44a3d7fac5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 3 Apr 2025 15:09:49 +0200 Subject: [PATCH] Revert "LibJS: Avoid calling generic Instruction::length() during dispatch" This reverts commit 8f2ee01e6fb41b85f8966f0112034d95ce25f88e. Speculative revert, as this appears to severely regress performance on our JS benchmark runner. --- Libraries/LibJS/Bytecode/Interpreter.cpp | 2 +- Libraries/LibJS/Bytecode/Op.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index e868d4cd5c5..08d0f9cc692 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -386,7 +386,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) #define DISPATCH_NEXT(name) \ do { \ if constexpr (Op::name::IsVariableLength) \ - program_counter += static_cast(instruction).length(); \ + program_counter += instruction.length(); \ else \ program_counter += sizeof(Op::name); \ auto& next_instruction = *reinterpret_cast(&bytecode[program_counter]); \ diff --git a/Libraries/LibJS/Bytecode/Op.h b/Libraries/LibJS/Bytecode/Op.h index 6adca76f196..3b1e6438d8a 100644 --- a/Libraries/LibJS/Bytecode/Op.h +++ b/Libraries/LibJS/Bytecode/Op.h @@ -313,7 +313,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_excluded_names_count); } - size_t length() const { return length_impl(); } Operand dst() const { return m_dst; } Operand from_object() const { return m_from_object; } @@ -363,7 +362,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_element_count); } - size_t length() const { return length_impl(); } size_t element_count() const { return m_element_count; } @@ -390,7 +388,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Value) * m_element_count); } - size_t length() const { return length_impl(); } void execute_impl(Bytecode::Interpreter&) const; ByteString to_byte_string_impl(Bytecode::Executable const&) const; @@ -1819,7 +1816,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); } - size_t length() const { return length_impl(); } Operand dst() const { return m_dst; } Operand callee() const { return m_callee; } @@ -1869,7 +1865,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); } - size_t length() const { return length_impl(); } Operand dst() const { return m_dst; } Operand callee() const { return m_callee; } @@ -1921,7 +1916,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); } - size_t length() const { return length_impl(); } Operand dst() const { return m_dst; } Operand callee() const { return m_callee; } @@ -1970,7 +1964,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); } - size_t length() const { return length_impl(); } Operand dst() const { return m_dst; } Operand callee() const { return m_callee; } @@ -2088,7 +2081,6 @@ public: { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Optional) * m_element_keys_count); } - size_t length() const { return length_impl(); } ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; ByteString to_byte_string_impl(Bytecode::Executable const&) const;