| 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 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 (defn->ssa_temp_index() != -1)) { | 124 (defn->ssa_temp_index() != -1)) { |
| 125 replacement->set_ssa_temp_index(graph->alloc_ssa_temp_index()); | 125 replacement->set_ssa_temp_index(graph->alloc_ssa_temp_index()); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 static void ReplaceCurrentInstruction(ForwardInstructionIterator* it, | 130 static void ReplaceCurrentInstruction(ForwardInstructionIterator* it, |
| 131 Instruction* current, | 131 Instruction* current, |
| 132 Instruction* replacement, | 132 Instruction* replacement, |
| 133 FlowGraph* graph) { | 133 FlowGraph* graph) { |
| 134 if ((replacement != NULL) && current->IsDefinition()) { | 134 Definition* current_defn = current->AsDefinition(); |
| 135 Definition* current_defn = current->AsDefinition(); | 135 if ((replacement != NULL) && (current_defn != NULL)) { |
| 136 Definition* replacement_defn = replacement->AsDefinition(); | 136 Definition* replacement_defn = replacement->AsDefinition(); |
| 137 ASSERT(replacement_defn != NULL); | 137 ASSERT(replacement_defn != NULL); |
| 138 current_defn->ReplaceUsesWith(replacement_defn); | 138 current_defn->ReplaceUsesWith(replacement_defn); |
| 139 EnsureSSATempIndex(graph, current_defn, replacement_defn); | 139 EnsureSSATempIndex(graph, current_defn, replacement_defn); |
| 140 | 140 |
| 141 if (FLAG_trace_optimization) { | 141 if (FLAG_trace_optimization) { |
| 142 OS::Print("Replacing v%"Pd" with v%"Pd"\n", | 142 OS::Print("Replacing v%"Pd" with v%"Pd"\n", |
| 143 current_defn->ssa_temp_index(), | 143 current_defn->ssa_temp_index(), |
| 144 replacement_defn->ssa_temp_index()); | 144 replacement_defn->ssa_temp_index()); |
| 145 } | 145 } |
| 146 } else if (FLAG_trace_optimization) { | 146 } else if (FLAG_trace_optimization) { |
| 147 ASSERT(!current->IsDefinition() || | 147 if (current_defn == NULL) { |
| 148 ((current->AsDefinition()->input_use_list() == NULL) && | 148 OS::Print("Removing %s\n", current->DebugName()); |
| 149 (current->AsDefinition()->env_use_list() == NULL))); | |
| 150 if (current->IsDefinition()) { | |
| 151 OS::Print("Removing v%"Pd".\n", | |
| 152 current->AsDefinition()->ssa_temp_index()); | |
| 153 } else { | 149 } else { |
| 154 OS::Print("Removing %s\n", current->DebugName()); | 150 ASSERT(!current_defn->HasUses()); |
| 151 OS::Print("Removing v%"Pd".\n", current_defn->ssa_temp_index()); |
| 155 } | 152 } |
| 156 } | 153 } |
| 157 it->RemoveCurrentFromGraph(); | 154 it->RemoveCurrentFromGraph(); |
| 158 } | 155 } |
| 159 | 156 |
| 160 | 157 |
| 161 void FlowGraphOptimizer::Canonicalize() { | 158 void FlowGraphOptimizer::Canonicalize() { |
| 162 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 159 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 163 BlockEntryInstr* entry = block_order_[i]; | 160 BlockEntryInstr* entry = block_order_[i]; |
| 164 entry->Accept(this); | 161 entry->Accept(this); |
| (...skipping 4249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4414 | 4411 |
| 4415 if (FLAG_trace_constant_propagation) { | 4412 if (FLAG_trace_constant_propagation) { |
| 4416 OS::Print("\n==== After constant propagation ====\n"); | 4413 OS::Print("\n==== After constant propagation ====\n"); |
| 4417 FlowGraphPrinter printer(*graph_); | 4414 FlowGraphPrinter printer(*graph_); |
| 4418 printer.PrintBlocks(); | 4415 printer.PrintBlocks(); |
| 4419 } | 4416 } |
| 4420 } | 4417 } |
| 4421 | 4418 |
| 4422 | 4419 |
| 4423 } // namespace dart | 4420 } // namespace dart |
| OLD | NEW |