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 {
}
KeyedAccessMode KeyedAccessMode::FromNexus(FeedbackNexus const& nexus) {
if (IsKeyedLoadICKind(nexus.kind())) {
FeedbackSlotKind kind = nexus.kind();
if (IsKeyedLoadICKind(kind)) {
return KeyedAccessMode(AccessMode::kLoad, nexus.GetKeyedAccessLoadMode());
}
if (IsKeyedHasICKind(nexus.kind())) {
if (IsKeyedHasICKind(kind)) {
return KeyedAccessMode(AccessMode::kHas, nexus.GetKeyedAccessLoadMode());
}
if (IsKeyedStoreICKind(nexus.kind())) {
if (IsKeyedStoreICKind(kind)) {
return KeyedAccessMode(AccessMode::kStore, nexus.GetKeyedAccessStoreMode());
}
if (IsStoreInArrayLiteralICKind(nexus.kind())) {
if (IsStoreInArrayLiteralICKind(kind) ||
IsStoreDataPropertyInLiteralKind(kind)) {
return KeyedAccessMode(AccessMode::kStoreInLiteral,
nexus.GetKeyedAccessStoreMode());
}
......
......@@ -1091,6 +1091,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess(
node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreNamedOwn ||
node->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
node->opcode() == IrOpcode::kJSHasProperty ||
node->opcode() == IrOpcode::kJSGetIterator);
Node* receiver = NodeProperties::GetValueInput(node, 0);
......@@ -1524,6 +1525,7 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
DCHECK(node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreInArrayLiteral ||
node->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
node->opcode() == IrOpcode::kJSHasProperty);
Node* receiver = NodeProperties::GetValueInput(node, 0);
......@@ -1828,6 +1830,7 @@ Reduction JSNativeContextSpecialization::ReducePropertyAccess(
DCHECK(node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreInArrayLiteral ||
node->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
node->opcode() == IrOpcode::kJSHasProperty ||
node->opcode() == IrOpcode::kJSLoadNamed ||
node->opcode() == IrOpcode::kJSStoreNamed ||
......@@ -2434,76 +2437,16 @@ JSNativeContextSpecialization::BuildPropertyStore(
Reduction JSNativeContextSpecialization::ReduceJSStoreDataPropertyInLiteral(
Node* node) {
DisallowHeapAccessIf no_heap_access(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSStoreDataPropertyInLiteral, node->opcode());
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();
FeedbackNexus nexus(p.feedback().vector(), p.feedback().slot());
if (nexus.IsUninitialized()) {
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);
return ReducePropertyAccess(node, key, base::nullopt, value,
FeedbackSource(p.feedback()),
AccessMode::kStoreInLiteral);
}
Reduction JSNativeContextSpecialization::ReduceJSStoreInArrayLiteral(
......
......@@ -203,6 +203,7 @@ namespace compiler {
V(Return) \
V(StaContextSlot) \
V(StaCurrentContextSlot) \
V(StaDataPropertyInLiteral) \
V(StaGlobal) \
V(StaInArrayLiteral) \
V(StaKeyedProperty) \
......@@ -2653,6 +2654,17 @@ void SerializerForBackgroundCompilation::VisitStaInArrayLiteral(
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, ...) \
void SerializerForBackgroundCompilation::Visit##name( \
BytecodeArrayIterator* iterator) { \
......
......@@ -1093,6 +1093,12 @@ Name FeedbackNexus::GetName() const {
return Name::cast(feedback->GetHeapObjectAssumeStrong());
}
}
if (IsStoreDataPropertyInLiteralKind(kind())) {
MaybeObject extra = GetFeedbackExtra();
if (IsPropertyNameFeedback(extra)) {
return Name::cast(extra->GetHeapObjectAssumeStrong());
}
}
return Name();
}
......@@ -1179,7 +1185,8 @@ KeyedAccessStoreMode KeyedAccessStoreModeForBuiltin(int builtin_index) {
} // namespace
KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const {
DCHECK(IsKeyedStoreICKind(kind()) || IsStoreInArrayLiteralICKind(kind()));
DCHECK(IsKeyedStoreICKind(kind()) || IsStoreInArrayLiteralICKind(kind()) ||
IsStoreDataPropertyInLiteralKind(kind()));
KeyedAccessStoreMode mode = STANDARD_STORE;
MapHandles maps;
MaybeObjectHandles handlers;
......@@ -1219,14 +1226,17 @@ KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const {
IcCheckType FeedbackNexus::GetKeyType() const {
DCHECK(IsKeyedStoreICKind(kind()) || IsKeyedLoadICKind(kind()) ||
IsStoreInArrayLiteralICKind(kind()) || IsKeyedHasICKind(kind()));
IsStoreInArrayLiteralICKind(kind()) || IsKeyedHasICKind(kind()) ||
IsStoreDataPropertyInLiteralKind(kind()));
MaybeObject feedback = GetFeedback();
if (feedback == MaybeObject::FromObject(
*FeedbackVector::MegamorphicSentinel(GetIsolate()))) {
return static_cast<IcCheckType>(
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 {
......
......@@ -914,8 +914,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
nexus.ConfigureMegamorphic(PROPERTY);
}
} else if (nexus.ic_state() == MONOMORPHIC) {
if (nexus.GetFirstMap() != object->map() ||
nexus.GetFeedbackExtra() != MaybeObject::FromObject(*name)) {
if (nexus.GetFirstMap() != object->map() || nexus.GetName() != *name) {
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