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

[maglev] Support StaGlobal

Bug: v8:7700
Change-Id: I27db2c8d0cbbf4324d9f2b214b909326fc61968d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3805065
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82148}
parent 68b3b65e
......@@ -782,7 +782,20 @@ void MaglevGraphBuilder::VisitLdaGlobal() {
SetAccumulator(AddNewNode<LoadGlobal>({context}, name, feedback_source));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaGlobalInsideTypeof)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaGlobal)
void MaglevGraphBuilder::VisitStaGlobal() {
// StaGlobal <name_index> <slot>
ValueNode* value = GetAccumulatorTagged();
compiler::NameRef name = GetRefOperand<Name>(0);
FeedbackSlot slot = GetSlotOperand(1);
compiler::FeedbackSource feedback_source{feedback(), slot};
// TODO(v8:7700): Add fast path.
ValueNode* context = GetContext();
SetAccumulator(
AddNewNode<StoreGlobal>({context, value}, name, feedback_source));
}
void MaglevGraphBuilder::VisitLdaLookupSlot() {
// LdaLookupSlot <name_index>
......
......@@ -166,6 +166,7 @@ class MaglevGraphVerifier {
case Opcode::kGenericLessThanOrEqual:
case Opcode::kGenericStrictEqual:
case Opcode::kTaggedEqual:
case Opcode::kStoreGlobal:
// TODO(victorgomes): Can we check that first input is an Object?
case Opcode::kStoreTaggedFieldNoWriteBarrier:
// TODO(victorgomes): Can we check that second input is a Smi?
......
......@@ -823,6 +823,30 @@ void LoadGlobal::PrintParams(std::ostream& os,
os << "(" << name() << ")";
}
void StoreGlobal::AllocateVreg(MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kStoreGlobalIC>::type;
UseFixed(context(), kContextRegister);
UseFixed(value(), D::GetRegisterParameter(D::kValue));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void StoreGlobal::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
using D = CallInterfaceDescriptorFor<Builtin::kStoreGlobalIC>::type;
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(value()), D::GetRegisterParameter(D::kValue));
__ Move(D::GetRegisterParameter(D::kName), name().object());
__ Move(D::GetRegisterParameter(D::kSlot),
TaggedIndex::FromIntptr(feedback().index()));
__ Move(D::GetRegisterParameter(D::kVector), feedback().vector);
__ CallBuiltin(Builtin::kStoreGlobalIC);
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void StoreGlobal::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
os << "(" << name() << ")";
}
void RegisterInput::AllocateVreg(MaglevVregAllocationState* vreg_state) {
DefineAsFixed(vreg_state, this, input());
}
......
......@@ -141,6 +141,7 @@ class CompactInterpreterFrameState;
V(SetNamedGeneric) \
V(DefineNamedOwnGeneric) \
V(StoreInArrayLiteralGeneric) \
V(StoreGlobal) \
V(GetKeyedGeneric) \
V(SetKeyedGeneric) \
V(DefineKeyedOwnGeneric) \
......@@ -2425,6 +2426,32 @@ class LoadGlobal : public FixedInputValueNodeT<1, LoadGlobal> {
const compiler::FeedbackSource feedback_;
};
class StoreGlobal : public FixedInputValueNodeT<2, StoreGlobal> {
using Base = FixedInputValueNodeT<2, StoreGlobal>;
public:
explicit StoreGlobal(uint64_t bitfield, const compiler::NameRef& name,
const compiler::FeedbackSource& feedback)
: Base(bitfield), name_(name), feedback_(feedback) {}
// The implementation currently calls runtime.
static constexpr OpProperties kProperties = OpProperties::JSCall();
const compiler::NameRef& name() const { return name_; }
compiler::FeedbackSource feedback() const { return feedback_; }
Input& context() { return input(0); }
Input& value() { return input(1); }
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
private:
const compiler::NameRef name_;
const compiler::FeedbackSource feedback_;
};
class LoadNamedGeneric : public FixedInputValueNodeT<2, LoadNamedGeneric> {
using Base = FixedInputValueNodeT<2, LoadNamedGeneric>;
......
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