| 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 interface OptimizationPhase { | 5 interface OptimizationPhase { |
| 6 String get name; | 6 String get name; |
| 7 void visitGraph(HGraph graph); | 7 void visitGraph(HGraph graph); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class SsaOptimizerTask extends CompilerTask { | 10 class SsaOptimizerTask extends CompilerTask { |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 HBoundsCheck insertBoundsCheck(HInstruction node, | 690 HBoundsCheck insertBoundsCheck(HInstruction node, |
| 691 HInstruction receiver, | 691 HInstruction receiver, |
| 692 HInstruction index) { | 692 HInstruction index) { |
| 693 HStatic interceptor = new HStatic(lengthInterceptor); | 693 HStatic interceptor = new HStatic(lengthInterceptor); |
| 694 node.block.addBefore(node, interceptor); | 694 node.block.addBefore(node, interceptor); |
| 695 Selector selector = new Selector.getter( | 695 Selector selector = new Selector.getter( |
| 696 const SourceString('length'), | 696 const SourceString('length'), |
| 697 lengthInterceptor.getLibrary()); // TODO(kasperl): Wrong. | 697 lengthInterceptor.getLibrary()); // TODO(kasperl): Wrong. |
| 698 HInvokeInterceptor length = new HInvokeInterceptor( | 698 HInvokeInterceptor length = new HInvokeInterceptor( |
| 699 selector, <HInstruction>[interceptor, receiver]); | 699 selector, <HInstruction>[interceptor, receiver], true); |
| 700 types[length] = HType.INTEGER; | 700 types[length] = HType.INTEGER; |
| 701 node.block.addBefore(node, length); | 701 node.block.addBefore(node, length); |
| 702 | 702 |
| 703 HBoundsCheck check = new HBoundsCheck(index, length); | 703 HBoundsCheck check = new HBoundsCheck(index, length); |
| 704 node.block.addBefore(node, check); | 704 node.block.addBefore(node, check); |
| 705 boundsChecked.add(node); | 705 boundsChecked.add(node); |
| 706 return check; | 706 return check; |
| 707 } | 707 } |
| 708 | 708 |
| 709 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { | 709 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 748 |
| 749 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { | 749 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { |
| 750 final HTypeMap types; | 750 final HTypeMap types; |
| 751 final String name = "SsaDeadCodeEliminator"; | 751 final String name = "SsaDeadCodeEliminator"; |
| 752 | 752 |
| 753 SsaDeadCodeEliminator(this.types); | 753 SsaDeadCodeEliminator(this.types); |
| 754 | 754 |
| 755 bool isDeadCode(HInstruction instruction) { | 755 bool isDeadCode(HInstruction instruction) { |
| 756 return !instruction.hasSideEffects(types) | 756 return !instruction.hasSideEffects(types) |
| 757 && instruction.usedBy.isEmpty() | 757 && instruction.usedBy.isEmpty() |
| 758 // A dynamic getter that has no side effect can still throw |
| 759 // a NoSuchMethodError or a NullPointerException. |
| 760 && instruction is !HInvokeDynamicGetter |
| 758 && instruction is !HCheck | 761 && instruction is !HCheck |
| 759 && instruction is !HTypeGuard | 762 && instruction is !HTypeGuard |
| 760 && !instruction.isControlFlow(); | 763 && !instruction.isControlFlow(); |
| 761 } | 764 } |
| 762 | 765 |
| 763 void visitGraph(HGraph graph) { | 766 void visitGraph(HGraph graph) { |
| 764 visitPostDominatorTree(graph); | 767 visitPostDominatorTree(graph); |
| 765 } | 768 } |
| 766 | 769 |
| 767 void visitBasicBlock(HBasicBlock block) { | 770 void visitBasicBlock(HBasicBlock block) { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 // this type for the field is still a strong signal | 1366 // this type for the field is still a strong signal |
| 1364 // indicating the expected type of the field. | 1367 // indicating the expected type of the field. |
| 1365 types[field] = type; | 1368 types[field] = type; |
| 1366 } else { | 1369 } else { |
| 1367 // If there are no invoked setters we know the type of | 1370 // If there are no invoked setters we know the type of |
| 1368 // this field for sure. | 1371 // this field for sure. |
| 1369 field.guaranteedType = type; | 1372 field.guaranteedType = type; |
| 1370 } | 1373 } |
| 1371 } | 1374 } |
| 1372 } | 1375 } |
| OLD | NEW |