Chromium Code Reviews| Index: runtime/vm/flow_graph.cc |
| diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc |
| index 90cbd1e90730f1c9932c0b6db18b02e3e42c6930..9f2abd0067f31a14c83316fd36f8e354255b2fa1 100644 |
| --- a/runtime/vm/flow_graph.cc |
| +++ b/runtime/vm/flow_graph.cc |
| @@ -103,11 +103,15 @@ static void ResetUseListsInInstruction(Instruction* instr) { |
| bool FlowGraph::ResetUseLists() { |
| + // Reset global constants. |
| + ResetUseListsInInstruction(graph_entry_->constant_null()); |
| + |
| // Reset definitions referenced from the start environment. |
| for (intptr_t i = 0; i < graph_entry_->start_env()->values().length(); ++i) { |
| UseVal* env_use = graph_entry_->start_env()->values()[i]->AsUse(); |
| if (env_use != NULL) ResetUseListsInInstruction(env_use->definition()); |
| } |
| + |
| // Reset phis in join entries and the instructions in each block. |
| for (intptr_t i = 0; i < preorder_.length(); ++i) { |
| BlockEntryInstr* entry = preorder_[i]; |
| @@ -163,11 +167,15 @@ static void ValidateUseListsInInstruction(Instruction* instr) { |
| bool FlowGraph::ValidateUseLists() { |
| + // Validate global constants. |
| + ValidateUseListsInInstruction(graph_entry_->constant_null()); |
| + |
| // Validate definitions referenced from the start environment. |
| for (intptr_t i = 0; i < graph_entry_->start_env()->values().length(); ++i) { |
| UseVal* env_use = graph_entry_->start_env()->values()[i]->AsUse(); |
| if (env_use != NULL) ValidateUseListsInInstruction(env_use->definition()); |
| } |
| + |
| // Validate phis in join entries and the instructions in each block. |
| for (intptr_t i = 0; i < preorder_.length(); ++i) { |
| BlockEntryInstr* entry = preorder_[i]; |
| @@ -482,6 +490,9 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) { |
| Bailout("Catch-entry support in SSA."); |
| } |
| + // Name global constants. |
| + graph_entry_->constant_null()->set_ssa_temp_index(alloc_ssa_temp_index()); |
| + |
| // Initialize start environment. |
| GrowableArray<Definition*> start_env(variable_count()); |
| for (intptr_t i = 0; i < parameter_count(); ++i) { |
| @@ -490,14 +501,10 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) { |
| start_env.Add(param); |
| } |
| - // All locals are initialized with #null. |
| - Definition* null_defn = |
| - new BindInstr(BindInstr::kUsed, |
| - new MaterializeComp(new ConstantVal(Object::ZoneHandle()))); |
| - // The null definition should not appear in input positions. |
| - ASSERT(null_defn->ssa_temp_index() == -1); |
| + // All locals are initialized with #null. Use the global definition, uses |
| + // will be created in the Environment constructor. |
| while (start_env.length() < variable_count()) { |
| - start_env.Add(null_defn); |
| + start_env.Add(graph_entry_->constant_null()); |
|
Kevin Millikin (Google)
2012/08/29 09:56:00
This is a bit dodgy, because there are now multipl
|
| } |
| graph_entry_->set_start_env( |
| new Environment(start_env, non_copied_parameter_count_)); |
| @@ -510,16 +517,6 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) { |
| } |
| -// Helper to either use the constant value of a definition or the definition. |
| -static Value* UseDefinition(Definition* defn) { |
| - if (defn->IsBind() && defn->AsBind()->computation()->IsMaterialize()) { |
| - return defn->AsBind()->computation()->AsMaterialize()->constant_val(); |
| - } else { |
| - return new UseVal(defn); |
| - } |
| -} |
| - |
| - |
| void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
| GrowableArray<Definition*>* env, |
| GrowableArray<PhiInstr*>* live_phis) { |
| @@ -646,7 +643,7 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
| PhiInstr* phi = (*successor->phis())[i]; |
| if (phi != NULL) { |
| // Rename input operand. |
| - phi->SetInputAt(pred_index, UseDefinition((*env)[i])); |
| + phi->SetInputAt(pred_index, new UseVal((*env)[i])); |
| } |
| } |
| } |