LibJS/JIT: Always mask everything but LSB in ToBoolean

As it turns out, cxx_to_boolean() may return "bool" as other values
than just 0 or 1. This happens when the C++ compiler decides to only
update the AL portion of the RAX return value register instead of
the whole thing.
This commit is contained in:
Andreas Kling 2023-10-27 11:12:52 +02:00
parent 5b198ccf32
commit e2f5bfb4c4

View file

@ -127,11 +127,6 @@ void Compiler::compile_to_boolean(Assembler::Reg dst, Assembler::Reg src)
Assembler::Operand::Register(dst),
Assembler::Operand::Register(src));
// dst &= 1;
m_assembler.bitwise_and(
Assembler::Operand::Register(dst),
Assembler::Operand::Imm32(1));
// goto end;
auto end = m_assembler.jump();
@ -147,6 +142,11 @@ void Compiler::compile_to_boolean(Assembler::Reg dst, Assembler::Reg src)
// end:
end.link(m_assembler);
// dst &= 1;
m_assembler.bitwise_and(
Assembler::Operand::Register(dst),
Assembler::Operand::Imm32(1));
}
void Compiler::compile_jump_conditional(Bytecode::Op::JumpConditional const& op)