1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:37:35 +00:00

LibJS/JIT: Add Assembler::jump(Operand) and verify_not_reached()

Yet another jump() overload, and also a way to crash if we end up
somewhere we shouldn't be while in jitted code.
This commit is contained in:
Andreas Kling 2023-10-17 18:36:12 +02:00
parent e3560c2545
commit 9d35016284

View file

@ -204,6 +204,25 @@ struct Assembler {
return make_label();
}
void jump(Operand op)
{
if (op.type == Operand::Type::Reg) {
if (to_underlying(op.reg) >= 8)
emit8(0x41);
emit8(0xff);
emit8(0xe0 | encode_reg(op.reg));
} else {
VERIFY_NOT_REACHED();
}
}
void verify_not_reached()
{
// ud2
emit8(0x0f);
emit8(0x0b);
}
void jump(Bytecode::BasicBlock& target)
{
// jmp target (RIP-relative 32-bit offset)