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