1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:57:45 +00:00

LibJS/JIT: Add fast path for Increment with Int32 value

This uses a new branch_if_int32() mechanism that takes a code generating
lambda whose code will run if the input register is an Int32 JS::Value.
This commit is contained in:
Andreas Kling 2023-10-23 10:20:35 +02:00
parent aeb9bd3bf1
commit ea65214c57
3 changed files with 99 additions and 0 deletions

View file

@ -204,6 +204,14 @@ struct Assembler {
return make_label();
}
void jump(Label& label)
{
// jmp target (RIP-relative 32-bit offset)
emit8(0xe9);
emit32(0xdeadbeef);
label.offset_in_instruction_stream = m_output.size();
}
void jump(Operand op)
{
if (op.type == Operand::Type::Reg) {
@ -309,6 +317,25 @@ struct Assembler {
}
}
void bitwise_or(Operand dst, Operand src)
{
// or dst,src
if (dst.type == Operand::Type::Reg && src.type == Operand::Type::Reg) {
emit8(0x48
| ((to_underlying(src.reg) >= 8) ? 1 << 2 : 0)
| ((to_underlying(dst.reg) >= 8) ? 1 << 0 : 0));
emit8(0x09);
emit8(0xc0 | (encode_reg(src.reg) << 3) | encode_reg(dst.reg));
} else if (dst.type == Operand::Type::Reg && src.type == Operand::Type::Imm32) {
emit8(0x48 | ((to_underlying(dst.reg) >= 8) ? 1 << 0 : 0));
emit8(0x81);
emit8(0xc8 | encode_reg(dst.reg));
emit32(src.offset_or_immediate);
} else {
VERIFY_NOT_REACHED();
}
}
void enter()
{
push_callee_saved_registers();
@ -459,6 +486,12 @@ struct Assembler {
pop(Operand::Register(Reg::RDX));
pop(Operand::Register(Reg::RCX));
}
void trap()
{
// int3
emit8(0xcc);
}
};
}