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

[maglev] Add SetKeyed and DefineKeyedOwn generic nodes

Bug: v8:7700
Change-Id: I49c13eb2f251b8d547826928da479fa1186a11fd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3757894
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81682}
parent 7cbdde4a
...@@ -1055,8 +1055,38 @@ void MaglevGraphBuilder::VisitDefineNamedOwnProperty() { ...@@ -1055,8 +1055,38 @@ void MaglevGraphBuilder::VisitDefineNamedOwnProperty() {
name, feedback_source)); name, feedback_source));
} }
MAGLEV_UNIMPLEMENTED_BYTECODE(SetKeyedProperty) void MaglevGraphBuilder::VisitSetKeyedProperty() {
MAGLEV_UNIMPLEMENTED_BYTECODE(DefineKeyedOwnProperty) // SetKeyedProperty <object> <key> <slot>
ValueNode* object = LoadRegisterTagged(0);
ValueNode* key = LoadRegisterTagged(1);
FeedbackSlot slot = GetSlotOperand(2);
compiler::FeedbackSource feedback_source{feedback(), slot};
// TODO(victorgomes): Add monomorphic fast path.
// Create a generic store in the fallthrough.
ValueNode* context = GetContext();
ValueNode* value = GetAccumulatorTagged();
SetAccumulator(AddNewNode<SetKeyedGeneric>({context, object, key, value},
feedback_source));
}
void MaglevGraphBuilder::VisitDefineKeyedOwnProperty() {
// DefineKeyedOwnProperty <object> <key> <slot>
ValueNode* object = LoadRegisterTagged(0);
ValueNode* key = LoadRegisterTagged(1);
FeedbackSlot slot = GetSlotOperand(2);
compiler::FeedbackSource feedback_source{feedback(), slot};
// TODO(victorgomes): Add monomorphic fast path.
// Create a generic store in the fallthrough.
ValueNode* context = GetContext();
ValueNode* value = GetAccumulatorTagged();
SetAccumulator(AddNewNode<DefineKeyedOwnGeneric>(
{context, object, key, value}, feedback_source));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(StaInArrayLiteral) MAGLEV_UNIMPLEMENTED_BYTECODE(StaInArrayLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(DefineKeyedOwnPropertyInLiteral) MAGLEV_UNIMPLEMENTED_BYTECODE(DefineKeyedOwnPropertyInLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CollectTypeProfile) MAGLEV_UNIMPLEMENTED_BYTECODE(CollectTypeProfile)
......
...@@ -151,6 +151,14 @@ class MaglevGraphVerifier { ...@@ -151,6 +151,14 @@ class MaglevGraphVerifier {
CheckValueInputIs(node, 1, ValueRepresentation::kTagged); CheckValueInputIs(node, 1, ValueRepresentation::kTagged);
CheckValueInputIs(node, 2, ValueRepresentation::kTagged); CheckValueInputIs(node, 2, ValueRepresentation::kTagged);
break; break;
case Opcode::kSetKeyedGeneric:
case Opcode::kDefineKeyedOwnGeneric:
DCHECK_EQ(node->input_count(), 4);
CheckValueInputIs(node, 0, ValueRepresentation::kTagged);
CheckValueInputIs(node, 1, ValueRepresentation::kTagged);
CheckValueInputIs(node, 2, ValueRepresentation::kTagged);
CheckValueInputIs(node, 3, ValueRepresentation::kTagged);
break;
case Opcode::kInt32AddWithOverflow: case Opcode::kInt32AddWithOverflow:
case Opcode::kInt32SubtractWithOverflow: case Opcode::kInt32SubtractWithOverflow:
case Opcode::kInt32MultiplyWithOverflow: case Opcode::kInt32MultiplyWithOverflow:
......
...@@ -981,6 +981,51 @@ void DefineNamedOwnGeneric::PrintParams( ...@@ -981,6 +981,51 @@ void DefineNamedOwnGeneric::PrintParams(
os << "(" << name_ << ")"; os << "(" << name_ << ")";
} }
void SetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kKeyedStoreIC>::type;
UseFixed(context(), kContextRegister);
UseFixed(object_input(), D::GetRegisterParameter(D::kReceiver));
UseFixed(key_input(), D::GetRegisterParameter(D::kName));
UseFixed(value_input(), D::GetRegisterParameter(D::kValue));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void SetKeyedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
using D = CallInterfaceDescriptorFor<Builtin::kKeyedStoreIC>::type;
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(object_input()), D::GetRegisterParameter(D::kReceiver));
DCHECK_EQ(ToRegister(key_input()), D::GetRegisterParameter(D::kName));
DCHECK_EQ(ToRegister(value_input()), D::GetRegisterParameter(D::kValue));
__ Move(D::GetRegisterParameter(D::kSlot),
Smi::FromInt(feedback().slot.ToInt()));
__ Move(D::GetRegisterParameter(D::kVector), feedback().vector);
__ CallBuiltin(Builtin::kKeyedStoreIC);
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void DefineKeyedOwnGeneric::AllocateVreg(
MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kKeyedStoreIC>::type;
UseFixed(context(), kContextRegister);
UseFixed(object_input(), D::GetRegisterParameter(D::kReceiver));
UseFixed(key_input(), D::GetRegisterParameter(D::kName));
UseFixed(value_input(), D::GetRegisterParameter(D::kValue));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void DefineKeyedOwnGeneric::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
using D = CallInterfaceDescriptorFor<Builtin::kDefineKeyedOwnIC>::type;
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(object_input()), D::GetRegisterParameter(D::kReceiver));
DCHECK_EQ(ToRegister(key_input()), D::GetRegisterParameter(D::kName));
DCHECK_EQ(ToRegister(value_input()), D::GetRegisterParameter(D::kValue));
__ Move(D::GetRegisterParameter(D::kSlot),
Smi::FromInt(feedback().slot.ToInt()));
__ Move(D::GetRegisterParameter(D::kVector), feedback().vector);
__ CallBuiltin(Builtin::kDefineKeyedOwnIC);
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
}
void GetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) { void GetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) {
using D = CallInterfaceDescriptorFor<Builtin::kKeyedLoadIC>::type; using D = CallInterfaceDescriptorFor<Builtin::kKeyedLoadIC>::type;
UseFixed(context(), kContextRegister); UseFixed(context(), kContextRegister);
......
...@@ -129,6 +129,8 @@ class CompactInterpreterFrameState; ...@@ -129,6 +129,8 @@ class CompactInterpreterFrameState;
V(SetNamedGeneric) \ V(SetNamedGeneric) \
V(DefineNamedOwnGeneric) \ V(DefineNamedOwnGeneric) \
V(GetKeyedGeneric) \ V(GetKeyedGeneric) \
V(SetKeyedGeneric) \
V(DefineKeyedOwnGeneric) \
V(Phi) \ V(Phi) \
V(RegisterInput) \ V(RegisterInput) \
V(CheckedSmiTag) \ V(CheckedSmiTag) \
...@@ -2080,6 +2082,67 @@ class GetKeyedGeneric : public FixedInputValueNodeT<3, GetKeyedGeneric> { ...@@ -2080,6 +2082,67 @@ class GetKeyedGeneric : public FixedInputValueNodeT<3, GetKeyedGeneric> {
const compiler::FeedbackSource feedback_; const compiler::FeedbackSource feedback_;
}; };
class SetKeyedGeneric : public FixedInputValueNodeT<4, SetKeyedGeneric> {
using Base = FixedInputValueNodeT<4, SetKeyedGeneric>;
public:
explicit SetKeyedGeneric(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 kKeyIndex = 2;
static constexpr int kValueIndex = 3;
Input& context() { return input(kContextIndex); }
Input& object_input() { return input(kObjectIndex); }
Input& key_input() { return input(kKeyIndex); }
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 DefineKeyedOwnGeneric
: public FixedInputValueNodeT<4, DefineKeyedOwnGeneric> {
using Base = FixedInputValueNodeT<4, DefineKeyedOwnGeneric>;
public:
explicit DefineKeyedOwnGeneric(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 kKeyIndex = 2;
static constexpr int kValueIndex = 3;
Input& context() { return input(kContextIndex); }
Input& object_input() { return input(kObjectIndex); }
Input& key_input() { return input(kKeyIndex); }
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 GapMove : public FixedInputNodeT<0, GapMove> { class GapMove : public FixedInputNodeT<0, GapMove> {
using Base = FixedInputNodeT<0, GapMove>; using Base = FixedInputNodeT<0, GapMove>;
......
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