Commit 3fbe85ba authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Support TestUndetectable

Bug: v8:7700
Change-Id: Ibf21ca005754d9dba2669175a24a74f96ff871a5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3760459
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81718}
parent 3687a512
......@@ -641,7 +641,10 @@ void MaglevGraphBuilder::VisitTestReferenceEqual() {
SetAccumulator(AddNewNode<TaggedEqual>({lhs, rhs}));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(TestUndetectable)
void MaglevGraphBuilder::VisitTestUndetectable() {
ValueNode* value = GetAccumulatorTagged();
SetAccumulator(AddNewNode<TestUndetectable>({value}));
}
void MaglevGraphBuilder::VisitTestNull() {
ValueNode* value = GetAccumulatorTagged();
......
......@@ -105,6 +105,7 @@ class MaglevGraphVerifier {
case Opcode::kCreateFunctionContext:
case Opcode::kCreateClosure:
case Opcode::kFastCreateClosure:
case Opcode::kTestUndetectable:
case Opcode::kReturn:
DCHECK_EQ(node->input_count(), 1);
CheckValueInputIs(node, 0, ValueRepresentation::kTagged);
......
......@@ -1725,6 +1725,30 @@ void TaggedEqual::GenerateCode(MaglevCodeGenState* code_gen_state,
__ bind(&done);
}
void TestUndetectable::AllocateVreg(MaglevVregAllocationState* vreg_state) {
UseRegister(value());
set_temporaries_needed(1);
DefineAsRegister(vreg_state, this);
}
void TestUndetectable::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
Register object = ToRegister(value());
Register return_value = ToRegister(result());
RegList temps = temporaries();
Register tmp = temps.PopFirst();
Label done;
__ LoadRoot(return_value, RootIndex::kFalseValue);
// If the object is an Smi, return false.
__ JumpIfSmi(object, &done);
// If it is a HeapObject, load the map and check for the undetectable bit.
__ LoadMap(tmp, object);
__ movl(tmp, FieldOperand(tmp, Map::kBitFieldOffset));
__ testl(tmp, Immediate(Map::Bits1::IsUndetectableBit::kMask));
__ j(zero, &done);
__ LoadRoot(return_value, RootIndex::kTrueValue);
__ bind(&done);
}
void ChangeInt32ToFloat64::AllocateVreg(MaglevVregAllocationState* vreg_state) {
UseRegister(input());
DefineAsRegister(vreg_state, this);
......
......@@ -145,6 +145,7 @@ class CompactInterpreterFrameState;
V(Float64Box) \
V(CheckedFloat64Unbox) \
V(TaggedEqual) \
V(TestUndetectable) \
CONSTANT_VALUE_NODE_LIST(V) \
INT32_OPERATIONS_NODE_LIST(V) \
FLOAT64_OPERATIONS_NODE_LIST(V) \
......@@ -1554,6 +1555,19 @@ class TaggedEqual : public FixedInputValueNodeT<2, TaggedEqual> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
};
class TestUndetectable : public FixedInputValueNodeT<1, TestUndetectable> {
using Base = FixedInputValueNodeT<1, TestUndetectable>;
public:
explicit TestUndetectable(uint64_t bitfield) : Base(bitfield) {}
Input& value() { return Node::input(0); }
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
};
class InitialValue : public FixedInputValueNodeT<0, InitialValue> {
using Base = FixedInputValueNodeT<0, InitialValue>;
......
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