| 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 525ef51faa539493494f34c8a6e94242d1e2a379..99b1105505e92700d44ce26eec64a67a15a5ef09 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart
|
| @@ -127,4 +127,26 @@ class LoopHierarchy {
|
| }
|
| return _markInnerLoop(target, catchLoop);
|
| }
|
| +
|
| + /// 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 0;
|
| + return loopDepth[loop];
|
| + }
|
| }
|
|
|