| 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 cps_ir.optimization.insert_refinements; | 5 library cps_ir.optimization.insert_refinements; |
| 6 | 6 |
| 7 import 'optimizers.dart' show Pass; | 7 import 'optimizers.dart' show Pass; |
| 8 import 'shrinking_reductions.dart' show ParentVisitor; | 8 import 'shrinking_reductions.dart' show ParentVisitor; |
| 9 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
| 10 import '../types/constants.dart'; | 10 import '../types/constants.dart'; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 Continuation falseCont = node.falseContinuation.definition; | 156 Continuation falseCont = node.falseContinuation.definition; |
| 157 | 157 |
| 158 // Sink both continuations to the Branch to ensure everything in scope | 158 // Sink both continuations to the Branch to ensure everything in scope |
| 159 // here is also in scope inside the continuations. | 159 // here is also in scope inside the continuations. |
| 160 sinkContinuationToUse(trueCont, node); | 160 sinkContinuationToUse(trueCont, node); |
| 161 sinkContinuationToUse(falseCont, node); | 161 sinkContinuationToUse(falseCont, node); |
| 162 | 162 |
| 163 // If the condition is an 'is' check, promote the checked value. | 163 // If the condition is an 'is' check, promote the checked value. |
| 164 if (condition is TypeTest) { | 164 if (condition is TypeTest) { |
| 165 Primitive value = condition.value.definition; | 165 Primitive value = condition.value.definition; |
| 166 TypeMask type = types.subtypesOf(condition.type); | 166 TypeMask type = types.subtypesOf(condition.dartType); |
| 167 Primitive refinedValue = new Refinement(value, type); | 167 Primitive refinedValue = new Refinement(value, type); |
| 168 pushRefinement(trueCont, refinedValue); | 168 pushRefinement(trueCont, refinedValue); |
| 169 push(falseCont); | 169 push(falseCont); |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // If the condition is comparison with a constant, promote the other value. | 173 // If the condition is comparison with a constant, promote the other value. |
| 174 // This can happen either for calls to `==` or `identical` calls, such | 174 // This can happen either for calls to `==` or `identical` calls, such |
| 175 // as the ones inserted by the unsugaring pass. | 175 // as the ones inserted by the unsugaring pass. |
| 176 | 176 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 cont.firstRef.parent is Branch)) { | 223 cont.firstRef.parent is Branch)) { |
| 224 // Do not push the continuation here. | 224 // Do not push the continuation here. |
| 225 // visitInvokeMethod and visitBranch will do that. | 225 // visitInvokeMethod and visitBranch will do that. |
| 226 } else { | 226 } else { |
| 227 push(cont); | 227 push(cont); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 return node.body; | 230 return node.body; |
| 231 } | 231 } |
| 232 } | 232 } |
| OLD | NEW |