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) {
AccessMode::kStoreInLiteral);
}
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);
Reduction JSNativeContextSpecialization::ReduceElementAccessOnString(
Node* node, Node* index, Node* value, AccessMode access_mode,
KeyedAccessLoadMode load_mode) {
Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(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.
if (access_mode == AccessMode::kStore) return NoChange();
......@@ -1501,21 +1494,41 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
// if the {index} is out of bounds (depending on the {load_mode}).
value = BuildIndexedStringLoad(receiver, index, length, &effect, &control,
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.
AccessInfoFactory access_info_factory(
broker(), dependencies(), native_context().object(), graph()->zone());
ZoneVector<ElementAccessInfo> access_infos(zone());
if (!access_info_factory.ComputeElementAccessInfos(
receiver_maps, access_mode, &access_infos)) {
if (!access_info_factory.ComputeElementAccessInfos(receiver_maps, access_mode,
&access_infos)) {
return NoChange();
}
// Nothing to do if we have no non-deprecated maps.
if (access_infos.empty()) {
return ReduceSoftDeoptimize(
node,
DeoptimizeReason::kInsufficientTypeFeedbackForGenericKeyedAccess);
node, DeoptimizeReason::kInsufficientTypeFeedbackForGenericKeyedAccess);
}
// For holey stores or growing stores, we need to check that the prototype
......@@ -1539,8 +1552,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
Handle<Object> map_prototype(map->prototype(), isolate());
if (map_prototype->IsNull(isolate())) break;
if (!map_prototype->IsJSObject()) return NoChange();
map = handle(Handle<JSObject>::cast(map_prototype)->map(),
isolate());
map =
handle(Handle<JSObject>::cast(map_prototype)->map(), isolate());
if (!map->is_stable()) return NoChange();
if (!IsFastElementsKind(map->elements_kind())) return NoChange();
prototype_maps.push_back(map);
......@@ -1582,8 +1595,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
// elements kind transition above. This is because those operators
// don't have the kNoWrite flag on it, even though they are not
// observable by JavaScript.
effect = graph()->NewNode(common()->Checkpoint(), frame_state, effect,
control);
effect =
graph()->NewNode(common()->Checkpoint(), frame_state, effect, control);
// Perform map check on the {receiver}.
access_builder.BuildCheckMaps(receiver, &effect, control,
......@@ -1591,8 +1604,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
// Access the actual element.
ValueEffectControl continuation =
BuildElementAccess(receiver, index, value, effect, control,
access_info, access_mode, load_mode, store_mode);
BuildElementAccess(receiver, index, value, effect, control, access_info,
access_mode, load_mode, store_mode);
value = continuation.value();
effect = continuation.effect();
control = continuation.control();
......@@ -1614,14 +1627,12 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
Node* this_control = fallthrough_control;
// Perform possible elements kind transitions.
Handle<Map> const transition_target =
access_info.receiver_maps().front();
Handle<Map> const transition_target = access_info.receiver_maps().front();
for (auto transition_source : access_info.transition_sources()) {
DCHECK_EQ(access_info.receiver_maps().size(), 1);
this_effect = graph()->NewNode(
simplified()->TransitionElementsKind(
ElementsTransition(IsSimpleMapChangeTransition(
transition_source->elements_kind(),
simplified()->TransitionElementsKind(ElementsTransition(
IsSimpleMapChangeTransition(transition_source->elements_kind(),
transition_target->elements_kind())
? ElementsTransition::kFastTransition
: ElementsTransition::kSlowTransition,
......@@ -1676,8 +1687,8 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
effect = effects.front();
control = controls.front();
} else {
control = graph()->NewNode(common()->Merge(control_count),
control_count, &controls.front());
control = graph()->NewNode(common()->Merge(control_count), control_count,
&controls.front());
values.push_back(control);
value = graph()->NewNode(
common()->Phi(MachineRepresentation::kTagged, control_count),
......@@ -1687,7 +1698,6 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
control_count + 1, &effects.front());
}
}
}
ReplaceWithValue(node, value, effect, control);
return Replace(value);
......
......@@ -118,6 +118,9 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final
Reduction ReduceKeyedLoadFromHeapConstant(Node* node, Node* index,
FeedbackNexus const& nexus,
KeyedAccessLoadMode load_mode);
Reduction ReduceElementAccessOnString(Node* node, Node* index, Node* value,
AccessMode access_mode,
KeyedAccessLoadMode load_mode);
Reduction ReduceSoftDeoptimize(Node* node, DeoptimizeReason reason);
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