mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
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:
parent
5b198ccf32
commit
e2f5bfb4c4
1 changed files with 5 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue