From 8b32e98f3f9b8fd79d34dc0ccbd0f1a45d5b8ae6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 26 Oct 2023 15:40:06 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibJS/JIT/Compiler.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 43fd81ec09..40d666878d 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -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); });