mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00: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(dst),
|
||||||
Assembler::Operand::Register(src));
|
Assembler::Operand::Register(src));
|
||||||
|
|
||||||
// dst &= 1;
|
|
||||||
m_assembler.bitwise_and(
|
|
||||||
Assembler::Operand::Register(dst),
|
|
||||||
Assembler::Operand::Imm32(1));
|
|
||||||
|
|
||||||
// goto end;
|
// goto end;
|
||||||
auto end = m_assembler.jump();
|
auto end = m_assembler.jump();
|
||||||
|
|
||||||
|
@ -147,6 +142,11 @@ void Compiler::compile_to_boolean(Assembler::Reg dst, Assembler::Reg src)
|
||||||
|
|
||||||
// end:
|
// end:
|
||||||
end.link(m_assembler);
|
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)
|
void Compiler::compile_jump_conditional(Bytecode::Op::JumpConditional const& op)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue