Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1093)

Unified Diff: runtime/vm/flow_graph_allocator.cc

Issue 10857016: Refactored FlowGraphBuilder into a separate FlowGraph representation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revision based on Kevin's review. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_allocator.h ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9bfdbf0061f0d2084e7f200625daee6249cb8ae2 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(const FlowGraph& flow_graph)
+ : flow_graph_(flow_graph),
+ block_order_(flow_graph.reverse_postorder()),
+ 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,18 @@ void FlowGraphAllocator::BuildLiveRanges() {
range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos());
range->DefineAt(graph_entry->start_pos());
+ // Assert that copied and non-copied parameters are mutually exclusive.
+ // This might change in the future and, if so, the index will be wrong.
+ ASSERT(flow_graph_.copied_parameter_count() == 0 ||
+ 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 +543,9 @@ void FlowGraphAllocator::BuildLiveRanges() {
AddToUnallocated(tail);
}
ConvertAllUses(range);
- if (copied) MarkAsObjectAtSafepoints(range);
+ if (flow_graph_.copied_parameter_count() > 0) {
+ MarkAsObjectAtSafepoints(range);
+ }
}
}
}
@@ -746,7 +743,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 +1999,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());
@@ -2011,7 +2008,7 @@ void FlowGraphAllocator::AllocateRegisters() {
OS::Print("-- [before ssa allocator] ir [%s] -------------\n",
function.ToFullyQualifiedCString());
- FlowGraphPrinter printer(Function::Handle(), block_order_, true);
+ FlowGraphPrinter printer(flow_graph_, true);
printer.PrintBlocks();
OS::Print("----------------------------------------------\n");
}
@@ -2025,7 +2022,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());
@@ -2034,7 +2031,7 @@ void FlowGraphAllocator::AllocateRegisters() {
OS::Print("-- [after ssa allocator] ir [%s] -------------\n",
function.ToFullyQualifiedCString());
- FlowGraphPrinter printer(Function::Handle(), block_order_, true);
+ FlowGraphPrinter printer(flow_graph_, true);
printer.PrintBlocks();
OS::Print("----------------------------------------------\n");
}
« no previous file with comments | « runtime/vm/flow_graph_allocator.h ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698