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

[maglev] Support generic GetIterator

Bug: v8:7700
Change-Id: I9f22a94ca5edfc733045dbf8b00738807b876f45
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3823132
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82384}
parent 8b4272c2
......@@ -2730,7 +2730,16 @@ void MaglevGraphBuilder::VisitThrowIfNotSuperConstructor() {
MAGLEV_UNIMPLEMENTED_BYTECODE(SwitchOnGeneratorState)
MAGLEV_UNIMPLEMENTED_BYTECODE(SuspendGenerator)
MAGLEV_UNIMPLEMENTED_BYTECODE(ResumeGenerator)
MAGLEV_UNIMPLEMENTED_BYTECODE(GetIterator)
void MaglevGraphBuilder::VisitGetIterator() {
// GetIterator <object>
ValueNode* receiver = LoadRegisterTagged(0);
ValueNode* context = GetContext();
int load_slot = iterator_.GetIndexOperand(1);
int call_slot = iterator_.GetIndexOperand(2);
SetAccumulator(AddNewNode<GetIterator>({context, receiver}, load_slot,
call_slot, feedback()));
}
void MaglevGraphBuilder::VisitDebugger() {
BuildCallRuntime(Runtime::kHandleDebuggerStatement, {});
......
......@@ -173,6 +173,7 @@ class MaglevGraphVerifier {
case Opcode::kGenericLessThan:
case Opcode::kGenericLessThanOrEqual:
case Opcode::kGenericStrictEqual:
case Opcode::kGetIterator:
case Opcode::kTaggedEqual:
case Opcode::kTaggedNotEqual:
case Opcode::kStoreGlobal:
......
......@@ -835,6 +835,25 @@ void ForInNext::GenerateCode(MaglevCodeGenState* code_gen_state,
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void GetIterator::AllocateVreg(MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kGetIteratorWithFeedback>::type;
UseFixed(context(), kContextRegister);
UseFixed(receiver(), D::GetRegisterParameter(D::kReceiver));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void GetIterator::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
using D = CallInterfaceDescriptorFor<Builtin::kGetIteratorWithFeedback>::type;
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(receiver()), D::GetRegisterParameter(D::kReceiver));
__ Move(D::GetRegisterParameter(D::kLoadSlot),
TaggedIndex::FromIntptr(load_slot()));
__ Move(D::GetRegisterParameter(D::kCallSlot),
TaggedIndex::FromIntptr(call_slot()));
__ Move(D::GetRegisterParameter(D::kMaybeFeedbackVector), feedback());
__ CallBuiltin(Builtin::kGetIteratorWithFeedback);
}
void GetSecondReturnedValue::AllocateVreg(
MaglevVregAllocationState* vreg_state) {
DefineAsFixed(vreg_state, this, kReturnRegister1);
......
......@@ -136,6 +136,7 @@ class CompactInterpreterFrameState;
V(DeleteProperty) \
V(ForInPrepare) \
V(ForInNext) \
V(GetIterator) \
V(GetSecondReturnedValue) \
V(GetTemplateObject) \
V(InitialValue) \
......@@ -1836,6 +1837,36 @@ class ForInNext : public FixedInputValueNodeT<5, ForInNext> {
const compiler::FeedbackSource feedback_;
};
class GetIterator : public FixedInputValueNodeT<2, GetIterator> {
using Base = FixedInputValueNodeT<2, GetIterator>;
public:
explicit GetIterator(uint64_t bitfield, int load_slot, int call_slot,
const compiler::FeedbackVectorRef& feedback)
: Base(bitfield),
load_slot_(load_slot),
call_slot_(call_slot),
feedback_(feedback.object()) {}
static constexpr OpProperties kProperties = OpProperties::JSCall();
Input& context() { return input(0); }
Input& receiver() { return input(1); }
int load_slot() const { return load_slot_; }
int call_slot() const { return call_slot_; }
Handle<FeedbackVector> feedback() const { return feedback_; }
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
private:
const int load_slot_;
const int call_slot_;
const Handle<FeedbackVector> feedback_;
};
class GetSecondReturnedValue
: public FixedInputValueNodeT<0, GetSecondReturnedValue> {
using Base = FixedInputValueNodeT<0, GetSecondReturnedValue>;
......
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