| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.cps_ir.loop_hierarchy; | 5 library dart2js.cps_ir.loop_hierarchy; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 | 8 |
| 9 /// Determines the effective nesting of loops. | 9 /// Determines the effective nesting of loops. |
| 10 /// | 10 /// |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 target = _markInnerLoop(target, catchLoop); | 144 target = _markInnerLoop(target, catchLoop); |
| 145 for (Continuation cont in callContinuations) { | 145 for (Continuation cont in callContinuations) { |
| 146 // Store the loop target on each call continuation in the basic block. | 146 // Store the loop target on each call continuation in the basic block. |
| 147 // Because we walk over call continuations as part of the basic block | 147 // Because we walk over call continuations as part of the basic block |
| 148 // traversal, these do not get their loop target set otherwise. | 148 // traversal, these do not get their loop target set otherwise. |
| 149 loopTarget[cont] = target; | 149 loopTarget[cont] = target; |
| 150 } | 150 } |
| 151 return target; | 151 return target; |
| 152 } | 152 } |
| 153 |
| 154 /// Returns the the innermost loop that effectively encloses both |
| 155 /// c1 and c2 (or `null` if there is no such loop). |
| 156 Continuation lowestCommonAncestor(Continuation c1, Continuation c2) { |
| 157 int d1 = getDepth(c1), d2 = getDepth(c2); |
| 158 while (c1 != c2) { |
| 159 if (d1 <= d2) { |
| 160 c2 = getEnclosingLoop(c2); |
| 161 d2 = getDepth(c2); |
| 162 } else { |
| 163 c1 = getEnclosingLoop(c1); |
| 164 d1 = getDepth(c1); |
| 165 } |
| 166 } |
| 167 return c1; |
| 168 } |
| 169 |
| 170 /// Returns the lexical nesting depth of [loop]. |
| 171 int getDepth(Continuation loop) { |
| 172 if (loop == null) return 0; |
| 173 return loopDepth[loop]; |
| 174 } |
| 153 } | 175 } |
| OLD | NEW |