Commit 2db0c1c6 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Support TestInstanceOf (generic)

Bug: v8:7700
Change-Id: I2cfb80046798e77f4392f16ebb8b3e89632d3da4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3762570Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81743}
parent 7f9c35d4
......@@ -1533,7 +1533,21 @@ void MaglevGraphBuilder::VisitTestGreaterThanOrEqual() {
VisitCompareOperation<Operation::kGreaterThanOrEqual>();
}
MAGLEV_UNIMPLEMENTED_BYTECODE(TestInstanceOf)
void MaglevGraphBuilder::VisitTestInstanceOf() {
// TestInstanceOf <src> <feedback_slot>
ValueNode* object = LoadRegisterTagged(0);
ValueNode* callable = GetAccumulatorTagged();
FeedbackSlot slot = GetSlotOperand(1);
compiler::FeedbackSource feedback_source{feedback(), slot};
// TODO(victorgomes): Check feedback slot and a do static lookup for
// @@hasInstance.
USE(feedback_source);
ValueNode* context = GetContext();
SetAccumulator(AddNewNode<TestInstanceOf>({context, object, callable}));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(TestIn)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToName)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToNumber)
......
......@@ -152,6 +152,7 @@ class MaglevGraphVerifier {
case Opcode::kSetNamedGeneric:
case Opcode::kDefineNamedOwnGeneric:
case Opcode::kGetKeyedGeneric:
case Opcode::kTestInstanceOf:
DCHECK_EQ(node->input_count(), 3);
CheckValueInputIs(node, 0, ValueRepresentation::kTagged);
CheckValueInputIs(node, 1, ValueRepresentation::kTagged);
......
......@@ -1735,6 +1735,25 @@ void TaggedEqual::GenerateCode(MaglevCodeGenState* code_gen_state,
__ bind(&done);
}
void TestInstanceOf::AllocateVreg(MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kInstanceOf>::type;
UseFixed(context(), kContextRegister);
UseFixed(object(), D::GetRegisterParameter(D::kLeft));
UseFixed(callable(), D::GetRegisterParameter(D::kRight));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void TestInstanceOf::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
#ifdef DEBUG
using D = CallInterfaceDescriptorFor<Builtin::kInstanceOf>::type;
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(object()), D::GetRegisterParameter(D::kLeft));
DCHECK_EQ(ToRegister(callable()), D::GetRegisterParameter(D::kRight));
#endif
__ CallBuiltin(Builtin::kInstanceOf);
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void TestUndetectable::AllocateVreg(MaglevVregAllocationState* vreg_state) {
UseRegister(value());
set_temporaries_needed(1);
......
......@@ -146,6 +146,7 @@ class CompactInterpreterFrameState;
V(Float64Box) \
V(CheckedFloat64Unbox) \
V(TaggedEqual) \
V(TestInstanceOf) \
V(TestUndetectable) \
CONSTANT_VALUE_NODE_LIST(V) \
INT32_OPERATIONS_NODE_LIST(V) \
......@@ -1557,6 +1558,24 @@ class TaggedEqual : public FixedInputValueNodeT<2, TaggedEqual> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
};
class TestInstanceOf : public FixedInputValueNodeT<3, TestInstanceOf> {
using Base = FixedInputValueNodeT<3, TestInstanceOf>;
public:
explicit TestInstanceOf(uint64_t bitfield) : Base(bitfield) {}
// The implementation currently calls runtime.
static constexpr OpProperties kProperties = OpProperties::JSCall();
Input& context() { return input(0); }
Input& object() { return input(1); }
Input& callable() { return input(2); }
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
};
class TestUndetectable : public FixedInputValueNodeT<1, TestUndetectable> {
using Base = FixedInputValueNodeT<1, TestUndetectable>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment