1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 05:47:34 +00:00

LibJS+LibJIT: Don't turn patchable movs into xors with self

If a mov instruction is meant to be patchable, we don't want to rewrite
it as a xor, since that removes the slot where we'd patch in the right
value later.

Also, make sure to set both size bits in the REX prefix for xoring a
register with itself.
This commit is contained in:
Andreas Kling 2023-10-26 19:48:37 +02:00
parent 8b32e98f3f
commit 5b198ccf32
2 changed files with 12 additions and 5 deletions

View file

@ -357,7 +357,8 @@ void Compiler::push_unwind_context(bool valid, Optional<Bytecode::Label> const&
// push finalizer (patched later)
m_assembler.mov(
Assembler::Operand::Register(GPR0),
Assembler::Operand::Imm64(0));
Assembler::Operand::Imm64(0),
Assembler::Patchable::Yes);
if (finalizer.has_value())
block_data_for(finalizer.value().block()).absolute_references_to_here.append(m_assembler.m_output.size() - 8);
m_assembler.push(Assembler::Operand::Register(GPR0));
@ -365,7 +366,8 @@ void Compiler::push_unwind_context(bool valid, Optional<Bytecode::Label> const&
// push handler (patched later)
m_assembler.mov(
Assembler::Operand::Register(GPR0),
Assembler::Operand::Imm64(0));
Assembler::Operand::Imm64(0),
Assembler::Patchable::Yes);
if (handler.has_value())
block_data_for(handler.value().block()).absolute_references_to_here.append(m_assembler.m_output.size() - 8);
m_assembler.push(Assembler::Operand::Register(GPR0));