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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 121 target = node.continuation; |
122 } else { | 122 } else { |
123 target = loopTarget[node.continuation]; | 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(loopTarget[node.trueContinuation], |
127 loopTarget[node.trueContinuation], | |
128 loopTarget[node.falseContinuation]); | 127 loopTarget[node.falseContinuation]); |
129 } else if (node == null) { | 128 } else if (node == null) { |
130 // 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]. |
131 target = _exitLoop; | 130 target = _exitLoop; |
132 } else { | 131 } else { |
133 assert(node is Unreachable || node is Throw || node == null); | 132 assert(node is Unreachable || node is Throw || node == null); |
134 } | 133 } |
135 return _markInnerLoop(target, catchLoop); | 134 return _markInnerLoop(target, catchLoop); |
136 } | 135 } |
137 | 136 |
(...skipping 21 matching lines...) Expand all Loading... |
159 | 158 |
160 /// Sets the loop header for each continuation bound inside the given | 159 /// Sets the loop header for each continuation bound inside the given |
161 /// fragment. | 160 /// fragment. |
162 /// | 161 /// |
163 /// If the fragment is open, [exitLoop] denotes the loop header for | 162 /// If the fragment is open, [exitLoop] denotes the loop header for |
164 /// the code that will occur after the fragment. | 163 /// the code that will occur after the fragment. |
165 /// | 164 /// |
166 /// [catchLoop] is the loop target for the catch clause of the try/catch | 165 /// [catchLoop] is the loop target for the catch clause of the try/catch |
167 /// surrounding the inserted fragment. | 166 /// surrounding the inserted fragment. |
168 void update(CpsFragment fragment, | 167 void update(CpsFragment fragment, |
169 {Continuation exitLoop, | 168 {Continuation exitLoop, Continuation catchLoop}) { |
170 Continuation catchLoop}) { | |
171 if (fragment.isEmpty) return; | 169 if (fragment.isEmpty) return; |
172 _exitLoop = exitLoop; | 170 _exitLoop = exitLoop; |
173 _currentDepth = getDepth(exitLoop); | 171 _currentDepth = getDepth(exitLoop); |
174 _processBlock(fragment.root, catchLoop); | 172 _processBlock(fragment.root, catchLoop); |
175 _exitLoop = null; | 173 _exitLoop = null; |
176 } | 174 } |
177 } | 175 } |
OLD | NEW |