| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 computeChangesFlags(graph); | 774 computeChangesFlags(graph); |
| 775 moveLoopInvariantCode(graph); | 775 moveLoopInvariantCode(graph); |
| 776 visitBasicBlock(graph.entry, new ValueSet()); | 776 visitBasicBlock(graph.entry, new ValueSet()); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void moveLoopInvariantCode(HGraph graph) { | 779 void moveLoopInvariantCode(HGraph graph) { |
| 780 for (int i = graph.blocks.length - 1; i >= 0; i--) { | 780 for (int i = graph.blocks.length - 1; i >= 0; i--) { |
| 781 HBasicBlock block = graph.blocks[i]; | 781 HBasicBlock block = graph.blocks[i]; |
| 782 if (block.isLoopHeader()) { | 782 if (block.isLoopHeader()) { |
| 783 int changesFlags = loopChangesFlags[block.id]; | 783 int changesFlags = loopChangesFlags[block.id]; |
| 784 HLoopInformation info = block.blockInformation; | 784 HLoopInformation info = block.loopInformation; |
| 785 HBasicBlock last = info.getLastBackEdge(); | 785 HBasicBlock last = info.getLastBackEdge(); |
| 786 for (int j = block.id; j <= last.id; j++) { | 786 for (int j = block.id; j <= last.id; j++) { |
| 787 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); | 787 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 | 792 |
| 793 void moveLoopInvariantCodeFromBlock(HBasicBlock block, | 793 void moveLoopInvariantCodeFromBlock(HBasicBlock block, |
| 794 HBasicBlock loopHeader, | 794 HBasicBlock loopHeader, |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 // the if block terminates. So any use of the instruction | 1086 // the if block terminates. So any use of the instruction |
| 1087 // after the join block should be changed to the new | 1087 // after the join block should be changed to the new |
| 1088 // instruction. | 1088 // instruction. |
| 1089 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); | 1089 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); |
| 1090 } | 1090 } |
| 1091 // TODO(ngeoffray): Also change uses for the then block on a HType | 1091 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1092 // that knows it is not of a specific Type. | 1092 // that knows it is not of a specific Type. |
| 1093 } | 1093 } |
| 1094 } | 1094 } |
| 1095 } | 1095 } |
| OLD | NEW |