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

Unified Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 2395623002: Improvement to SsaLoadElimination (Closed)
Patch Set: format Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 9aa2d98dd339645993dc3367293532c7c205f48a..6ff4e783c2628f33e7a24e2fe26721b75945ba10 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -2604,7 +2604,33 @@ class MemorySet {
MemorySet intersectionFor(
MemorySet other, HBasicBlock block, int predecessorIndex) {
MemorySet result = new MemorySet(compiler);
- if (other == null) return result;
+ if (other == null) {
+ // This is the first visit to a loop header ([other] is `null` because we
+ // have not visited the back edge). Copy the nonEscapingReceivers that are
+ // guaranteed to survive the loop because they are not escaped before
+ // method exit.
+ // TODO(sra): We should do a proper dataflow to find the maximal
+ // nonEscapingReceivers (a variant of Available-Expressions), which must
+ // converge before we edit the program in [findCommonInstruction].
+ for (HInstruction instruction in nonEscapingReceivers) {
+ bool isNonEscapingUse(HInstruction use) {
+ if (use is HReturn) return true; // Escapes, but so does control.
+ if (use is HFieldGet) return true;
+ if (use is HFieldSet &&
+ use.receiver.nonCheck() == instruction &&
+ use.value.nonCheck() != instruction) {
+ return true;
+ }
+ if (use is HTypeInfoReadVariable) return true;
+ return false;
+ }
+
+ if (instruction.usedBy.every(isNonEscapingUse)) {
+ result.nonEscapingReceivers.add(instruction);
+ }
+ }
+ return result;
+ }
fieldValues.forEach((element, values) {
var otherValues = other.fieldValues[element];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698