mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibJS: Move Instruction::length() to the Op.h header
Make sure this gets inlined as well, as it's used by the bytecode stream iterator and thus extremely hot.
This commit is contained in:
parent
48a8022cf6
commit
a8ccc9580d
Notes:
sideshowbarker
2024-07-18 12:35:23 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a8ccc9580d7
2 changed files with 19 additions and 18 deletions
|
@ -25,22 +25,4 @@ void Instruction::destroy(Instruction& instruction)
|
|||
#undef __BYTECODE_OP
|
||||
}
|
||||
|
||||
size_t Instruction::length() const
|
||||
{
|
||||
if (type() == Type::Call)
|
||||
return static_cast<Op::Call const&>(*this).length();
|
||||
else if (type() == Type::NewArray)
|
||||
return static_cast<Op::NewArray const&>(*this).length();
|
||||
|
||||
#define __BYTECODE_OP(op) \
|
||||
case Type::op: \
|
||||
return sizeof(Op::op);
|
||||
|
||||
switch (type()) {
|
||||
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -392,4 +392,23 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons
|
|||
#undef __BYTECODE_OP
|
||||
}
|
||||
|
||||
ALWAYS_INLINE size_t Instruction::length() const
|
||||
{
|
||||
if (type() == Type::Call)
|
||||
return static_cast<Op::Call const&>(*this).length();
|
||||
else if (type() == Type::NewArray)
|
||||
return static_cast<Op::NewArray const&>(*this).length();
|
||||
|
||||
#define __BYTECODE_OP(op) \
|
||||
case Type::op: \
|
||||
return sizeof(Op::op);
|
||||
|
||||
switch (type()) {
|
||||
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
#undef __BYTECODE_OP
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue