OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.shrinking_reductions; | 5 library dart2js.cps_ir.shrinking_reductions; |
6 | 6 |
7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
8 import 'optimizers.dart'; | 8 import 'optimizers.dart'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 return; | 159 return; |
160 } | 160 } |
161 | 161 |
162 // Remove the continuation. | 162 // Remove the continuation. |
163 Continuation cont = task.node; | 163 Continuation cont = task.node; |
164 _removeContinuation(cont); | 164 _removeContinuation(cont); |
165 | 165 |
166 InvokeContinuation invoke = cont.body; | 166 InvokeContinuation invoke = cont.body; |
167 Continuation wrappedCont = invoke.continuation.definition; | 167 Continuation wrappedCont = invoke.continuation.definition; |
168 | 168 |
169 // If the invocation of wrappedCont is escaping, then all invocations of | |
170 // cont will be as well, after the reduction. | |
171 if (invoke.isEscapingTry) { | |
172 Reference current = cont.firstRef; | |
173 while (current != null) { | |
174 InvokeContinuation owner = current.parent; | |
175 owner.isEscapingTry = true; | |
176 current = current.next; | |
177 } | |
178 } | |
179 | |
180 // Replace all occurrences with the wrapped continuation. | 169 // Replace all occurrences with the wrapped continuation. |
181 cont.replaceUsesWith(wrappedCont); | 170 cont.replaceUsesWith(wrappedCont); |
182 | 171 |
183 // Perform bookkeeping on removed body and scan for new redexes. | 172 // Perform bookkeeping on removed body and scan for new redexes. |
184 new _RemovalVisitor(_worklist).visit(cont); | 173 new _RemovalVisitor(_worklist).visit(cont); |
185 } | 174 } |
186 | 175 |
187 void _reduceDeadParameter(_ReductionTask task) { | 176 void _reduceDeadParameter(_ReductionTask task) { |
188 // Continuation eta-reduction can destroy a dead parameter redex. For | 177 // Continuation eta-reduction can destroy a dead parameter redex. For |
189 // example, in the term: | 178 // example, in the term: |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 513 |
525 String toString() => "$kind: $node"; | 514 String toString() => "$kind: $node"; |
526 } | 515 } |
527 | 516 |
528 /// A dummy class used solely to mark nodes as deleted once they are removed | 517 /// A dummy class used solely to mark nodes as deleted once they are removed |
529 /// from a term. | 518 /// from a term. |
530 class _DeletedNode extends Node { | 519 class _DeletedNode extends Node { |
531 accept(_) {} | 520 accept(_) {} |
532 setParentPointers() {} | 521 setParentPointers() {} |
533 } | 522 } |
OLD | NEW |