| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } else if (expressionMask.intersection(typeMask, compiler).isEmpty) { | 599 } else if (expressionMask.intersection(typeMask, compiler).isEmpty) { |
| 600 return graph.addConstantBool(false, constantSystem); | 600 return graph.addConstantBool(false, constantSystem); |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 return node; | 603 return node; |
| 604 } | 604 } |
| 605 | 605 |
| 606 HInstruction visitTypeConversion(HTypeConversion node) { | 606 HInstruction visitTypeConversion(HTypeConversion node) { |
| 607 HInstruction value = node.inputs[0]; | 607 HInstruction value = node.inputs[0]; |
| 608 DartType type = node.typeExpression; | 608 DartType type = node.typeExpression; |
| 609 if (type != null && !type.isRaw) return node; | 609 if (type != null && (!type.isRaw || type.kind == TypeKind.TYPE_VARIABLE)) { |
| 610 return node; |
| 611 } |
| 610 HType convertedType = node.instructionType; | 612 HType convertedType = node.instructionType; |
| 611 if (convertedType.isUnknown()) return node; | 613 if (convertedType.isUnknown()) return node; |
| 612 HType combinedType = value.instructionType.intersection( | 614 HType combinedType = value.instructionType.intersection( |
| 613 convertedType, compiler); | 615 convertedType, compiler); |
| 614 return (combinedType == value.instructionType) ? value : node; | 616 return (combinedType == value.instructionType) ? value : node; |
| 615 } | 617 } |
| 616 | 618 |
| 617 Element findConcreteFieldForDynamicAccess(HInstruction receiver, | 619 Element findConcreteFieldForDynamicAccess(HInstruction receiver, |
| 618 Selector selector) { | 620 Selector selector) { |
| 619 HType receiverType = receiver.instructionType; | 621 HType receiverType = receiver.instructionType; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 718 } |
| 717 | 719 |
| 718 HInstruction receiver = node.getDartReceiver(compiler); | 720 HInstruction receiver = node.getDartReceiver(compiler); |
| 719 Element field = findConcreteFieldForDynamicAccess(receiver, node.selector); | 721 Element field = findConcreteFieldForDynamicAccess(receiver, node.selector); |
| 720 if (field == null || !field.isAssignable()) return node; | 722 if (field == null || !field.isAssignable()) return node; |
| 721 // Use [:node.inputs.last:] in case the call follows the | 723 // Use [:node.inputs.last:] in case the call follows the |
| 722 // interceptor calling convention, but is not a call on an | 724 // interceptor calling convention, but is not a call on an |
| 723 // interceptor. | 725 // interceptor. |
| 724 HInstruction value = node.inputs.last; | 726 HInstruction value = node.inputs.last; |
| 725 if (compiler.enableTypeAssertions) { | 727 if (compiler.enableTypeAssertions) { |
| 728 DartType type = field.computeType(compiler); |
| 729 if (!type.isRaw || type.kind == TypeKind.TYPE_VARIABLE) { |
| 730 // We cannot generate the correct type representation here, so don't |
| 731 // inline this access. |
| 732 return node; |
| 733 } |
| 726 HInstruction other = value.convertType( | 734 HInstruction other = value.convertType( |
| 727 compiler, | 735 compiler, |
| 728 field.computeType(compiler), | 736 type, |
| 729 HTypeConversion.CHECKED_MODE_CHECK); | 737 HTypeConversion.CHECKED_MODE_CHECK); |
| 730 if (other != value) { | 738 if (other != value) { |
| 731 node.block.addBefore(node, other); | 739 node.block.addBefore(node, other); |
| 732 value = other; | 740 value = other; |
| 733 } | 741 } |
| 734 } | 742 } |
| 735 return new HFieldSet(field, receiver, value); | 743 return new HFieldSet(field, receiver, value); |
| 736 } | 744 } |
| 737 | 745 |
| 738 HInstruction visitStringConcat(HStringConcat node) { | 746 HInstruction visitStringConcat(HStringConcat node) { |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 HBasicBlock block = user.block; | 1714 HBasicBlock block = user.block; |
| 1707 block.addAfter(user, interceptor); | 1715 block.addAfter(user, interceptor); |
| 1708 block.rewrite(user, interceptor); | 1716 block.rewrite(user, interceptor); |
| 1709 block.remove(user); | 1717 block.remove(user); |
| 1710 | 1718 |
| 1711 // The interceptor will be removed in the dead code elimination | 1719 // The interceptor will be removed in the dead code elimination |
| 1712 // phase. Note that removing it here would not work because of how | 1720 // phase. Note that removing it here would not work because of how |
| 1713 // the [visitBasicBlock] is implemented. | 1721 // the [visitBasicBlock] is implemented. |
| 1714 } | 1722 } |
| 1715 } | 1723 } |
| OLD | NEW |