| 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 } | 672 } |
| 673 | 673 |
| 674 void visitIndex(HIndex node) { | 674 void visitIndex(HIndex node) { |
| 675 if (!node.receiver.isIndexablePrimitive()) return; | 675 if (!node.receiver.isIndexablePrimitive()) return; |
| 676 HInstruction index = node.index; | 676 HInstruction index = node.index; |
| 677 if (index is HBoundsCheck) return; | 677 if (index is HBoundsCheck) return; |
| 678 if (!node.index.isInteger()) { | 678 if (!node.index.isInteger()) { |
| 679 index = insertIntegerCheck(node, index); | 679 index = insertIntegerCheck(node, index); |
| 680 } | 680 } |
| 681 index = insertBoundsCheck(node, node.receiver, index); | 681 index = insertBoundsCheck(node, node.receiver, index); |
| 682 HIndex newInstruction = new HIndex(node.target, node.receiver, index); | 682 node.changeUse(node.index, index); |
| 683 node.block.addBefore(node, newInstruction); | |
| 684 node.block.rewrite(node, newInstruction); | |
| 685 node.block.remove(node); | |
| 686 } | 683 } |
| 687 | 684 |
| 688 void visitIndexAssign(HIndexAssign node) { | 685 void visitIndexAssign(HIndexAssign node) { |
| 689 if (!node.receiver.isMutableArray()) return; | 686 if (!node.receiver.isMutableArray()) return; |
| 690 HInstruction index = node.index; | 687 HInstruction index = node.index; |
| 691 if (index is HBoundsCheck) return; | 688 if (index is HBoundsCheck) return; |
| 692 if (!node.index.isInteger()) { | 689 if (!node.index.isInteger()) { |
| 693 index = insertIntegerCheck(node, index); | 690 index = insertIntegerCheck(node, index); |
| 694 } | 691 } |
| 695 index = insertBoundsCheck(node, node.receiver, index); | 692 index = insertBoundsCheck(node, node.receiver, index); |
| 696 HIndexAssign newInstruction = | 693 node.changeUse(node.index, index); |
| 697 new HIndexAssign(node.target, node.receiver, index, node.value); | |
| 698 node.block.addBefore(node, newInstruction); | |
| 699 node.block.rewrite(node, newInstruction); | |
| 700 node.block.remove(node); | |
| 701 } | 694 } |
| 702 } | 695 } |
| 703 | 696 |
| 704 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { | 697 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { |
| 705 final String name = "SsaDeadCodeEliminator"; | 698 final String name = "SsaDeadCodeEliminator"; |
| 706 | 699 |
| 707 static bool isDeadCode(HInstruction instruction) { | 700 static bool isDeadCode(HInstruction instruction) { |
| 708 return !instruction.hasSideEffects() | 701 return !instruction.hasSideEffects() |
| 709 && instruction.usedBy.isEmpty() | 702 && instruction.usedBy.isEmpty() |
| 710 && instruction is !HCheck | 703 && instruction is !HCheck |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 // this type for the field is still a strong signal | 1299 // this type for the field is still a strong signal |
| 1307 // indicating the expected type of the field. | 1300 // indicating the expected type of the field. |
| 1308 field.propagatedType = type; | 1301 field.propagatedType = type; |
| 1309 } else { | 1302 } else { |
| 1310 // If there are no invoked setters we know the type of | 1303 // If there are no invoked setters we know the type of |
| 1311 // this field for sure. | 1304 // this field for sure. |
| 1312 field.guaranteedType = type; | 1305 field.guaranteedType = type; |
| 1313 } | 1306 } |
| 1314 } | 1307 } |
| 1315 } | 1308 } |
| OLD | NEW |