| 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.gvn; | 5 library dart2js.cps_ir.gvn; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import '../universe/side_effects.dart'; | 8 import '../universe/side_effects.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import 'optimizers.dart' show Pass; | 10 import 'optimizers.dart' show Pass; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 if (node is LetCont) { | 185 if (node is LetCont) { |
| 186 continue; | 186 continue; |
| 187 } | 187 } |
| 188 return false; | 188 return false; |
| 189 } | 189 } |
| 190 return node == currentLoopHeader; | 190 return node == currentLoopHeader; |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool isHoistablePrimitive(Primitive prim) { | 193 bool isHoistablePrimitive(Primitive prim) { |
| 194 if (prim.isSafeForElimination) return true; | 194 if (prim.isSafeForElimination) return true; |
| 195 if (prim is NullCheck || | 195 if (prim is ReceiverCheck || |
| 196 prim is BoundsCheck || | 196 prim is BoundsCheck || |
| 197 prim is GetLength || | 197 prim is GetLength || |
| 198 prim is GetField || | 198 prim is GetField || |
| 199 prim is GetIndex) { | 199 prim is GetIndex) { |
| 200 // Expressions that potentially throw but have no other effects can be | 200 // Expressions that potentially throw but have no other effects can be |
| 201 // hoisted if they occur as the first impure expression in a loop. | 201 // hoisted if they occur as the first impure expression in a loop. |
| 202 // Note regarding BoundsCheck: the current array length is an input to | 202 // Note regarding BoundsCheck: the current array length is an input to |
| 203 // check, so the check itself has no heap dependency. It will only be | 203 // check, so the check itself has no heap dependency. It will only be |
| 204 // hoisted if the length was hoisted. | 204 // hoisted if the length was hoisted. |
| 205 // TODO(asgerf): In general we could hoist these out of multiple loops, | 205 // TODO(asgerf): In general we could hoist these out of multiple loops, |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 760 |
| 761 @override | 761 @override |
| 762 processReference(Reference ref) { | 762 processReference(Reference ref) { |
| 763 callback(ref); | 763 callback(ref); |
| 764 } | 764 } |
| 765 | 765 |
| 766 static void forEach(Primitive node, ReferenceCallback callback) { | 766 static void forEach(Primitive node, ReferenceCallback callback) { |
| 767 new InputVisitor(callback).visit(node); | 767 new InputVisitor(callback).visit(node); |
| 768 } | 768 } |
| 769 } | 769 } |
| OLD | NEW |