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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of ssa; 5 part of ssa;
6 6
7 abstract class OptimizationPhase { 7 abstract class OptimizationPhase {
8 String get name; 8 String get name;
9 void visitGraph(HGraph graph); 9 void visitGraph(HGraph graph);
10 } 10 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 HInstruction visitInstruction(HInstruction node) { 176 HInstruction visitInstruction(HInstruction node) {
177 return node; 177 return node;
178 } 178 }
179 179
180 HInstruction visitBoolify(HBoolify node) { 180 HInstruction visitBoolify(HBoolify node) {
181 List<HInstruction> inputs = node.inputs; 181 List<HInstruction> inputs = node.inputs;
182 assert(inputs.length == 1); 182 assert(inputs.length == 1);
183 HInstruction input = inputs[0]; 183 HInstruction input = inputs[0];
184 HType type = input.instructionType; 184 HType type = input.instructionType;
185 if (type.isBoolean()) return input; 185 if (type.isBoolean()) return input;
186 // All values !== true are boolified to false. 186 // All values that cannot be 'true' are boolified to false.
187 if (!type.isBooleanOrNull() && !type.isUnknown()) { 187 DartType booleanType = backend.jsBoolClass.computeType(compiler);
karlklose 2013/03/05 09:29:21 You could use '.rawType' here. Long term I think
188 TypeMask mask = type.computeMask(compiler);
189 // TODO(kasperl): Get rid of the null check here once all HTypes
190 // have a proper mask.
191 if (mask != null && !mask.contains(booleanType, compiler)) {
188 return graph.addConstantBool(false, constantSystem); 192 return graph.addConstantBool(false, constantSystem);
189 } 193 }
190 return node; 194 return node;
191 } 195 }
192 196
193 HInstruction visitNot(HNot node) { 197 HInstruction visitNot(HNot node) {
194 List<HInstruction> inputs = node.inputs; 198 List<HInstruction> inputs = node.inputs;
195 assert(inputs.length == 1); 199 assert(inputs.length == 1);
196 HInstruction input = inputs[0]; 200 HInstruction input = inputs[0];
197 if (input is HConstant) { 201 if (input is HConstant) {
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 HBasicBlock block = user.block; 1543 HBasicBlock block = user.block;
1540 block.addAfter(user, interceptor); 1544 block.addAfter(user, interceptor);
1541 block.rewrite(user, interceptor); 1545 block.rewrite(user, interceptor);
1542 block.remove(user); 1546 block.remove(user);
1543 1547
1544 // The interceptor will be removed in the dead code elimination 1548 // The interceptor will be removed in the dead code elimination
1545 // phase. Note that removing it here would not work because of how 1549 // phase. Note that removing it here would not work because of how
1546 // the [visitBasicBlock] is implemented. 1550 // the [visitBasicBlock] is implemented.
1547 } 1551 }
1548 } 1552 }
OLDNEW
« 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