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

Unified Diff: pkg/compiler/lib/src/cps_ir/loop_effects.dart

Issue 1444363002: dart2js cps: Global value numbering and loop-invariant code motion. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment Created 5 years, 1 month 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
Index: pkg/compiler/lib/src/cps_ir/loop_effects.dart
diff --git a/pkg/compiler/lib/src/cps_ir/loop_effects.dart b/pkg/compiler/lib/src/cps_ir/loop_effects.dart
index 9dd39ff78518b5cfe9fc6e2d725f2c49fe7695f2..8552786e241d21f8b61b3ae4d9da5799ab7b3234 100644
--- a/pkg/compiler/lib/src/cps_ir/loop_effects.dart
+++ b/pkg/compiler/lib/src/cps_ir/loop_effects.dart
@@ -46,9 +46,7 @@ class LoopSideEffects extends TrampolineRecursiveVisitor {
Expression traverseContinuation(Continuation cont) {
if (cont.isRecursive) {
SideEffects oldEffects = currentLoopSideEffects;
- Continuation oldLoopHeader = currentLoopHeader;
bool oldChangesLength = currentLoopChangesLength;
- currentLoopHeader = cont;
loopSideEffects[cont] = currentLoopSideEffects = new SideEffects.empty();
exitContinuations[cont] = <Continuation>[];
pushAction(() {
@@ -57,11 +55,15 @@ class LoopSideEffects extends TrampolineRecursiveVisitor {
loopsChangingLength.add(cont);
}
currentLoopChangesLength = currentLoopChangesLength || oldChangesLength;
- currentLoopHeader = oldLoopHeader;
currentLoopSideEffects = oldEffects;
exitContinuations[cont].forEach(push);
});
}
+ Continuation oldLoopHeader = currentLoopHeader;
+ currentLoopHeader = loopHierarchy.getLoopHeader(cont);
+ pushAction(() {
+ currentLoopHeader = oldLoopHeader;
+ });
return cont.body;
}
@@ -87,6 +89,12 @@ class LoopSideEffects extends TrampolineRecursiveVisitor {
Continuation inner = currentLoopHeader;
Continuation outer = loopHierarchy.getEnclosingLoop(currentLoopHeader);
while (outer != loop) {
+ if (inner == null) {
+ // The shrinking reductions pass must run before any pass that relies
+ // on computing loop side effects.
+ throw 'Unreachable continuations must be removed before computing '
+ 'loop side effects.';
asgerf 2015/11/16 15:42:39 This is similar to the problem of putting unreacha
sra1 2015/11/17 05:41:14 Use the proper internal error (possibly as separat
asgerf 2015/11/17 12:43:43 Done.
+ }
inner = outer;
outer = loopHierarchy.getEnclosingLoop(outer);
}
@@ -171,6 +179,7 @@ class LoopSideEffects extends TrampolineRecursiveVisitor {
}
void visitApplyBuiltinMethod(ApplyBuiltinMethod node) {
+ currentLoopSideEffects.setChangesIndex();
currentLoopChangesLength = true; // Push and pop.
}
}

Powered by Google App Engine
This is Rietveld 408576698