mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-24 19:21:52 +00:00
LibJS: Avoid calling generic Instruction::length() during dispatch
Since we know the exact type, we can avoid calling the generic lookup function that branches on instruction type.
This commit is contained in:
parent
4b04e97feb
commit
8f2ee01e6f
Notes:
github-actions[bot]
2025-04-03 11:57:56 +00:00
Author: https://github.com/awesomekling
Commit: 8f2ee01e6f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4204
2 changed files with 9 additions and 1 deletions
|
@ -386,7 +386,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point)
|
||||||
#define DISPATCH_NEXT(name) \
|
#define DISPATCH_NEXT(name) \
|
||||||
do { \
|
do { \
|
||||||
if constexpr (Op::name::IsVariableLength) \
|
if constexpr (Op::name::IsVariableLength) \
|
||||||
program_counter += instruction.length(); \
|
program_counter += static_cast<Op::name const&>(instruction).length(); \
|
||||||
else \
|
else \
|
||||||
program_counter += sizeof(Op::name); \
|
program_counter += sizeof(Op::name); \
|
||||||
auto& next_instruction = *reinterpret_cast<Instruction const*>(&bytecode[program_counter]); \
|
auto& next_instruction = *reinterpret_cast<Instruction const*>(&bytecode[program_counter]); \
|
||||||
|
|
|
@ -313,6 +313,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_excluded_names_count);
|
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 dst() const { return m_dst; }
|
||||||
Operand from_object() const { return m_from_object; }
|
Operand from_object() const { return m_from_object; }
|
||||||
|
@ -362,6 +363,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_element_count);
|
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; }
|
size_t element_count() const { return m_element_count; }
|
||||||
|
|
||||||
|
@ -388,6 +390,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Value) * m_element_count);
|
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;
|
void execute_impl(Bytecode::Interpreter&) const;
|
||||||
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
||||||
|
@ -1816,6 +1819,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count);
|
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 dst() const { return m_dst; }
|
||||||
Operand callee() const { return m_callee; }
|
Operand callee() const { return m_callee; }
|
||||||
|
@ -1865,6 +1869,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count);
|
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 dst() const { return m_dst; }
|
||||||
Operand callee() const { return m_callee; }
|
Operand callee() const { return m_callee; }
|
||||||
|
@ -1916,6 +1921,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count);
|
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 dst() const { return m_dst; }
|
||||||
Operand callee() const { return m_callee; }
|
Operand callee() const { return m_callee; }
|
||||||
|
@ -1964,6 +1970,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * m_argument_count);
|
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 dst() const { return m_dst; }
|
||||||
Operand callee() const { return m_callee; }
|
Operand callee() const { return m_callee; }
|
||||||
|
@ -2081,6 +2088,7 @@ public:
|
||||||
{
|
{
|
||||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Optional<Operand>) * m_element_keys_count);
|
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Optional<Operand>) * m_element_keys_count);
|
||||||
}
|
}
|
||||||
|
size_t length() const { return length_impl(); }
|
||||||
|
|
||||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||||
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue