mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:37:35 +00:00
LibJS/JIT: Add fast path for LeftShift
This commit is contained in:
parent
a1cdfe1b54
commit
1244e91481
3 changed files with 55 additions and 1 deletions
|
@ -566,6 +566,23 @@ struct X86_64Assembler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shift_left32(Operand dest, Optional<Operand> count)
|
||||||
|
{
|
||||||
|
VERIFY(dest.type == Operand::Type::Reg);
|
||||||
|
if (count.has_value()) {
|
||||||
|
VERIFY(count->type == Operand::Type::Imm);
|
||||||
|
VERIFY(count->fits_in_u8());
|
||||||
|
emit_rex_for_slash(dest, REX_W::No);
|
||||||
|
emit8(0xc1);
|
||||||
|
emit_modrm_slash(4, dest);
|
||||||
|
emit8(count->offset_or_immediate);
|
||||||
|
} else {
|
||||||
|
emit_rex_for_slash(dest, REX_W::No);
|
||||||
|
emit8(0xd3);
|
||||||
|
emit_modrm_slash(4, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void enter()
|
void enter()
|
||||||
{
|
{
|
||||||
push(Operand::Register(Reg::RBP));
|
push(Operand::Register(Reg::RBP));
|
||||||
|
|
|
@ -762,6 +762,44 @@ void Compiler::compile_bitwise_xor(Bytecode::Op::BitwiseXor const& op)
|
||||||
end.link(m_assembler);
|
end.link(m_assembler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_left_shift(VM& vm, Value lhs, Value rhs)
|
||||||
|
{
|
||||||
|
return TRY_OR_SET_EXCEPTION(left_shift(vm, lhs, rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_left_shift(Bytecode::Op::LeftShift const& op)
|
||||||
|
{
|
||||||
|
load_vm_register(ARG1, op.lhs());
|
||||||
|
load_accumulator(ARG2);
|
||||||
|
|
||||||
|
Assembler::Label end {};
|
||||||
|
|
||||||
|
branch_if_both_int32(ARG1, ARG2, [&] {
|
||||||
|
// RCX = ARG2
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(Assembler::Reg::RCX),
|
||||||
|
Assembler::Operand::Register(ARG2));
|
||||||
|
|
||||||
|
// ARG1 <<= CL (32-bit)
|
||||||
|
m_assembler.shift_left32(Assembler::Operand::Register(ARG1), {});
|
||||||
|
|
||||||
|
// accumulator = ARG1 | SHIFTED_INT32_TAG;
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(GPR0),
|
||||||
|
Assembler::Operand::Imm(SHIFTED_INT32_TAG));
|
||||||
|
m_assembler.bitwise_or(
|
||||||
|
Assembler::Operand::Register(ARG1),
|
||||||
|
Assembler::Operand::Register(GPR0));
|
||||||
|
store_accumulator(ARG1);
|
||||||
|
m_assembler.jump(end);
|
||||||
|
});
|
||||||
|
|
||||||
|
native_call((void*)cxx_left_shift);
|
||||||
|
store_accumulator(RET);
|
||||||
|
check_exception();
|
||||||
|
end.link(m_assembler);
|
||||||
|
}
|
||||||
|
|
||||||
static ThrowCompletionOr<Value> not_(VM&, Value value)
|
static ThrowCompletionOr<Value> not_(VM&, Value value)
|
||||||
{
|
{
|
||||||
return Value(!value.to_boolean());
|
return Value(!value.to_boolean());
|
||||||
|
|
|
@ -53,7 +53,6 @@ private:
|
||||||
O(LooselyEquals, abstract_equals) \
|
O(LooselyEquals, abstract_equals) \
|
||||||
O(StrictlyInequals, typed_inequals) \
|
O(StrictlyInequals, typed_inequals) \
|
||||||
O(StrictlyEquals, typed_equals) \
|
O(StrictlyEquals, typed_equals) \
|
||||||
O(LeftShift, left_shift) \
|
|
||||||
O(RightShift, right_shift) \
|
O(RightShift, right_shift) \
|
||||||
O(UnsignedRightShift, unsigned_right_shift)
|
O(UnsignedRightShift, unsigned_right_shift)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue