| 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 import 'cps_fragment.dart'; | 8 import 'cps_fragment.dart'; |
| 9 | 9 |
| 10 /// Determines the effective nesting of loops. | 10 /// Determines the effective nesting of loops. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 loopTarget[node.falseContinuation]); | 127 loopTarget[node.falseContinuation]); |
| 128 } else if (node == null) { | 128 } else if (node == null) { |
| 129 // If the code ends abruptly, use the exit loop provided in [update]. | 129 // If the code ends abruptly, use the exit loop provided in [update]. |
| 130 target = _exitLoop; | 130 target = _exitLoop; |
| 131 } else { | 131 } else { |
| 132 assert(node is Unreachable || node is Throw || node == null); | 132 assert(node is Unreachable || node is Throw || node == null); |
| 133 } | 133 } |
| 134 return _markInnerLoop(target, catchLoop); | 134 return _markInnerLoop(target, catchLoop); |
| 135 } | 135 } |
| 136 | 136 |
| 137 /// Returns the the innermost loop that effectively encloses both | 137 /// Returns the innermost loop that effectively encloses both |
| 138 /// c1 and c2 (or `null` if there is no such loop). | 138 /// c1 and c2 (or `null` if there is no such loop). |
| 139 Continuation lowestCommonAncestor(Continuation c1, Continuation c2) { | 139 Continuation lowestCommonAncestor(Continuation c1, Continuation c2) { |
| 140 int d1 = getDepth(c1), d2 = getDepth(c2); | 140 int d1 = getDepth(c1), d2 = getDepth(c2); |
| 141 while (c1 != c2) { | 141 while (c1 != c2) { |
| 142 if (d1 <= d2) { | 142 if (d1 <= d2) { |
| 143 c2 = getEnclosingLoop(c2); | 143 c2 = getEnclosingLoop(c2); |
| 144 d2 = getDepth(c2); | 144 d2 = getDepth(c2); |
| 145 } else { | 145 } else { |
| 146 c1 = getEnclosingLoop(c1); | 146 c1 = getEnclosingLoop(c1); |
| 147 d1 = getDepth(c1); | 147 d1 = getDepth(c1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 166 /// surrounding the inserted fragment. | 166 /// surrounding the inserted fragment. |
| 167 void update(CpsFragment fragment, | 167 void update(CpsFragment fragment, |
| 168 {Continuation exitLoop, Continuation catchLoop}) { | 168 {Continuation exitLoop, Continuation catchLoop}) { |
| 169 if (fragment.isEmpty) return; | 169 if (fragment.isEmpty) return; |
| 170 _exitLoop = exitLoop; | 170 _exitLoop = exitLoop; |
| 171 _currentDepth = getDepth(exitLoop); | 171 _currentDepth = getDepth(exitLoop); |
| 172 _processBlock(fragment.root, catchLoop); | 172 _processBlock(fragment.root, catchLoop); |
| 173 _exitLoop = null; | 173 _exitLoop = null; |
| 174 } | 174 } |
| 175 } | 175 } |
| OLD | NEW |