Chromium Code Reviews| Index: runtime/vm/flow_graph_builder.cc |
| diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc |
| index dec84c86ee96261f304569a9f962ded762c3bc13..cb6eed88aef19d05f93f8eb6afa0383d3277a404 100644 |
| --- a/runtime/vm/flow_graph_builder.cc |
| +++ b/runtime/vm/flow_graph_builder.cc |
| @@ -2259,11 +2259,21 @@ void FlowGraphBuilder::BuildGraph(bool for_optimized, bool use_ssa) { |
| GrowableArray<intptr_t> parent; |
| GrowableArray<BitVector*> assigned_vars; |
| - const intptr_t fixed_parameter_count = |
| - parsed_function_.function().num_fixed_parameters(); |
| - const intptr_t variable_count = fixed_parameter_count + |
| - parsed_function_.copied_parameter_count() + |
| - parsed_function_.stack_local_count(); |
| + // Either all parameters are fixed or (ie, one is named) they are all copied. |
|
Florian Schneider
2012/08/02 14:44:39
s/one/none/
Florian Schneider
2012/08/02 14:45:59
Actually I'd write:
Either all parameters are fix
zerny-google
2012/08/02 14:50:35
Done.
|
| + // This could change, so we keep fixed/named counts separate. |
| + intptr_t fixed_parameter_count; |
| + intptr_t named_parameter_count; |
| + if (parsed_function_.copied_parameter_count() > 0) { |
| + fixed_parameter_count = 0; |
| + named_parameter_count = parsed_function_.copied_parameter_count(); |
| + } else { |
| + fixed_parameter_count = parsed_function_.function().num_fixed_parameters(); |
| + named_parameter_count = 0; |
| + } |
| + const intptr_t stack_local_count = parsed_function_.stack_local_count(); |
| + const intptr_t variable_count = |
| + stack_local_count + fixed_parameter_count + named_parameter_count; |
| + |
| // Perform a depth-first traversal of the graph to build preorder and |
| // postorder block orders. |
| graph_entry_->DiscoverBlocks(NULL, // Entry block predecessor. |
| @@ -2299,7 +2309,7 @@ void FlowGraphBuilder::BuildGraph(bool for_optimized, bool use_ssa) { |
| assigned_vars, |
| variable_count, |
| dominance_frontier); |
| - Rename(variable_count); |
| + Rename(stack_local_count, fixed_parameter_count, named_parameter_count); |
| } |
| if (FLAG_print_flow_graph || (Dart::flow_graph_writer() != NULL)) { |
| intptr_t length = postorder_block_entries_.length(); |
| @@ -2501,26 +2511,24 @@ void FlowGraphBuilder::InsertPhis( |
| } |
| -void FlowGraphBuilder::Rename(intptr_t var_count) { |
| - // TODO(fschneider): Store var_count in the FlowGraphBuilder instead of |
| +void FlowGraphBuilder::Rename(intptr_t stack_local_count, |
| + intptr_t fixed_parameter_count, |
| + intptr_t named_parameter_count) { |
| + // TODO(fschneider): Store counts in the FlowGraphBuilder instead of |
| // passing it around. |
| // TODO(fschneider): Support catch-entry. |
| if (graph_entry_->SuccessorCount() > 1) { |
| Bailout("Catch-entry support in SSA."); |
| } |
| - // TODO(fschneider): Support copied parameters. |
| - if (parsed_function().copied_parameter_count() != 0) { |
| - Bailout("Copied parameter support in SSA"); |
| - } |
| - ASSERT(var_count == (parsed_function().stack_local_count() + |
| - parsed_function().function().num_fixed_parameters())); |
| + |
| + const intptr_t parameter_count = |
| + named_parameter_count + fixed_parameter_count; |
| + const intptr_t variable_count = parameter_count + stack_local_count; |
| // Initialize start environment. |
| - GrowableArray<Value*> start_env(var_count); |
| + GrowableArray<Value*> start_env(variable_count); |
| intptr_t i = 0; |
| - const intptr_t fixed_parameter_count = |
| - parsed_function().function().num_fixed_parameters(); |
| - for (; i < fixed_parameter_count; ++i) { |
| + for (; i < parameter_count; ++i) { |
| ParameterInstr* param = new ParameterInstr(i); |
| param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
| start_env.Add(new UseVal(param)); |
| @@ -2528,7 +2536,7 @@ void FlowGraphBuilder::Rename(intptr_t var_count) { |
| // All locals are initialized with #null. |
| Value* null_value = new ConstantVal(Object::ZoneHandle()); |
| - for (; i < var_count; i++) { |
| + for (; i < variable_count; i++) { |
| start_env.Add(null_value); |
| } |
| graph_entry_->set_start_env( |
| @@ -2536,9 +2544,9 @@ void FlowGraphBuilder::Rename(intptr_t var_count) { |
| BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0); |
| ASSERT(normal_entry != NULL); // Must have entry. |
| - GrowableArray<Value*> env(var_count); |
| + GrowableArray<Value*> env(variable_count); |
| env.AddArray(start_env); |
| - RenameRecursive(normal_entry, &env, var_count, fixed_parameter_count); |
| + RenameRecursive(normal_entry, &env, variable_count, fixed_parameter_count); |
| } |