| 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.optimizers; | 5 library dart2js.cps_ir.optimizers; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
| 9 | 9 |
| 10 export 'type_propagation.dart' show TypePropagator; | 10 export 'type_propagation.dart' show TypePropagator; |
| 11 export 'scalar_replacement.dart' show ScalarReplacer; | 11 export 'scalar_replacement.dart' show ScalarReplacer; |
| 12 export 'redundant_phi.dart' show RedundantPhiEliminator; | 12 export 'redundant_phi.dart' show RedundantPhiEliminator; |
| 13 export 'redundant_join.dart' show RedundantJoinEliminator; | 13 export 'redundant_join.dart' show RedundantJoinEliminator; |
| 14 export 'shrinking_reductions.dart' show ShrinkingReducer, ParentVisitor; | 14 export 'shrinking_reductions.dart' show ShrinkingReducer, ParentVisitor; |
| 15 export 'mutable_ssa.dart' show MutableVariableEliminator; | 15 export 'mutable_ssa.dart' show MutableVariableEliminator; |
| 16 export 'let_sinking.dart' show LetSinker; | |
| 17 export 'insert_refinements.dart' show InsertRefinements; | 16 export 'insert_refinements.dart' show InsertRefinements; |
| 18 export 'remove_refinements.dart' show RemoveRefinements; | 17 export 'remove_refinements.dart' show RemoveRefinements; |
| 19 export 'loop_invariant_code_motion.dart' show LoopInvariantCodeMotion; | 18 export 'loop_invariant_code_motion.dart' show LoopInvariantCodeMotion; |
| 20 export 'share_interceptors.dart' show ShareInterceptors; | 19 export 'share_interceptors.dart' show ShareInterceptors; |
| 21 | 20 |
| 22 /// An optimization pass over the CPS IR. | 21 /// An optimization pass over the CPS IR. |
| 23 abstract class Pass { | 22 abstract class Pass { |
| 24 /// Applies optimizations to root, rewriting it in the process. | 23 /// Applies optimizations to root, rewriting it in the process. |
| 25 void rewrite(FunctionDefinition root); | 24 void rewrite(FunctionDefinition root); |
| 26 | 25 |
| 27 String get passName; | 26 String get passName; |
| 28 } | 27 } |
| 29 | 28 |
| 30 // Shared code between optimizations | 29 // Shared code between optimizations |
| 31 | 30 |
| 32 /// Returns true if [value] is false, null, 0, -0, NaN, or the empty string. | 31 /// Returns true if [value] is false, null, 0, -0, NaN, or the empty string. |
| 33 bool isFalsyConstant(ConstantValue value) { | 32 bool isFalsyConstant(ConstantValue value) { |
| 34 return value.isFalse || | 33 return value.isFalse || |
| 35 value.isNull || | 34 value.isNull || |
| 36 value.isZero || | 35 value.isZero || |
| 37 value.isMinusZero || | 36 value.isMinusZero || |
| 38 value.isNaN || | 37 value.isNaN || |
| 39 value is StringConstantValue && value.primitiveValue.isEmpty; | 38 value is StringConstantValue && value.primitiveValue.isEmpty; |
| 40 } | 39 } |
| OLD | NEW |