1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

LibJS/JIT: Simplify Increment Int32 fast path

When we know the value is a positive Int32 less than 0x7fffffff,
it's safe to just add 1 to it and use that as the final result.
This avoids the work of re-adding the INT32_TAG.
This commit is contained in:
Andreas Kling 2023-10-26 15:40:06 +02:00
parent b43e38112c
commit 8b32e98f3f

View file

@ -240,21 +240,13 @@ void Compiler::compile_increment(Bytecode::Op::Increment const&)
Assembler::Operand::Imm32(0x7fffffff),
slow_case);
// GPR0 += 1;
// ARG1 += 1;
m_assembler.add(
Assembler::Operand::Register(GPR0),
Assembler::Operand::Register(ARG1),
Assembler::Operand::Imm32(1));
// GPR0 |= INT32_TAG << 48;
m_assembler.mov(
Assembler::Operand::Register(GPR1),
Assembler::Operand::Imm64(SHIFTED_INT32_TAG));
m_assembler.bitwise_or(
Assembler::Operand::Register(GPR0),
Assembler::Operand::Register(GPR1));
// accumulator = GPR0;
store_vm_register(Bytecode::Register::accumulator(), GPR0);
// accumulator = ARG1;
store_vm_register(Bytecode::Register::accumulator(), ARG1);
m_assembler.jump(end);
});