From 6061da33825598c18c664c2fc07a5600fb53e5f3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 28 Apr 2025 23:16:26 +0200 Subject: [PATCH] LibJS: Overload Instruction::length() on variable-length instructions This allows the DISPATCH_NEXT() macro to do the math to find the next instruction boundary point without performing a function call. --- Libraries/LibJS/Bytecode/Op.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Libraries/LibJS/Bytecode/Op.h b/Libraries/LibJS/Bytecode/Op.h index 95151084545..4cf41763a49 100644 --- a/Libraries/LibJS/Bytecode/Op.h +++ b/Libraries/LibJS/Bytecode/Op.h @@ -309,6 +309,7 @@ public: visitor(m_excluded_names[i]); } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_excluded_names_count); @@ -358,6 +359,7 @@ public: Operand dst() const { return m_dst; } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_element_count); @@ -384,6 +386,7 @@ public: m_elements[i] = elements[i]; } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Value) * m_element_count); @@ -1766,6 +1769,7 @@ public: m_arguments[i] = arguments[i]; } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); @@ -1815,6 +1819,7 @@ public: m_arguments[i] = arguments[i]; } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); @@ -1865,6 +1870,7 @@ public: m_arguments[i] = arguments[i]; } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); @@ -1910,6 +1916,7 @@ public: m_arguments[i] = arguments[i]; } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count); @@ -2027,6 +2034,7 @@ public: } } + size_t length() const { return length_impl(); } size_t length_impl() const { return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Optional) * m_element_keys_count);