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