Chromium Code Reviews| Index: pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart |
| diff --git a/pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart b/pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart |
| index 3aa5bc9bf64e548bb6373543b869fece700db572..27b129e711265c0ac2872f4aa9b999647b8efc86 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart |
| @@ -150,4 +150,26 @@ class LoopHierarchy { |
| } |
| return target; |
| } |
| + |
| + /// Returns the the innermost loop that effectively encloses both |
| + /// c1 and c2 (or `null` if there is no such loop). |
| + Continuation lowestCommonAncestor(Continuation c1, Continuation c2) { |
| + int d1 = getDepth(c1), d2 = getDepth(c2); |
| + while (c1 != c2) { |
| + if (d1 <= d2) { |
| + c2 = getEnclosingLoop(c2); |
| + d2 = getDepth(c2); |
| + } else { |
| + c1 = getEnclosingLoop(c1); |
| + d1 = getDepth(c1); |
| + } |
| + } |
| + return c1; |
| + } |
| + |
| + /// Returns the lexical nesting depth of [loop]. |
| + int getDepth(Continuation loop) { |
| + if (loop == null) return -1; |
|
sra1
2015/11/17 05:41:14
It would be useful if unnested was 0 (depth can th
asgerf
2015/11/17 12:43:43
Done. (The first loop had depth 1 so it kind of wr
|
| + return loopDepth[loop]; |
| + } |
| } |