mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:37:35 +00:00
LibJS/JIT: Add fast path for loose equality check between 2 objects
There are more fast paths to be added here, just starting with this one since it's heavy on Kraken/ai-astar.js :^)
This commit is contained in:
parent
4e9e183a34
commit
e41f0d9dec
2 changed files with 45 additions and 1 deletions
|
@ -618,6 +618,51 @@ static ThrowCompletionOr<Value> strict_equals(VM&, Value src1, Value src2)
|
||||||
return Value(is_strictly_equal(src1, src2));
|
return Value(is_strictly_equal(src1, src2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_loosely_equals(VM& vm, Value lhs, Value rhs)
|
||||||
|
{
|
||||||
|
return TRY_OR_SET_EXCEPTION(loosely_equals(vm, lhs, rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_loosely_equals(Bytecode::Op::LooselyEquals const& op)
|
||||||
|
{
|
||||||
|
Assembler::Label end;
|
||||||
|
|
||||||
|
load_vm_register(ARG1, op.lhs());
|
||||||
|
load_accumulator(ARG2);
|
||||||
|
|
||||||
|
// Fast path if both sides are objects.
|
||||||
|
branch_if_object(ARG1, [&] {
|
||||||
|
branch_if_object(ARG2, [&] {
|
||||||
|
Assembler::Label true_case;
|
||||||
|
|
||||||
|
m_assembler.jump_if(
|
||||||
|
Assembler::Operand::Register(ARG1),
|
||||||
|
Assembler::Condition::EqualTo,
|
||||||
|
Assembler::Operand::Register(ARG2),
|
||||||
|
true_case);
|
||||||
|
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(GPR0),
|
||||||
|
Assembler::Operand::Imm(Value(false).encoded()));
|
||||||
|
store_accumulator(GPR0);
|
||||||
|
m_assembler.jump(end);
|
||||||
|
|
||||||
|
true_case.link(m_assembler);
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(GPR0),
|
||||||
|
Assembler::Operand::Imm(Value(true).encoded()));
|
||||||
|
store_accumulator(GPR0);
|
||||||
|
m_assembler.jump(end);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
native_call((void*)cxx_loosely_equals);
|
||||||
|
store_accumulator(RET);
|
||||||
|
check_exception();
|
||||||
|
|
||||||
|
end.link(m_assembler);
|
||||||
|
}
|
||||||
|
|
||||||
# define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
# define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||||
static Value cxx_##snake_case_name(VM& vm, Value lhs, Value rhs) \
|
static Value cxx_##snake_case_name(VM& vm, Value lhs, Value rhs) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -51,7 +51,6 @@ private:
|
||||||
O(In, in) \
|
O(In, in) \
|
||||||
O(InstanceOf, instance_of) \
|
O(InstanceOf, instance_of) \
|
||||||
O(LooselyInequals, loosely_inequals) \
|
O(LooselyInequals, loosely_inequals) \
|
||||||
O(LooselyEquals, loosely_equals) \
|
|
||||||
O(StrictlyInequals, strict_inequals) \
|
O(StrictlyInequals, strict_inequals) \
|
||||||
O(StrictlyEquals, strict_equals)
|
O(StrictlyEquals, strict_equals)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue