mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
LibJS/JIT: Add fast path for Int32 & Int32
This commit is contained in:
parent
17ae6edd8e
commit
82635083dc
2 changed files with 29 additions and 1 deletions
|
@ -626,6 +626,35 @@ void Compiler::compile_less_than(Bytecode::Op::LessThan const& op)
|
|||
end.link(m_assembler);
|
||||
}
|
||||
|
||||
static Value cxx_bitwise_and(VM& vm, Value lhs, Value rhs)
|
||||
{
|
||||
return TRY_OR_SET_EXCEPTION(bitwise_and(vm, lhs, rhs));
|
||||
}
|
||||
|
||||
void Compiler::compile_bitwise_and(Bytecode::Op::BitwiseAnd const& op)
|
||||
{
|
||||
load_vm_register(ARG1, op.lhs());
|
||||
load_accumulator(ARG2);
|
||||
|
||||
Assembler::Label end {};
|
||||
|
||||
branch_if_both_int32(ARG1, ARG2, [&] {
|
||||
// NOTE: Since both sides are Int32, we know that the upper 32 bits are nothing but the INT32_TAG.
|
||||
// This means we can get away with just a simple 64-bit bitwise and.
|
||||
m_assembler.bitwise_and(
|
||||
Assembler::Operand::Register(ARG1),
|
||||
Assembler::Operand::Register(ARG2));
|
||||
|
||||
store_accumulator(ARG1);
|
||||
m_assembler.jump(end);
|
||||
});
|
||||
|
||||
native_call((void*)cxx_bitwise_and);
|
||||
store_accumulator(RET);
|
||||
check_exception();
|
||||
end.link(m_assembler);
|
||||
}
|
||||
|
||||
static ThrowCompletionOr<Value> not_(VM&, Value value)
|
||||
{
|
||||
return Value(!value.to_boolean());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue