Commit c505520a authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Support generic StaInArrayLiteral

Just the generic path for now, the most valuable optimisation here would
be transitioning stores but we don't yet support these.

Bug: v8:7700
Change-Id: I95e3a77cccf43bc33607a50bab1eb89fca32af06
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3758144
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81684}
parent c906eec7
......@@ -1088,7 +1088,34 @@ void MaglevGraphBuilder::VisitDefineKeyedOwnProperty() {
{context, object, key, value}, feedback_source));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(StaInArrayLiteral)
void MaglevGraphBuilder::VisitStaInArrayLiteral() {
// StaInArrayLiteral <object> <name_reg> <slot>
ValueNode* object = LoadRegisterTagged(0);
ValueNode* name = LoadRegisterTagged(1);
FeedbackSlot slot = GetSlotOperand(2);
compiler::FeedbackSource feedback_source{feedback(), slot};
const compiler::ProcessedFeedback& processed_feedback =
broker()->GetFeedbackForPropertyAccess(
feedback_source, compiler::AccessMode::kStoreInLiteral,
base::nullopt);
switch (processed_feedback.kind()) {
case compiler::ProcessedFeedback::kInsufficient:
EmitUnconditionalDeopt();
return;
default:
break;
}
// Create a generic store in the fallthrough.
ValueNode* context = GetContext();
ValueNode* value = GetAccumulatorTagged();
SetAccumulator(AddNewNode<StoreInArrayLiteralGeneric>(
{context, object, name, value}, feedback_source));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(DefineKeyedOwnPropertyInLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CollectTypeProfile)
......
......@@ -155,6 +155,7 @@ class MaglevGraphVerifier {
break;
case Opcode::kSetKeyedGeneric:
case Opcode::kDefineKeyedOwnGeneric:
case Opcode::kStoreInArrayLiteralGeneric:
DCHECK_EQ(node->input_count(), 4);
CheckValueInputIs(node, 0, ValueRepresentation::kTagged);
CheckValueInputIs(node, 1, ValueRepresentation::kTagged);
......
......@@ -1071,6 +1071,29 @@ void DefineKeyedOwnGeneric::GenerateCode(MaglevCodeGenState* code_gen_state,
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void StoreInArrayLiteralGeneric::AllocateVreg(
MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kStoreInArrayLiteralIC>::type;
UseFixed(context(), kContextRegister);
UseFixed(object_input(), D::GetRegisterParameter(D::kReceiver));
UseFixed(name_input(), D::GetRegisterParameter(D::kName));
UseFixed(value_input(), D::GetRegisterParameter(D::kValue));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void StoreInArrayLiteralGeneric::GenerateCode(
MaglevCodeGenState* code_gen_state, const ProcessingState& state) {
using D = CallInterfaceDescriptorFor<Builtin::kStoreInArrayLiteralIC>::type;
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(object_input()), D::GetRegisterParameter(D::kReceiver));
DCHECK_EQ(ToRegister(value_input()), D::GetRegisterParameter(D::kValue));
DCHECK_EQ(ToRegister(name_input()), D::GetRegisterParameter(D::kName));
__ Move(D::GetRegisterParameter(D::kSlot),
Smi::FromInt(feedback().slot.ToInt()));
__ Move(D::GetRegisterParameter(D::kVector), feedback().vector);
__ CallBuiltin(Builtin::kStoreInArrayLiteralIC);
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void GetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kKeyedLoadIC>::type;
UseFixed(context(), kContextRegister);
......
......@@ -130,6 +130,7 @@ class CompactInterpreterFrameState;
V(LoadNamedGeneric) \
V(SetNamedGeneric) \
V(DefineNamedOwnGeneric) \
V(StoreInArrayLiteralGeneric) \
V(GetKeyedGeneric) \
V(SetKeyedGeneric) \
V(DefineKeyedOwnGeneric) \
......@@ -2120,6 +2121,37 @@ class DefineNamedOwnGeneric
const compiler::FeedbackSource feedback_;
};
class StoreInArrayLiteralGeneric
: public FixedInputValueNodeT<4, StoreInArrayLiteralGeneric> {
using Base = FixedInputValueNodeT<4, StoreInArrayLiteralGeneric>;
public:
explicit StoreInArrayLiteralGeneric(uint64_t bitfield,
const compiler::FeedbackSource& feedback)
: Base(bitfield), feedback_(feedback) {}
// The implementation currently calls runtime.
static constexpr OpProperties kProperties = OpProperties::JSCall();
compiler::FeedbackSource feedback() const { return feedback_; }
static constexpr int kContextIndex = 0;
static constexpr int kObjectIndex = 1;
static constexpr int kNameIndex = 2;
static constexpr int kValueIndex = 3;
Input& context() { return input(kContextIndex); }
Input& object_input() { return input(kObjectIndex); }
Input& name_input() { return input(kNameIndex); }
Input& value_input() { return input(kValueIndex); }
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
private:
const compiler::FeedbackSource feedback_;
};
class GetKeyedGeneric : public FixedInputValueNodeT<3, GetKeyedGeneric> {
using Base = FixedInputValueNodeT<3, GetKeyedGeneric>;
......
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