Index: pkg/compiler/lib/src/cps_ir/optimizers.dart |
diff --git a/pkg/compiler/lib/src/cps_ir/optimizers.dart b/pkg/compiler/lib/src/cps_ir/optimizers.dart |
index c80dfb0499f952cee3c110f286d231a4dbb2200e..3b48349f6e0e45d7633f8bf4e6ac7853043a22e6 100644 |
--- a/pkg/compiler/lib/src/cps_ir/optimizers.dart |
+++ b/pkg/compiler/lib/src/cps_ir/optimizers.dart |
@@ -5,9 +5,11 @@ |
library dart2js.cps_ir.optimizers; |
import 'cps_ir_nodes.dart'; |
+import '../constants/values.dart'; |
export 'type_propagation.dart' show TypePropagator; |
export 'redundant_phi.dart' show RedundantPhiEliminator; |
+export 'redundant_join.dart' show RedundantJoinEliminator; |
export 'shrinking_reductions.dart' show ShrinkingReducer, ParentVisitor; |
/// An optimization pass over the CPS IR. |
@@ -17,3 +19,15 @@ abstract class Pass { |
String get passName; |
} |
+ |
+// Shared code between optimizations |
+ |
+/// Returns true if [value] is false, null, 0, -0, NaN, or the empty string. |
+bool isFalsyConstant(ConstantValue value) { |
+ return value.isFalse || |
+ value.isNull || |
+ value.isZero || |
+ value.isMinusZero || |
+ value.isNaN || |
+ value is StringConstantValue && value.primitiveValue.isEmpty; |
+} |