1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:07:46 +00:00

LibJS/JIT: Sign-extend integers before comparing in LessThan fast path

This commit is contained in:
Andreas Kling 2023-10-26 14:49:58 +02:00
parent 4b7f5f4ae7
commit 5bd93f34af
2 changed files with 12 additions and 0 deletions

View file

@ -320,6 +320,14 @@ struct Assembler {
label.add_jump(m_output.size());
}
void sign_extend_32_to_64_bits(Reg reg)
{
// movsxd (reg as 64-bit), (reg as 32-bit)
emit8(0x48 | ((to_underlying(reg) >= 8) ? 1 << 0 : 0));
emit8(0x63);
emit8(0xc0 | (encode_reg(reg) << 3) | encode_reg(reg));
}
void bitwise_and(Operand dst, Operand src)
{
// and dst,src

View file

@ -468,6 +468,10 @@ void Compiler::compile_less_than(Bytecode::Op::LessThan const& op)
// else return false;
auto true_case = m_assembler.make_label();
m_assembler.sign_extend_32_to_64_bits(ARG1);
m_assembler.sign_extend_32_to_64_bits(ARG2);
m_assembler.jump_if_less_than(
Assembler::Operand::Register(ARG1),
Assembler::Operand::Register(ARG2),