| 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_invariant_code_motion; | 5 library dart2js.cps_ir.loop_invariant_code_motion; |
| 6 | 6 |
| 7 import 'optimizers.dart'; | 7 import 'optimizers.dart'; |
| 8 import 'cps_ir_nodes.dart'; | 8 import 'cps_ir_nodes.dart'; |
| 9 import 'loop_hierarchy.dart'; | 9 import 'loop_hierarchy.dart'; |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (loop1 == null) return loop2; | 119 if (loop1 == null) return loop2; |
| 120 if (loop2 == null) return loop1; | 120 if (loop2 == null) return loop1; |
| 121 if (loopHierarchy.loopDepth[loop1] > loopHierarchy.loopDepth[loop2]) { | 121 if (loopHierarchy.loopDepth[loop1] > loopHierarchy.loopDepth[loop2]) { |
| 122 return loop1; | 122 return loop1; |
| 123 } else { | 123 } else { |
| 124 return loop2; | 124 return loop2; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool shouldLift(Primitive prim) { | 128 bool shouldLift(Primitive prim) { |
| 129 // Interceptors are safe and almost always profitable for lifting | 129 // Interceptors are generally safe and almost always profitable for lifting |
| 130 // out of loops. Several other primitive could be lifted too, but it's not | 130 // out of loops. Several other primitive could be lifted too, but it's not |
| 131 // always profitable to do so. | 131 // always profitable to do so. |
| 132 |
| 133 // Note that the type of the interceptor is technically not sound after |
| 134 // lifting because its current type might have been computed based on a |
| 135 // refinement node (which has since been removed). As a whole, it still |
| 136 // works out because all uses of the interceptor must occur in a context |
| 137 // where it indeed has the type it claims to have. |
| 132 return prim is Interceptor; | 138 return prim is Interceptor; |
| 133 } | 139 } |
| 134 } | 140 } |
| OLD | NEW |