Chromium Code Reviews| Index: runtime/vm/flow_graph_allocator.cc |
| diff --git a/runtime/vm/flow_graph_allocator.cc b/runtime/vm/flow_graph_allocator.cc |
| index 8b0dd6453901b3bef73ee1b6a864db1bdfb7941d..c3cef1bcaa44cdf94696f0db1b764556e3932699 100644 |
| --- a/runtime/vm/flow_graph_allocator.cc |
| +++ b/runtime/vm/flow_graph_allocator.cc |
| @@ -7,7 +7,7 @@ |
| #include "vm/bit_vector.h" |
| #include "vm/intermediate_language.h" |
| #include "vm/il_printer.h" |
| -#include "vm/flow_graph_builder.h" |
| +#include "vm/flow_graph.h" |
| #include "vm/flow_graph_compiler.h" |
| #include "vm/parser.h" |
| @@ -56,17 +56,15 @@ static intptr_t ToInstructionStart(intptr_t pos) { |
| } |
| -FlowGraphAllocator::FlowGraphAllocator( |
| - const GrowableArray<BlockEntryInstr*>& block_order, |
| - FlowGraphBuilder* builder) |
| - : builder_(builder), |
| - block_order_(block_order), |
| - postorder_(builder->postorder_block_entries()), |
| - live_out_(block_order.length()), |
| - kill_(block_order.length()), |
| - live_in_(block_order.length()), |
| - vreg_count_(builder->current_ssa_temp_index()), |
| - live_ranges_(builder->current_ssa_temp_index()), |
| +FlowGraphAllocator::FlowGraphAllocator(FlowGraph* flow_graph) |
| + : flow_graph_(flow_graph), |
| + block_order_(flow_graph->reverse_postorder()), |
|
Kevin Millikin (Google)
2012/08/16 08:09:57
Instead of reading these fields out of the flow gr
zerny-google
2012/08/16 11:52:27
Postponing to a later CL.
|
| + postorder_(flow_graph->postorder()), |
| + live_out_(block_order_.length()), |
| + kill_(block_order_.length()), |
| + live_in_(block_order_.length()), |
| + vreg_count_(flow_graph->max_virtual_register_number()), |
| + live_ranges_(flow_graph->max_virtual_register_number()), |
| cpu_regs_(), |
| blocked_cpu_regs_() { |
| for (intptr_t i = 0; i < vreg_count_; i++) live_ranges_.Add(NULL); |
| @@ -505,13 +503,8 @@ void FlowGraphAllocator::BuildLiveRanges() { |
| ConnectIncomingPhiMoves(block); |
| } |
| - const bool copied = builder_->copied_parameter_count() > 0; |
| - |
| // Process incoming parameters. Do this after all other instructions so |
| // that safepoints for all calls have already been found. |
| - const intptr_t fixed_parameters_count = |
| - builder_->parsed_function().function().num_fixed_parameters(); |
| - |
| GraphEntryInstr* graph_entry = postorder_[block_count - 1]->AsGraphEntry(); |
| for (intptr_t i = 0; i < graph_entry->start_env()->values().length(); i++) { |
| Value* val = graph_entry->start_env()->values()[i]; |
| @@ -522,16 +515,16 @@ void FlowGraphAllocator::BuildLiveRanges() { |
| range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
| range->DefineAt(graph_entry->start_pos()); |
| + ASSERT(flow_graph_->copied_parameter_count() == 0 || |
|
Kevin Millikin (Google)
2012/08/16 08:09:57
This assert should have a comment explaining it.
zerny-google
2012/08/16 11:52:27
Done.
|
| + flow_graph_->non_copied_parameter_count() == 0); |
| // Slot index for the leftmost copied parameter is 0. |
| intptr_t slot_index = param->index(); |
| - if (!copied) { |
| - // Slot index for the rightmost fixed parameter is -1. |
| - slot_index -= fixed_parameters_count; |
| - } |
| + // Slot index for the rightmost fixed parameter is -1. |
| + slot_index -= flow_graph_->non_copied_parameter_count(); |
| range->set_assigned_location(Location::StackSlot(slot_index)); |
| range->set_spill_slot(Location::StackSlot(slot_index)); |
| - if (copied) { |
| + if (flow_graph_->copied_parameter_count() > 0) { |
| ASSERT(spill_slots_.length() == slot_index); |
| spill_slots_.Add(range->End()); |
| } |
| @@ -548,7 +541,9 @@ void FlowGraphAllocator::BuildLiveRanges() { |
| AddToUnallocated(tail); |
| } |
| ConvertAllUses(range); |
| - if (copied) MarkAsObjectAtSafepoints(range); |
| + if (flow_graph_->copied_parameter_count() > 0) { |
| + MarkAsObjectAtSafepoints(range); |
| + } |
| } |
| } |
| } |
| @@ -746,7 +741,7 @@ void FlowGraphAllocator::ProcessOneInstruction(BlockEntryInstr* block, |
| // TODO(vegorov): number of inputs must match number of input locations. |
| if (locs->input_count() != current->InputCount()) { |
| - builder_->Bailout("ssa allocator: number of input locations mismatch"); |
| + flow_graph_->Bailout("ssa allocator: number of input locations mismatch"); |
| } |
| // Normalize same-as-first-input output if input is specified as |
| @@ -2002,7 +1997,7 @@ void FlowGraphAllocator::AllocateRegisters() { |
| } |
| if (FLAG_print_ssa_liveranges) { |
| - const Function& function = builder_->parsed_function().function(); |
| + const Function& function = flow_graph_->parsed_function().function(); |
| OS::Print("-- [before ssa allocator] ranges [%s] ---------\n", |
| function.ToFullyQualifiedCString()); |
| @@ -2025,7 +2020,7 @@ void FlowGraphAllocator::AllocateRegisters() { |
| entry->set_spill_slot_count(spill_slots_.length()); |
| if (FLAG_print_ssa_liveranges) { |
| - const Function& function = builder_->parsed_function().function(); |
| + const Function& function = flow_graph_->parsed_function().function(); |
| OS::Print("-- [after ssa allocator] ranges [%s] ---------\n", |
| function.ToFullyQualifiedCString()); |