| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 computeChangesFlags(graph); | 472 computeChangesFlags(graph); |
| 473 moveLoopInvariantCode(graph); | 473 moveLoopInvariantCode(graph); |
| 474 visitBasicBlock(graph.entry, new ValueSet()); | 474 visitBasicBlock(graph.entry, new ValueSet()); |
| 475 } | 475 } |
| 476 | 476 |
| 477 void moveLoopInvariantCode(HGraph graph) { | 477 void moveLoopInvariantCode(HGraph graph) { |
| 478 for (int i = graph.blocks.length - 1; i >= 0; i--) { | 478 for (int i = graph.blocks.length - 1; i >= 0; i--) { |
| 479 HBasicBlock block = graph.blocks[i]; | 479 HBasicBlock block = graph.blocks[i]; |
| 480 if (block.isLoopHeader()) { | 480 if (block.isLoopHeader()) { |
| 481 int changesFlags = loopChangesFlags[block.id]; | 481 int changesFlags = loopChangesFlags[block.id]; |
| 482 HBasicBlock last = block.loopInformation.getLastBackEdge(); | 482 HLoopInformation info = block.blockInformation; |
| 483 HBasicBlock last = info.getLastBackEdge(); |
| 483 for (int j = block.id; j <= last.id; j++) { | 484 for (int j = block.id; j <= last.id; j++) { |
| 484 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); | 485 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); |
| 485 } | 486 } |
| 486 } | 487 } |
| 487 } | 488 } |
| 488 } | 489 } |
| 489 | 490 |
| 490 void moveLoopInvariantCodeFromBlock(HBasicBlock block, | 491 void moveLoopInvariantCodeFromBlock(HBasicBlock block, |
| 491 HBasicBlock loopHeader, | 492 HBasicBlock loopHeader, |
| 492 int changesFlags) { | 493 int changesFlags) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 } | 713 } |
| 713 } | 714 } |
| 714 if (!canBeMoved) continue; | 715 if (!canBeMoved) continue; |
| 715 | 716 |
| 716 // This is safe because we are running after GVN. | 717 // This is safe because we are running after GVN. |
| 717 // TODO(ngeoffray): ensure GVN has been run. | 718 // TODO(ngeoffray): ensure GVN has been run. |
| 718 set_.add(current); | 719 set_.add(current); |
| 719 } | 720 } |
| 720 } | 721 } |
| 721 } | 722 } |
| OLD | NEW |