Commit 8e065dbe authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Brokerize ReduceJSStoreDataPropertyInLiteral

Rewrite the reducer in terms of the ordinary keyed-store reducer and
reuse the existing serializer machinery for that as well.

Bug: v8:7790
Change-Id: I5909739feee1d77dca1827166bad3d2a61561784
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1760807Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63254}
parent 9a9ba762
...@@ -4007,16 +4007,18 @@ base::Optional<ObjectRef> GlobalAccessFeedback::GetConstantHint() const { ...@@ -4007,16 +4007,18 @@ base::Optional<ObjectRef> GlobalAccessFeedback::GetConstantHint() const {
} }
KeyedAccessMode KeyedAccessMode::FromNexus(FeedbackNexus const& nexus) { KeyedAccessMode KeyedAccessMode::FromNexus(FeedbackNexus const& nexus) {
if (IsKeyedLoadICKind(nexus.kind())) { FeedbackSlotKind kind = nexus.kind();
if (IsKeyedLoadICKind(kind)) {
return KeyedAccessMode(AccessMode::kLoad, nexus.GetKeyedAccessLoadMode()); return KeyedAccessMode(AccessMode::kLoad, nexus.GetKeyedAccessLoadMode());
} }
if (IsKeyedHasICKind(nexus.kind())) { if (IsKeyedHasICKind(kind)) {
return KeyedAccessMode(AccessMode::kHas, nexus.GetKeyedAccessLoadMode()); return KeyedAccessMode(AccessMode::kHas, nexus.GetKeyedAccessLoadMode());
} }
if (IsKeyedStoreICKind(nexus.kind())) { if (IsKeyedStoreICKind(kind)) {
return KeyedAccessMode(AccessMode::kStore, nexus.GetKeyedAccessStoreMode()); return KeyedAccessMode(AccessMode::kStore, nexus.GetKeyedAccessStoreMode());
} }
if (IsStoreInArrayLiteralICKind(nexus.kind())) { if (IsStoreInArrayLiteralICKind(kind) ||
IsStoreDataPropertyInLiteralKind(kind)) {
return KeyedAccessMode(AccessMode::kStoreInLiteral, return KeyedAccessMode(AccessMode::kStoreInLiteral,
nexus.GetKeyedAccessStoreMode()); nexus.GetKeyedAccessStoreMode());
} }
......
...@@ -1091,6 +1091,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( ...@@ -1091,6 +1091,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess(
node->opcode() == IrOpcode::kJSLoadProperty || node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty || node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreNamedOwn || node->opcode() == IrOpcode::kJSStoreNamedOwn ||
node->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
node->opcode() == IrOpcode::kJSHasProperty || node->opcode() == IrOpcode::kJSHasProperty ||
node->opcode() == IrOpcode::kJSGetIterator); node->opcode() == IrOpcode::kJSGetIterator);
Node* receiver = NodeProperties::GetValueInput(node, 0); Node* receiver = NodeProperties::GetValueInput(node, 0);
...@@ -1524,6 +1525,7 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1524,6 +1525,7 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
DCHECK(node->opcode() == IrOpcode::kJSLoadProperty || DCHECK(node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty || node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreInArrayLiteral || node->opcode() == IrOpcode::kJSStoreInArrayLiteral ||
node->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
node->opcode() == IrOpcode::kJSHasProperty); node->opcode() == IrOpcode::kJSHasProperty);
Node* receiver = NodeProperties::GetValueInput(node, 0); Node* receiver = NodeProperties::GetValueInput(node, 0);
...@@ -1828,6 +1830,7 @@ Reduction JSNativeContextSpecialization::ReducePropertyAccess( ...@@ -1828,6 +1830,7 @@ Reduction JSNativeContextSpecialization::ReducePropertyAccess(
DCHECK(node->opcode() == IrOpcode::kJSLoadProperty || DCHECK(node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty || node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreInArrayLiteral || node->opcode() == IrOpcode::kJSStoreInArrayLiteral ||
node->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
node->opcode() == IrOpcode::kJSHasProperty || node->opcode() == IrOpcode::kJSHasProperty ||
node->opcode() == IrOpcode::kJSLoadNamed || node->opcode() == IrOpcode::kJSLoadNamed ||
node->opcode() == IrOpcode::kJSStoreNamed || node->opcode() == IrOpcode::kJSStoreNamed ||
...@@ -2434,76 +2437,16 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -2434,76 +2437,16 @@ JSNativeContextSpecialization::BuildPropertyStore(
Reduction JSNativeContextSpecialization::ReduceJSStoreDataPropertyInLiteral( Reduction JSNativeContextSpecialization::ReduceJSStoreDataPropertyInLiteral(
Node* node) { Node* node) {
DisallowHeapAccessIf no_heap_access(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSStoreDataPropertyInLiteral, node->opcode()); DCHECK_EQ(IrOpcode::kJSStoreDataPropertyInLiteral, node->opcode());
FeedbackParameter const& p = FeedbackParameterOf(node->op()); FeedbackParameter const& p = FeedbackParameterOf(node->op());
Node* const key = NodeProperties::GetValueInput(node, 1);
Node* const value = NodeProperties::GetValueInput(node, 2);
if (!p.feedback().IsValid()) return NoChange(); if (!p.feedback().IsValid()) return NoChange();
return ReducePropertyAccess(node, key, base::nullopt, value,
FeedbackNexus nexus(p.feedback().vector(), p.feedback().slot()); FeedbackSource(p.feedback()),
if (nexus.IsUninitialized()) { AccessMode::kStoreInLiteral);
return NoChange();
}
if (nexus.ic_state() == MEGAMORPHIC) {
return NoChange();
}
DCHECK_EQ(MONOMORPHIC, nexus.ic_state());
Map map = nexus.GetFirstMap();
if (map.is_null()) {
// Maps are weakly held in the type feedback vector, we may not have one.
return NoChange();
}
Handle<Map> receiver_map(map, isolate());
if (!Map::TryUpdate(isolate(), receiver_map).ToHandle(&receiver_map))
return NoChange();
NameRef cached_name(
broker(),
handle(Name::cast(nexus.GetFeedbackExtra()->GetHeapObjectAssumeStrong()),
isolate()));
AccessInfoFactory access_info_factory(broker(), dependencies(),
graph()->zone());
PropertyAccessInfo access_info =
access_info_factory.ComputePropertyAccessInfo(
receiver_map, cached_name.object(), AccessMode::kStoreInLiteral);
if (access_info.IsInvalid()) return NoChange();
access_info.RecordDependencies(dependencies());
Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
// Monomorphic property access.
PropertyAccessBuilder access_builder(jsgraph(), broker(), dependencies());
access_builder.BuildCheckMaps(receiver, &effect, control,
access_info.receiver_maps());
// Ensure that {name} matches the cached name.
Node* name = NodeProperties::GetValueInput(node, 1);
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), name,
jsgraph()->Constant(cached_name));
effect = graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kWrongName),
check, effect, control);
Node* value = NodeProperties::GetValueInput(node, 2);
Node* context = NodeProperties::GetContextInput(node);
Node* frame_state_lazy = NodeProperties::GetFrameStateInput(node);
// Generate the actual property access.
ValueEffectControl continuation = BuildPropertyAccess(
receiver, value, context, frame_state_lazy, effect, control, cached_name,
nullptr, access_info, AccessMode::kStoreInLiteral);
value = continuation.value();
effect = continuation.effect();
control = continuation.control();
ReplaceWithValue(node, value, effect, control);
return Replace(value);
} }
Reduction JSNativeContextSpecialization::ReduceJSStoreInArrayLiteral( Reduction JSNativeContextSpecialization::ReduceJSStoreInArrayLiteral(
......
...@@ -203,6 +203,7 @@ namespace compiler { ...@@ -203,6 +203,7 @@ namespace compiler {
V(Return) \ V(Return) \
V(StaContextSlot) \ V(StaContextSlot) \
V(StaCurrentContextSlot) \ V(StaCurrentContextSlot) \
V(StaDataPropertyInLiteral) \
V(StaGlobal) \ V(StaGlobal) \
V(StaInArrayLiteral) \ V(StaInArrayLiteral) \
V(StaKeyedProperty) \ V(StaKeyedProperty) \
...@@ -2653,6 +2654,17 @@ void SerializerForBackgroundCompilation::VisitStaInArrayLiteral( ...@@ -2653,6 +2654,17 @@ void SerializerForBackgroundCompilation::VisitStaInArrayLiteral(
true); true);
} }
void SerializerForBackgroundCompilation::VisitStaDataPropertyInLiteral(
BytecodeArrayIterator* iterator) {
Hints const& receiver =
environment()->register_hints(iterator->GetRegisterOperand(0));
Hints const& key =
environment()->register_hints(iterator->GetRegisterOperand(1));
FeedbackSlot slot = iterator->GetSlotOperand(3);
ProcessKeyedPropertyAccess(receiver, key, slot, AccessMode::kStoreInLiteral,
false);
}
#define DEFINE_CLEAR_ENVIRONMENT(name, ...) \ #define DEFINE_CLEAR_ENVIRONMENT(name, ...) \
void SerializerForBackgroundCompilation::Visit##name( \ void SerializerForBackgroundCompilation::Visit##name( \
BytecodeArrayIterator* iterator) { \ BytecodeArrayIterator* iterator) { \
......
...@@ -1093,6 +1093,12 @@ Name FeedbackNexus::GetName() const { ...@@ -1093,6 +1093,12 @@ Name FeedbackNexus::GetName() const {
return Name::cast(feedback->GetHeapObjectAssumeStrong()); return Name::cast(feedback->GetHeapObjectAssumeStrong());
} }
} }
if (IsStoreDataPropertyInLiteralKind(kind())) {
MaybeObject extra = GetFeedbackExtra();
if (IsPropertyNameFeedback(extra)) {
return Name::cast(extra->GetHeapObjectAssumeStrong());
}
}
return Name(); return Name();
} }
...@@ -1179,7 +1185,8 @@ KeyedAccessStoreMode KeyedAccessStoreModeForBuiltin(int builtin_index) { ...@@ -1179,7 +1185,8 @@ KeyedAccessStoreMode KeyedAccessStoreModeForBuiltin(int builtin_index) {
} // namespace } // namespace
KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const { KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const {
DCHECK(IsKeyedStoreICKind(kind()) || IsStoreInArrayLiteralICKind(kind())); DCHECK(IsKeyedStoreICKind(kind()) || IsStoreInArrayLiteralICKind(kind()) ||
IsStoreDataPropertyInLiteralKind(kind()));
KeyedAccessStoreMode mode = STANDARD_STORE; KeyedAccessStoreMode mode = STANDARD_STORE;
MapHandles maps; MapHandles maps;
MaybeObjectHandles handlers; MaybeObjectHandles handlers;
...@@ -1219,14 +1226,17 @@ KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const { ...@@ -1219,14 +1226,17 @@ KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const {
IcCheckType FeedbackNexus::GetKeyType() const { IcCheckType FeedbackNexus::GetKeyType() const {
DCHECK(IsKeyedStoreICKind(kind()) || IsKeyedLoadICKind(kind()) || DCHECK(IsKeyedStoreICKind(kind()) || IsKeyedLoadICKind(kind()) ||
IsStoreInArrayLiteralICKind(kind()) || IsKeyedHasICKind(kind())); IsStoreInArrayLiteralICKind(kind()) || IsKeyedHasICKind(kind()) ||
IsStoreDataPropertyInLiteralKind(kind()));
MaybeObject feedback = GetFeedback(); MaybeObject feedback = GetFeedback();
if (feedback == MaybeObject::FromObject( if (feedback == MaybeObject::FromObject(
*FeedbackVector::MegamorphicSentinel(GetIsolate()))) { *FeedbackVector::MegamorphicSentinel(GetIsolate()))) {
return static_cast<IcCheckType>( return static_cast<IcCheckType>(
Smi::ToInt(GetFeedbackExtra()->cast<Object>())); Smi::ToInt(GetFeedbackExtra()->cast<Object>()));
} }
return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT; MaybeObject maybe_name =
IsStoreDataPropertyInLiteralKind(kind()) ? GetFeedbackExtra() : feedback;
return IsPropertyNameFeedback(maybe_name) ? PROPERTY : ELEMENT;
} }
BinaryOperationHint FeedbackNexus::GetBinaryOperationFeedback() const { BinaryOperationHint FeedbackNexus::GetBinaryOperationFeedback() const {
......
...@@ -914,8 +914,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { ...@@ -914,8 +914,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
nexus.ConfigureMegamorphic(PROPERTY); nexus.ConfigureMegamorphic(PROPERTY);
} }
} else if (nexus.ic_state() == MONOMORPHIC) { } else if (nexus.ic_state() == MONOMORPHIC) {
if (nexus.GetFirstMap() != object->map() || if (nexus.GetFirstMap() != object->map() || nexus.GetName() != *name) {
nexus.GetFeedbackExtra() != MaybeObject::FromObject(*name)) {
nexus.ConfigureMegamorphic(PROPERTY); nexus.ConfigureMegamorphic(PROPERTY);
} }
} }
......
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