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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 } else { | 571 } else { |
572 return graph.addConstantBool(false, compiler); | 572 return graph.addConstantBool(false, compiler); |
573 } | 573 } |
574 } else if (expressionType.isNumber()) { | 574 } else if (expressionType.isNumber()) { |
575 if (identical(element, compiler.numClass)) { | 575 if (identical(element, compiler.numClass)) { |
576 return graph.addConstantBool(true, compiler); | 576 return graph.addConstantBool(true, compiler); |
577 } else { | 577 } else { |
578 // We cannot just return false, because the expression may be of | 578 // We cannot just return false, because the expression may be of |
579 // type int or double. | 579 // type int or double. |
580 } | 580 } |
| 581 } else if (expressionType.canBePrimitiveNumber(compiler) |
| 582 && identical(element, compiler.intClass)) { |
| 583 // We let the JS semantics decide for that check. |
| 584 return node; |
581 // We need the [:hasTypeArguments:] check because we don't have | 585 // We need the [:hasTypeArguments:] check because we don't have |
582 // the notion of generics in the backend. For example, [:this:] in | 586 // the notion of generics in the backend. For example, [:this:] in |
583 // a class [:A<T>:], is currently always considered to have the | 587 // a class [:A<T>:], is currently always considered to have the |
584 // raw type. | 588 // raw type. |
585 } else if (!RuntimeTypes.hasTypeArguments(type)) { | 589 } else if (!RuntimeTypes.hasTypeArguments(type)) { |
586 TypeMask expressionMask = expressionType.computeMask(compiler); | 590 TypeMask expressionMask = expressionType.computeMask(compiler); |
587 TypeMask typeMask = (element == compiler.nullClass) | 591 TypeMask typeMask = (element == compiler.nullClass) |
588 ? new TypeMask.subtype(type) : new TypeMask.nonNullSubtype(type); | 592 ? new TypeMask.subtype(type) : new TypeMask.nonNullSubtype(type); |
589 if (expressionMask.union(typeMask, compiler) == typeMask) { | 593 if (expressionMask.union(typeMask, compiler) == typeMask) { |
590 return graph.addConstantBool(true, compiler); | 594 return graph.addConstantBool(true, compiler); |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 // that knows it is not of a specific Type. | 1354 // that knows it is not of a specific Type. |
1351 } | 1355 } |
1352 | 1356 |
1353 for (HIf ifUser in notIfUsers) { | 1357 for (HIf ifUser in notIfUsers) { |
1354 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); | 1358 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); |
1355 // TODO(ngeoffray): Also change uses for the then block on a HType | 1359 // TODO(ngeoffray): Also change uses for the then block on a HType |
1356 // that knows it is not of a specific Type. | 1360 // that knows it is not of a specific Type. |
1357 } | 1361 } |
1358 } | 1362 } |
1359 } | 1363 } |
OLD | NEW |