| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 * If both inputs to known operations are available execute the operation at | 71 * If both inputs to known operations are available execute the operation at |
| 72 * compile-time. | 72 * compile-time. |
| 73 */ | 73 */ |
| 74 class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase { | 74 class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase { |
| 75 final String name = "SsaConstantFolder"; | 75 final String name = "SsaConstantFolder"; |
| 76 final Compiler compiler; | 76 final Compiler compiler; |
| 77 HGraph graph; | 77 HGraph graph; |
| 78 | 78 |
| 79 SsaConstantFolder(this.compiler); | 79 SsaConstantFolder(this.compiler); |
| 80 | 80 |
| 81 void visitGraph(HGraph graph) { | 81 void visitGraph(HGraph visitee) { |
| 82 this.graph = graph; | 82 graph = visitee; |
| 83 visitDominatorTree(graph); | 83 visitDominatorTree(visitee); |
| 84 } | 84 } |
| 85 | 85 |
| 86 visitBasicBlock(HBasicBlock block) { | 86 visitBasicBlock(HBasicBlock block) { |
| 87 HInstruction instruction = block.first; | 87 HInstruction instruction = block.first; |
| 88 while (instruction !== null) { | 88 while (instruction !== null) { |
| 89 HInstruction next = instruction.next; | 89 HInstruction next = instruction.next; |
| 90 HInstruction replacement = instruction.accept(this); | 90 HInstruction replacement = instruction.accept(this); |
| 91 if (replacement !== instruction) { | 91 if (replacement !== instruction) { |
| 92 if (!replacement.isInBasicBlock()) { | 92 if (!replacement.isInBasicBlock()) { |
| 93 // The constant folding can return an instruction that is already | 93 // The constant folding can return an instruction that is already |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 if (!canBeMoved) continue; | 714 if (!canBeMoved) continue; |
| 715 | 715 |
| 716 // This is safe because we are running after GVN. | 716 // This is safe because we are running after GVN. |
| 717 // TODO(ngeoffray): ensure GVN has been run. | 717 // TODO(ngeoffray): ensure GVN has been run. |
| 718 set_.add(current); | 718 set_.add(current); |
| 719 } | 719 } |
| 720 } | 720 } |
| 721 } | 721 } |
| OLD | NEW |