Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: src/compiler/load-elimination.cc

Issue 2866233002: [turbofan] Don't mix element accesses with incompatible representations. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/load-elimination.h ('k') | test/mjsunit/regress/regress-crbug-719479.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/load-elimination.cc
diff --git a/src/compiler/load-elimination.cc b/src/compiler/load-elimination.cc
index d216b0dc4cd3b01cec5b0e712b2e7464597d058d..f6ee350457480538a4ffdf202f29c6ffe68215bd 100644
--- a/src/compiler/load-elimination.cc
+++ b/src/compiler/load-elimination.cc
@@ -195,13 +195,23 @@ void LoadElimination::AbstractChecks::Print() const {
}
}
-Node* LoadElimination::AbstractElements::Lookup(Node* object,
- Node* index) const {
+namespace {
+
+bool IsCompatible(MachineRepresentation r1, MachineRepresentation r2) {
+ if (r1 == r2) return true;
+ return IsAnyTagged(r1) && IsAnyTagged(r2);
+}
+
+} // namespace
+
+Node* LoadElimination::AbstractElements::Lookup(
+ Node* object, Node* index, MachineRepresentation representation) const {
for (Element const element : elements_) {
if (element.object == nullptr) continue;
DCHECK_NOT_NULL(element.index);
DCHECK_NOT_NULL(element.value);
- if (MustAlias(object, element.object) && MustAlias(index, element.index)) {
+ if (MustAlias(object, element.object) && MustAlias(index, element.index) &&
+ IsCompatible(representation, element.representation)) {
return element.value;
}
}
@@ -470,22 +480,26 @@ LoadElimination::AbstractState const* LoadElimination::AbstractState::KillMaps(
return this;
}
-Node* LoadElimination::AbstractState::LookupElement(Node* object,
- Node* index) const {
+Node* LoadElimination::AbstractState::LookupElement(
+ Node* object, Node* index, MachineRepresentation representation) const {
if (this->elements_) {
- return this->elements_->Lookup(object, index);
+ return this->elements_->Lookup(object, index, representation);
}
return nullptr;
}
LoadElimination::AbstractState const*
LoadElimination::AbstractState::AddElement(Node* object, Node* index,
- Node* value, Zone* zone) const {
+ Node* value,
+ MachineRepresentation representation,
+ Zone* zone) const {
AbstractState* that = new (zone) AbstractState(*this);
if (that->elements_) {
- that->elements_ = that->elements_->Extend(object, index, value, zone);
+ that->elements_ =
+ that->elements_->Extend(object, index, value, representation, zone);
} else {
- that->elements_ = new (zone) AbstractElements(object, index, value, zone);
+ that->elements_ =
+ new (zone) AbstractElements(object, index, value, representation, zone);
}
return that;
}
@@ -823,7 +837,8 @@ Reduction LoadElimination::ReduceLoadElement(Node* node) {
case MachineRepresentation::kTaggedSigned:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTagged:
- if (Node* replacement = state->LookupElement(object, index)) {
+ if (Node* replacement = state->LookupElement(
+ object, index, access.machine_type.representation())) {
// Make sure we don't resurrect dead {replacement} nodes.
if (!replacement->IsDead()) {
// We might need to guard the {replacement} if the type of the
@@ -838,7 +853,8 @@ Reduction LoadElimination::ReduceLoadElement(Node* node) {
return Replace(replacement);
}
}
- state = state->AddElement(object, index, node, zone());
+ state = state->AddElement(object, index, node,
+ access.machine_type.representation(), zone());
return UpdateState(node, state);
}
return NoChange();
@@ -852,7 +868,8 @@ Reduction LoadElimination::ReduceStoreElement(Node* node) {
Node* const effect = NodeProperties::GetEffectInput(node);
AbstractState const* state = node_states_.Get(effect);
if (state == nullptr) return NoChange();
- Node* const old_value = state->LookupElement(object, index);
+ Node* const old_value =
+ state->LookupElement(object, index, access.machine_type.representation());
if (old_value == new_value) {
// This store is fully redundant.
return Replace(effect);
@@ -880,7 +897,8 @@ Reduction LoadElimination::ReduceStoreElement(Node* node) {
case MachineRepresentation::kTaggedSigned:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTagged:
- state = state->AddElement(object, index, new_value, zone());
+ state = state->AddElement(object, index, new_value,
+ access.machine_type.representation(), zone());
break;
}
return UpdateState(node, state);
« no previous file with comments | « src/compiler/load-elimination.h ('k') | test/mjsunit/regress/regress-crbug-719479.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698