Commit 9d98af91 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Move a special case out of ReduceElementAccess

...to make things easier to read.

R=jarin@chromium.org

Change-Id: I0e53ef67e34f696b5977d4e091c7bc7bdf0ec145
Reviewed-on: https://chromium-review.googlesource.com/c/1477739Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59706}
parent f23712f9
...@@ -1473,20 +1473,13 @@ Reduction JSNativeContextSpecialization::ReduceJSStoreNamedOwn(Node* node) { ...@@ -1473,20 +1473,13 @@ Reduction JSNativeContextSpecialization::ReduceJSStoreNamedOwn(Node* node) {
AccessMode::kStoreInLiteral); AccessMode::kStoreInLiteral);
} }
Reduction JSNativeContextSpecialization::ReduceElementAccess( Reduction JSNativeContextSpecialization::ReduceElementAccessOnString(
Node* node, Node* index, Node* value, MapHandles const& receiver_maps, Node* node, Node* index, Node* value, AccessMode access_mode,
AccessMode access_mode, KeyedAccessLoadMode load_mode, KeyedAccessLoadMode load_mode) {
KeyedAccessStoreMode store_mode) {
DCHECK(node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreInArrayLiteral);
Node* receiver = NodeProperties::GetValueInput(node, 0); Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
Node* frame_state = NodeProperties::FindFrameStateBefore(node);
// Check for keyed access to strings.
if (HasOnlyStringMaps(receiver_maps)) {
// Strings are immutable in JavaScript. // Strings are immutable in JavaScript.
if (access_mode == AccessMode::kStore) return NoChange(); if (access_mode == AccessMode::kStore) return NoChange();
...@@ -1501,21 +1494,41 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1501,21 +1494,41 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
// if the {index} is out of bounds (depending on the {load_mode}). // if the {index} is out of bounds (depending on the {load_mode}).
value = BuildIndexedStringLoad(receiver, index, length, &effect, &control, value = BuildIndexedStringLoad(receiver, index, length, &effect, &control,
load_mode); load_mode);
} else {
ReplaceWithValue(node, value, effect, control);
return Replace(value);
}
Reduction JSNativeContextSpecialization::ReduceElementAccess(
Node* node, Node* index, Node* value, MapHandles const& receiver_maps,
AccessMode access_mode, KeyedAccessLoadMode load_mode,
KeyedAccessStoreMode store_mode) {
DCHECK(node->opcode() == IrOpcode::kJSLoadProperty ||
node->opcode() == IrOpcode::kJSStoreProperty ||
node->opcode() == IrOpcode::kJSStoreInArrayLiteral);
Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
Node* frame_state = NodeProperties::FindFrameStateBefore(node);
if (HasOnlyStringMaps(receiver_maps)) {
return ReduceElementAccessOnString(node, index, value, access_mode,
load_mode);
}
// Compute element access infos for the receiver maps. // Compute element access infos for the receiver maps.
AccessInfoFactory access_info_factory( AccessInfoFactory access_info_factory(
broker(), dependencies(), native_context().object(), graph()->zone()); broker(), dependencies(), native_context().object(), graph()->zone());
ZoneVector<ElementAccessInfo> access_infos(zone()); ZoneVector<ElementAccessInfo> access_infos(zone());
if (!access_info_factory.ComputeElementAccessInfos( if (!access_info_factory.ComputeElementAccessInfos(receiver_maps, access_mode,
receiver_maps, access_mode, &access_infos)) { &access_infos)) {
return NoChange(); return NoChange();
} }
// Nothing to do if we have no non-deprecated maps. // Nothing to do if we have no non-deprecated maps.
if (access_infos.empty()) { if (access_infos.empty()) {
return ReduceSoftDeoptimize( return ReduceSoftDeoptimize(
node, node, DeoptimizeReason::kInsufficientTypeFeedbackForGenericKeyedAccess);
DeoptimizeReason::kInsufficientTypeFeedbackForGenericKeyedAccess);
} }
// For holey stores or growing stores, we need to check that the prototype // For holey stores or growing stores, we need to check that the prototype
...@@ -1539,8 +1552,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1539,8 +1552,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
Handle<Object> map_prototype(map->prototype(), isolate()); Handle<Object> map_prototype(map->prototype(), isolate());
if (map_prototype->IsNull(isolate())) break; if (map_prototype->IsNull(isolate())) break;
if (!map_prototype->IsJSObject()) return NoChange(); if (!map_prototype->IsJSObject()) return NoChange();
map = handle(Handle<JSObject>::cast(map_prototype)->map(), map =
isolate()); handle(Handle<JSObject>::cast(map_prototype)->map(), isolate());
if (!map->is_stable()) return NoChange(); if (!map->is_stable()) return NoChange();
if (!IsFastElementsKind(map->elements_kind())) return NoChange(); if (!IsFastElementsKind(map->elements_kind())) return NoChange();
prototype_maps.push_back(map); prototype_maps.push_back(map);
...@@ -1582,8 +1595,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1582,8 +1595,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
// elements kind transition above. This is because those operators // elements kind transition above. This is because those operators
// don't have the kNoWrite flag on it, even though they are not // don't have the kNoWrite flag on it, even though they are not
// observable by JavaScript. // observable by JavaScript.
effect = graph()->NewNode(common()->Checkpoint(), frame_state, effect, effect =
control); graph()->NewNode(common()->Checkpoint(), frame_state, effect, control);
// Perform map check on the {receiver}. // Perform map check on the {receiver}.
access_builder.BuildCheckMaps(receiver, &effect, control, access_builder.BuildCheckMaps(receiver, &effect, control,
...@@ -1591,8 +1604,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1591,8 +1604,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
// Access the actual element. // Access the actual element.
ValueEffectControl continuation = ValueEffectControl continuation =
BuildElementAccess(receiver, index, value, effect, control, BuildElementAccess(receiver, index, value, effect, control, access_info,
access_info, access_mode, load_mode, store_mode); access_mode, load_mode, store_mode);
value = continuation.value(); value = continuation.value();
effect = continuation.effect(); effect = continuation.effect();
control = continuation.control(); control = continuation.control();
...@@ -1614,14 +1627,12 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1614,14 +1627,12 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
Node* this_control = fallthrough_control; Node* this_control = fallthrough_control;
// Perform possible elements kind transitions. // Perform possible elements kind transitions.
Handle<Map> const transition_target = Handle<Map> const transition_target = access_info.receiver_maps().front();
access_info.receiver_maps().front();
for (auto transition_source : access_info.transition_sources()) { for (auto transition_source : access_info.transition_sources()) {
DCHECK_EQ(access_info.receiver_maps().size(), 1); DCHECK_EQ(access_info.receiver_maps().size(), 1);
this_effect = graph()->NewNode( this_effect = graph()->NewNode(
simplified()->TransitionElementsKind( simplified()->TransitionElementsKind(ElementsTransition(
ElementsTransition(IsSimpleMapChangeTransition( IsSimpleMapChangeTransition(transition_source->elements_kind(),
transition_source->elements_kind(),
transition_target->elements_kind()) transition_target->elements_kind())
? ElementsTransition::kFastTransition ? ElementsTransition::kFastTransition
: ElementsTransition::kSlowTransition, : ElementsTransition::kSlowTransition,
...@@ -1676,8 +1687,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1676,8 +1687,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
effect = effects.front(); effect = effects.front();
control = controls.front(); control = controls.front();
} else { } else {
control = graph()->NewNode(common()->Merge(control_count), control = graph()->NewNode(common()->Merge(control_count), control_count,
control_count, &controls.front()); &controls.front());
values.push_back(control); values.push_back(control);
value = graph()->NewNode( value = graph()->NewNode(
common()->Phi(MachineRepresentation::kTagged, control_count), common()->Phi(MachineRepresentation::kTagged, control_count),
...@@ -1687,7 +1698,6 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( ...@@ -1687,7 +1698,6 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
control_count + 1, &effects.front()); control_count + 1, &effects.front());
} }
} }
}
ReplaceWithValue(node, value, effect, control); ReplaceWithValue(node, value, effect, control);
return Replace(value); return Replace(value);
......
...@@ -118,6 +118,9 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final ...@@ -118,6 +118,9 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final
Reduction ReduceKeyedLoadFromHeapConstant(Node* node, Node* index, Reduction ReduceKeyedLoadFromHeapConstant(Node* node, Node* index,
FeedbackNexus const& nexus, FeedbackNexus const& nexus,
KeyedAccessLoadMode load_mode); KeyedAccessLoadMode load_mode);
Reduction ReduceElementAccessOnString(Node* node, Node* index, Node* value,
AccessMode access_mode,
KeyedAccessLoadMode load_mode);
Reduction ReduceSoftDeoptimize(Node* node, DeoptimizeReason reason); Reduction ReduceSoftDeoptimize(Node* node, DeoptimizeReason reason);
Reduction ReduceJSToString(Node* node); Reduction ReduceJSToString(Node* node);
......
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