Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart

Issue 12428003: Use type mask to figure out if we can constant fold boolify operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart b/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
index 7a41583029fa382f8aed202446162e1da390dbf4..df026d44805e13c757061e3c921835b55ae19a51 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
@@ -183,8 +183,12 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
HInstruction input = inputs[0];
HType type = input.instructionType;
if (type.isBoolean()) return input;
- // All values !== true are boolified to false.
- if (!type.isBooleanOrNull() && !type.isUnknown()) {
+ // All values that cannot be 'true' are boolified to false.
+ DartType booleanType = backend.jsBoolClass.computeType(compiler);
karlklose 2013/03/05 09:29:21 You could use '.rawType' here. Long term I think
+ TypeMask mask = type.computeMask(compiler);
+ // TODO(kasperl): Get rid of the null check here once all HTypes
+ // have a proper mask.
+ if (mask != null && !mask.contains(booleanType, compiler)) {
return graph.addConstantBool(false, constantSystem);
}
return node;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698