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 HLoopInformation info = block.blockInformation; | 482 HBasicBlock last = block.loopInformation.getLastBackEdge(); |
483 HBasicBlock last = info.getLastBackEdge(); | |
484 for (int j = block.id; j <= last.id; j++) { | 483 for (int j = block.id; j <= last.id; j++) { |
485 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); | 484 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); |
486 } | 485 } |
487 } | 486 } |
488 } | 487 } |
489 } | 488 } |
490 | 489 |
491 void moveLoopInvariantCodeFromBlock(HBasicBlock block, | 490 void moveLoopInvariantCodeFromBlock(HBasicBlock block, |
492 HBasicBlock loopHeader, | 491 HBasicBlock loopHeader, |
493 int changesFlags) { | 492 int changesFlags) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 712 } |
714 } | 713 } |
715 if (!canBeMoved) continue; | 714 if (!canBeMoved) continue; |
716 | 715 |
717 // This is safe because we are running after GVN. | 716 // This is safe because we are running after GVN. |
718 // TODO(ngeoffray): ensure GVN has been run. | 717 // TODO(ngeoffray): ensure GVN has been run. |
719 set_.add(current); | 718 set_.add(current); |
720 } | 719 } |
721 } | 720 } |
722 } | 721 } |
OLD | NEW |