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

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

Issue 1222913009: dart2js cps: Bugfix in redundant phi elimination. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/cps_ir/redundant_phi.dart
diff --git a/pkg/compiler/lib/src/cps_ir/redundant_phi.dart b/pkg/compiler/lib/src/cps_ir/redundant_phi.dart
index 1f40c037f6fa899f6025bc7891d45972d93e2053..e678a968efcf9fee1f8ba667aa715a210a08d24f 100644
--- a/pkg/compiler/lib/src/cps_ir/redundant_phi.dart
+++ b/pkg/compiler/lib/src/cps_ir/redundant_phi.dart
@@ -152,7 +152,7 @@ class RedundantPhiEliminator extends RecursiveVisitor implements Pass {
// invokes, and all such invokes must be within the scope of
// [uniqueDefinition]. Note that this is linear in the depth of
// the binding of [uniqueDefinition].
- assert(letCont != null);
+ letCont = _makeUniqueBinding(cont);
_moveIntoScopeOf(letCont, uniqueDefinition);
}
@@ -201,3 +201,19 @@ void _moveIntoScopeOf(LetCont letCont, Definition definition) {
binding.body = letCont;
letCont.parent = binding;
}
+
+/// Ensures [continuation] has its own LetCont binding by creating
+/// a new LetCont below its current binding, if necessary.
+///
+/// Returns the LetCont that now binds [continuation].
+LetCont _makeUniqueBinding(Continuation continuation) {
+ LetCont letCont = continuation.parent;
+ if (letCont.continuations.length == 1) return letCont;
+ letCont.continuations.remove(continuation);
+ LetCont newBinding = new LetCont(continuation, letCont.body);
+ newBinding.body.parent = newBinding;
+ newBinding.parent = letCont;
+ letCont.body = newBinding;
+ continuation.parent = newBinding;
+ return newBinding;
+}
« 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