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

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

Issue 1573693002: dart2js cps: Hoist loop-invariant branches from loop entry. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove self-import Created 4 years, 11 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/cps_fragment.dart ('k') | pkg/compiler/lib/src/cps_ir/loop_hierarchy.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/cps_ir_nodes.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
index 659b5e2f288f75b6f4e2d8ef46b682d026efa13b..7ccf271bcb07e6738c6c02dbd8bd7175218cffb6 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
@@ -1196,21 +1196,26 @@ class Branch extends TailExpression {
/// boolean.
bool isStrictCheck;
- Branch.strict(Primitive condition,
- Continuation trueCont,
- Continuation falseCont)
+ Branch(Primitive condition,
+ Continuation trueCont,
+ Continuation falseCont,
+ {bool strict})
: this.condition = new Reference<Primitive>(condition),
trueContinuation = new Reference<Continuation>(trueCont),
falseContinuation = new Reference<Continuation>(falseCont),
- isStrictCheck = true;
+ isStrictCheck = strict {
+ assert(strict != null);
+ }
+
+ Branch.strict(Primitive condition,
+ Continuation trueCont,
+ Continuation falseCont)
+ : this(condition, trueCont, falseCont, strict: true);
Branch.loose(Primitive condition,
Continuation trueCont,
Continuation falseCont)
- : this.condition = new Reference<Primitive>(condition),
- trueContinuation = new Reference<Continuation>(trueCont),
- falseContinuation = new Reference<Continuation>(falseCont),
- this.isStrictCheck = false;
+ : this(condition, trueCont, falseCont, strict: false);
accept(BlockVisitor visitor) => visitor.visitBranch(this);
@@ -1909,6 +1914,33 @@ abstract class BlockVisitor<T> {
}
nodes.reversed.forEach(v.visit);
}
+
+ /// Visits block-level nodes in lexical pre-order.
+ ///
+ /// The IR may be transformed during the traversal, but the currently
+ /// visited node should not be removed, as its 'body' pointer is needed
+ /// for the traversal.
+ static void traverseInPreOrder(FunctionDefinition root, BlockVisitor v) {
+ List<Continuation> stack = <Continuation>[];
+ void walkBlock(InteriorNode block) {
+ v.visit(block);
+ Expression node = block.body;
+ v.visit(node);
+ while (node.next != null) {
+ if (node is LetCont) {
+ stack.addAll(node.continuations);
+ } else if (node is LetHandler) {
+ stack.add(node.handler);
+ }
+ node = node.next;
+ v.visit(node);
+ }
+ }
+ walkBlock(root);
+ while (stack.isNotEmpty) {
+ walkBlock(stack.removeLast());
+ }
+ }
}
abstract class Visitor<T> implements BlockVisitor<T> {
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_fragment.dart ('k') | pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698