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:
Andreas Kling 2021-06-09 09:23:38 +02:00
parent 48a8022cf6
commit a8ccc9580d
Notes: sideshowbarker 2024-07-18 12:35:23 +09:00
2 changed files with 19 additions and 18 deletions

View file

@ -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();
}
}
}

View file

@ -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
}
}