| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 for (Continuation cont in node.continuations) { | 111 for (Continuation cont in node.continuations) { |
| 112 _processContinuation(cont, catchLoop); | 112 _processContinuation(cont, catchLoop); |
| 113 } | 113 } |
| 114 } else if (node is LetHandler) { | 114 } else if (node is LetHandler) { |
| 115 catchLoop = _processContinuation(node.handler, catchLoop); | 115 catchLoop = _processContinuation(node.handler, catchLoop); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 Continuation target; | 118 Continuation target; |
| 119 if (node is InvokeContinuation) { | 119 if (node is InvokeContinuation) { |
| 120 if (node.isRecursive) { | 120 if (node.isRecursive) { |
| 121 target = node.continuation.definition; | 121 target = node.continuation; |
| 122 } else { | 122 } else { |
| 123 target = loopTarget[node.continuation.definition]; | 123 target = loopTarget[node.continuation]; |
| 124 } | 124 } |
| 125 } else if (node is Branch) { | 125 } else if (node is Branch) { |
| 126 target = _markInnerLoop( | 126 target = _markInnerLoop( |
| 127 loopTarget[node.trueContinuation.definition], | 127 loopTarget[node.trueContinuation], |
| 128 loopTarget[node.falseContinuation.definition]); | 128 loopTarget[node.falseContinuation]); |
| 129 } else if (node == null) { | 129 } else if (node == null) { |
| 130 // If the code ends abruptly, use the exit loop provided in [update]. | 130 // If the code ends abruptly, use the exit loop provided in [update]. |
| 131 target = _exitLoop; | 131 target = _exitLoop; |
| 132 } else { | 132 } else { |
| 133 assert(node is Unreachable || node is Throw || node == null); | 133 assert(node is Unreachable || node is Throw || node == null); |
| 134 } | 134 } |
| 135 return _markInnerLoop(target, catchLoop); | 135 return _markInnerLoop(target, catchLoop); |
| 136 } | 136 } |
| 137 | 137 |
| 138 /// Returns the the innermost loop that effectively encloses both | 138 /// Returns the the innermost loop that effectively encloses both |
| (...skipping 29 matching lines...) Expand all Loading... |
| 168 void update(CpsFragment fragment, | 168 void update(CpsFragment fragment, |
| 169 {Continuation exitLoop, | 169 {Continuation exitLoop, |
| 170 Continuation catchLoop}) { | 170 Continuation catchLoop}) { |
| 171 if (fragment.isEmpty) return; | 171 if (fragment.isEmpty) return; |
| 172 _exitLoop = exitLoop; | 172 _exitLoop = exitLoop; |
| 173 _currentDepth = getDepth(exitLoop); | 173 _currentDepth = getDepth(exitLoop); |
| 174 _processBlock(fragment.root, catchLoop); | 174 _processBlock(fragment.root, catchLoop); |
| 175 _exitLoop = null; | 175 _exitLoop = null; |
| 176 } | 176 } |
| 177 } | 177 } |
| OLD | NEW |