| 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 } else { | 576 } else { |
| 577 // We cannot just return false, because the expression may be of | 577 // We cannot just return false, because the expression may be of |
| 578 // type int or double. | 578 // type int or double. |
| 579 } | 579 } |
| 580 // We need the [:hasTypeArguments:] check because we don't have | 580 // We need the [:hasTypeArguments:] check because we don't have |
| 581 // the notion of generics in the backend. For example, [:this:] in | 581 // the notion of generics in the backend. For example, [:this:] in |
| 582 // a class [:A<T>:], is currently always considered to have the | 582 // a class [:A<T>:], is currently always considered to have the |
| 583 // raw type. | 583 // raw type. |
| 584 } else if (!RuntimeTypes.hasTypeArguments(type)) { | 584 } else if (!RuntimeTypes.hasTypeArguments(type)) { |
| 585 TypeMask expressionMask = expressionType.computeMask(compiler); | 585 TypeMask expressionMask = expressionType.computeMask(compiler); |
| 586 TypeMask typeMask = new TypeMask.nonNullSubtype(type); | 586 TypeMask typeMask = (element == compiler.nullClass) |
| 587 ? new TypeMask.subtype(type) : new TypeMask.nonNullSubtype(type); |
| 587 if (expressionMask.union(typeMask, compiler) == typeMask) { | 588 if (expressionMask.union(typeMask, compiler) == typeMask) { |
| 588 return graph.addConstantBool(true, compiler); | 589 return graph.addConstantBool(true, compiler); |
| 589 } else if (expressionMask.intersection(typeMask, compiler).isEmpty) { | 590 } else if (expressionMask.intersection(typeMask, compiler).isEmpty) { |
| 590 return graph.addConstantBool(false, compiler); | 591 return graph.addConstantBool(false, compiler); |
| 591 } | 592 } |
| 592 } | 593 } |
| 593 return node; | 594 return node; |
| 594 } | 595 } |
| 595 | 596 |
| 596 HInstruction visitTypeConversion(HTypeConversion node) { | 597 HInstruction visitTypeConversion(HTypeConversion node) { |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 // that knows it is not of a specific Type. | 1339 // that knows it is not of a specific Type. |
| 1339 } | 1340 } |
| 1340 | 1341 |
| 1341 for (HIf ifUser in notIfUsers) { | 1342 for (HIf ifUser in notIfUsers) { |
| 1342 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); | 1343 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); |
| 1343 // TODO(ngeoffray): Also change uses for the then block on a HType | 1344 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1344 // that knows it is not of a specific Type. | 1345 // that knows it is not of a specific Type. |
| 1345 } | 1346 } |
| 1346 } | 1347 } |
| 1347 } | 1348 } |
| OLD | NEW |