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 tree_ir.optimization.variable_merger; | 5 library tree_ir.optimization.variable_merger; |
6 | 6 |
7 import 'optimization.dart' show Pass; | 7 import 'optimization.dart' show Pass; |
8 import '../tree_ir_nodes.dart'; | 8 import '../tree_ir_nodes.dart'; |
9 | 9 |
10 /// Merges variables based on liveness and source variable information. | 10 /// Merges variables based on liveness and source variable information. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 visitWhileTrue(WhileTrue node) { | 204 visitWhileTrue(WhileTrue node) { |
205 Block join = _jumpTarget[node.label] = newBlock(); | 205 Block join = _jumpTarget[node.label] = newBlock(); |
206 join.predecessors.add(_currentBlock); | 206 join.predecessors.add(_currentBlock); |
207 _currentBlock = join; | 207 _currentBlock = join; |
208 visitStatement(node.body); // visitContinue will add predecessors to join. | 208 visitStatement(node.body); // visitContinue will add predecessors to join. |
209 } | 209 } |
210 | 210 |
211 visitWhileCondition(WhileCondition node) { | 211 visitWhileCondition(WhileCondition node) { |
212 Block join = _jumpTarget[node.label] = newBlock(); | 212 Block entry = _currentBlock; |
213 join.predecessors.add(_currentBlock); | 213 _currentBlock = _jumpTarget[node.label] = newBlock(); |
214 _currentBlock = join; | 214 node.updates.forEach(visitExpression); |
| 215 joinFrom(entry, _currentBlock); |
215 visitExpression(node.condition); | 216 visitExpression(node.condition); |
216 Block afterCondition = _currentBlock; | 217 Block afterCondition = _currentBlock; |
217 branchFrom(afterCondition); | 218 branchFrom(afterCondition); |
218 visitStatement(node.body); // visitContinue will add predecessors to join. | 219 visitStatement(node.body); // visitContinue will add predecessors to join. |
219 branchFrom(afterCondition); | 220 branchFrom(afterCondition); |
220 visitStatement(node.next); | 221 visitStatement(node.next); |
221 } | 222 } |
222 | 223 |
223 visitTry(Try node) { | 224 visitTry(Try node) { |
224 Block outerCatchBlock = _currentBlock.catchBlock; | 225 Block outerCatchBlock = _currentBlock.catchBlock; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 node.expression = visitExpression(node.expression); | 536 node.expression = visitExpression(node.expression); |
536 node.next = visitStatement(node.next); | 537 node.next = visitStatement(node.next); |
537 if (node.expression is VariableUse) { | 538 if (node.expression is VariableUse) { |
538 VariableUse use = node.expression; | 539 VariableUse use = node.expression; |
539 --use.variable.readCount; | 540 --use.variable.readCount; |
540 return node.next; | 541 return node.next; |
541 } | 542 } |
542 return node; | 543 return node; |
543 } | 544 } |
544 } | 545 } |
OLD | NEW |