| 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 return node; | 660 return node; |
| 661 } | 661 } |
| 662 | 662 |
| 663 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) { | 663 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) { |
| 664 if (node.isInterceptedCall) { | 664 if (node.isInterceptedCall) { |
| 665 HInstruction folded = handleInterceptedCall(node); | 665 HInstruction folded = handleInterceptedCall(node); |
| 666 if (folded != node) return folded; | 666 if (folded != node) return folded; |
| 667 } | 667 } |
| 668 HInstruction receiver = node.getDartReceiver(compiler); | 668 HInstruction receiver = node.getDartReceiver(compiler); |
| 669 Element field = findConcreteFieldForDynamicAccess(receiver, node.selector); | 669 Element field = findConcreteFieldForDynamicAccess(receiver, node.selector); |
| 670 if (field == null) return node; | 670 if (field != null) return directFieldGet(receiver, field); |
| 671 return directFieldGet(receiver, field); | 671 Selector selector = node.selector; |
| 672 if (node.dependsOnSomething() |
| 673 && compiler.resolverWorld.onlyReachesFinalFields(selector, compiler)) { |
| 674 // If we know all potential targets are final fields, or fields |
| 675 // that are never assigned twice, we know this getter does not |
| 676 // depend on anything. |
| 677 node.clearAllDependencies(); |
| 678 } |
| 679 return node; |
| 672 } | 680 } |
| 673 | 681 |
| 674 HInstruction directFieldGet(HInstruction receiver, Element field) { | 682 HInstruction directFieldGet(HInstruction receiver, Element field) { |
| 675 Modifiers modifiers = field.modifiers; | 683 Modifiers modifiers = field.modifiers; |
| 676 bool isAssignable = !(modifiers.isFinal() || modifiers.isConst()); | 684 bool isAssignable = !(modifiers.isFinal() || modifiers.isConst()); |
| 677 if (!compiler.resolverWorld.hasInvokedSetter(field, compiler)) { | 685 if (!compiler.resolverWorld.hasInvokedSetter(field, compiler)) { |
| 678 // If no setter is ever used for this field it is only initialized in the | 686 // If no setter is ever used for this field it is only initialized in the |
| 679 // initializer list. | 687 // initializer list. |
| 680 isAssignable = false; | 688 isAssignable = false; |
| 681 } | 689 } |
| (...skipping 1024 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 |