| Index: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart
|
| ===================================================================
|
| --- sdk/lib/_internal/compiler/implementation/ssa/nodes.dart (revision 17870)
|
| +++ sdk/lib/_internal/compiler/implementation/ssa/nodes.dart (working copy)
|
| @@ -1857,6 +1857,23 @@
|
| bool isDoWhile() {
|
| return identical(kind, DO_WHILE_LOOP);
|
| }
|
| +
|
| + HBasicBlock computeLoopHeader() {
|
| + HBasicBlock result;
|
| + if (isDoWhile()) {
|
| + // In case of a do/while, the successor is a block that avoids
|
| + // a critical edge and branchs to the loop header.
|
| + result = block.successors[0].successors[0];
|
| + } else {
|
| + // For other loops, the loop header might be up the dominator
|
| + // tree if the loop condition has control flow.
|
| + result = block;
|
| + while (!result.isLoopHeader()) result = result.dominator;
|
| + }
|
| +
|
| + assert(result.isLoopHeader());
|
| + return result;
|
| + }
|
| }
|
|
|
| class HConstant extends HInstruction {
|
| @@ -2618,6 +2635,8 @@
|
| return node.accept(const LoopTypeVisitor());
|
| }
|
|
|
| + bool isDoWhile() => kind == DO_WHILE_LOOP;
|
| +
|
| bool accept(HStatementInformationVisitor visitor) =>
|
| visitor.visitLoopInfo(this);
|
| }
|
|
|