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

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

Issue 1380513002: Revert "dart2js cps: Add helpers for common IR manipulation." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | « pkg/compiler/lib/src/cps_ir/mutable_ssa.dart ('k') | pkg/compiler/lib/src/cps_ir/redundant_phi.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/redundant_join.dart
diff --git a/pkg/compiler/lib/src/cps_ir/redundant_join.dart b/pkg/compiler/lib/src/cps_ir/redundant_join.dart
index d07d5190ab480754da3971396e74e6d0b89a72d5..747e701a26112abc500069caa1f4cd3e3ea04f28 100644
--- a/pkg/compiler/lib/src/cps_ir/redundant_join.dart
+++ b/pkg/compiler/lib/src/cps_ir/redundant_join.dart
@@ -64,6 +64,20 @@ class RedundantJoinEliminator extends RecursiveVisitor implements Pass {
}
}
+ /// Removes [movedNode] from its current position and inserts it
+ /// before [target].
+ void moveToBefore(Expression target, LetCont movedNode) {
+ if (movedNode.parent != null) {
+ movedNode.parent.body = movedNode.body;
+ movedNode.body.parent = movedNode.parent;
+ }
+ InteriorNode parent = target.parent;
+ parent.body = movedNode;
+ movedNode.body = target;
+ target.parent = movedNode;
+ movedNode.parent = parent;
+ }
+
void rewriteBranch(Branch branch) {
InteriorNode parent = getEffectiveParent(branch);
if (parent is! Continuation) return;
@@ -147,8 +161,7 @@ class RedundantJoinEliminator extends RecursiveVisitor implements Pass {
}
}
}
- innerLetCont.remove();
- innerLetCont.insertAbove(outerLetCont);
+ moveToBefore(outerLetCont, innerLetCont);
}
assert(branchCont.body == branch);
@@ -183,7 +196,9 @@ class RedundantJoinEliminator extends RecursiveVisitor implements Pass {
branch.falseContinuation.unlink();
outerLetCont.continuations.remove(branchCont);
if (outerLetCont.continuations.isEmpty) {
- outerLetCont.remove();
+ InteriorNode parent = outerLetCont.parent;
+ parent.body = outerLetCont.body;
+ outerLetCont.body.parent = parent;
}
// We may have created new redundant join points in the two branches.
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/mutable_ssa.dart ('k') | pkg/compiler/lib/src/cps_ir/redundant_phi.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698