OLD | NEW |
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 HInstruction visitBoolify(HBoolify node) { | 242 HInstruction visitBoolify(HBoolify node) { |
243 List<HInstruction> inputs = node.inputs; | 243 List<HInstruction> inputs = node.inputs; |
244 assert(inputs.length == 1); | 244 assert(inputs.length == 1); |
245 HInstruction input = inputs[0]; | 245 HInstruction input = inputs[0]; |
246 if (input.isBoolean(compiler)) return input; | 246 if (input.isBoolean(compiler)) return input; |
247 | 247 |
248 // If the code is unreachable, remove the HBoolify. This can happen when | 248 // If the code is unreachable, remove the HBoolify. This can happen when |
249 // there is a throw expression in a short-circuit conditional. Removing the | 249 // there is a throw expression in a short-circuit conditional. Removing the |
250 // unreachable HBoolify makes it easier to reconstruct the short-circuit | 250 // unreachable HBoolify makes it easier to reconstruct the short-circuit |
251 // operation. | 251 // operation. |
252 if (input.instructionType.isEmpty && !input.instructionType.isNullable) | 252 if (input.instructionType.isEmpty) return input; |
253 return input; | |
254 | 253 |
255 // All values that cannot be 'true' are boolified to false. | 254 // All values that cannot be 'true' are boolified to false. |
256 TypeMask mask = input.instructionType; | 255 TypeMask mask = input.instructionType; |
257 if (!mask.contains(helpers.jsBoolClass, compiler.world)) { | 256 if (!mask.contains(helpers.jsBoolClass, compiler.world)) { |
258 return graph.addConstantBool(false, compiler); | 257 return graph.addConstantBool(false, compiler); |
259 } | 258 } |
260 return node; | 259 return node; |
261 } | 260 } |
262 | 261 |
263 HInstruction visitNot(HNot node) { | 262 HInstruction visitNot(HNot node) { |
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2398 | 2397 |
2399 keyedValues.forEach((receiver, values) { | 2398 keyedValues.forEach((receiver, values) { |
2400 result.keyedValues[receiver] = | 2399 result.keyedValues[receiver] = |
2401 new Map<HInstruction, HInstruction>.from(values); | 2400 new Map<HInstruction, HInstruction>.from(values); |
2402 }); | 2401 }); |
2403 | 2402 |
2404 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2403 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
2405 return result; | 2404 return result; |
2406 } | 2405 } |
2407 } | 2406 } |
OLD | NEW |