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

Unified Diff: runtime/vm/flow_graph_allocator.cc

Issue 10828018: Add support for fixed parameters in the register allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | runtime/vm/flow_graph_builder.cc » ('J')
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 ec48c20003803d5cb19a44a57421b8dd1584367a..0dae11236cd140eafc208a4b5251cdc425118cc9 100644
--- a/runtime/vm/flow_graph_allocator.cc
+++ b/runtime/vm/flow_graph_allocator.cc
@@ -139,6 +139,17 @@ void FlowGraphAllocator::ComputeInitialSets() {
}
}
+ // Process incomming parameters.
srdjan 2012/07/26 00:33:56 s/incomming/incoming/
Vyacheslav Egorov (Google) 2012/07/26 11:33:53 Done.
+ 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];
+ if (val->IsUse()) {
+ const intptr_t vreg = val->AsUse()->definition()->ssa_temp_index();
+ kill_[0]->Add(vreg);
Kevin Millikin (Google) 2012/07/26 09:29:08 It probably doesn't make a big difference to anyth
Vyacheslav Egorov (Google) 2012/07/26 11:33:53 It does not change anything. I just choose to defi
+ live_in_[0]->Remove(vreg);
+ }
+ }
+
// Update initial live_in sets to match live_out sets. Has to be
// done in a separate path because of backwards branches.
for (intptr_t i = 0; i < block_count; i++) {
@@ -396,6 +407,31 @@ void FlowGraphAllocator::BuildLiveRanges() {
ConnectIncomingPhiMoves(block);
}
+
+ // Process incomming parameters.
srdjan 2012/07/26 00:33:56 ditto
Vyacheslav Egorov (Google) 2012/07/26 11:33:53 Done.
+ 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];
+ if (val->IsUse()) {
+ ParameterInstr* param = val->AsUse()->definition()->AsParameter();
+
+ LiveRange* range = GetLiveRange(param->ssa_temp_index());
+ range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos());
+ range->DefineAt(graph_entry->start_pos());
+ range->set_assigned_location(Location::StackSlot(param->index()));
+
+ range->finger()->Initialize(range);
+ UsePosition* use = range->finger()->FirstRegisterBeneficialUse(
+ graph_entry->start_pos());
+ if (use != NULL) {
+ LiveRange* tail = SplitBetween(range,
+ graph_entry->start_pos(),
+ use->pos());
+ AddToUnallocated(tail);
+ }
+ ConvertAllUses(range);
+ }
+ }
}
//
@@ -547,6 +583,14 @@ void FlowGraphAllocator::ProcessOneInstruction(BlockEntryInstr* block,
builder_->Bailout("ssa allocator: number of input locations mismatch");
}
+ // Normalize same-as-first-input output if input is specified as
+ // fixed register.
+ if (locs->out().IsUnallocated() &&
+ (locs->out().policy() == Location::kSameAsFirstInput) &&
+ (locs->in(0).IsRegister())) {
+ locs->set_out(locs->in(0));
+ }
+
const bool output_same_as_first_input =
locs->out().IsUnallocated() &&
(locs->out().policy() == Location::kSameAsFirstInput);
@@ -1095,9 +1139,9 @@ intptr_t FlowGraphAllocator::AllocateSpillSlotFor(LiveRange* range) {
void FlowGraphAllocator::Spill(LiveRange* range) {
const intptr_t spill_index = AllocateSpillSlotFor(range);
- ASSERT(spill_slots_[spill_index] < range->Start());
+ ASSERT(spill_slots_[spill_index] <= range->Start());
spill_slots_[spill_index] = range->End();
- range->set_assigned_location(Location::SpillSlot(spill_index));
+ range->set_assigned_location(Location::StackSlot(spill_index));
ConvertAllUses(range);
}
@@ -1575,15 +1619,6 @@ void FlowGraphAllocator::ResolveControlFlow() {
void FlowGraphAllocator::AllocateRegisters() {
- GraphEntryInstr* entry = block_order_[0]->AsGraphEntry();
- ASSERT(entry != NULL);
-
- for (intptr_t i = 0; i < entry->start_env()->values().length(); i++) {
- if (entry->start_env()->values()[i]->IsUse()) {
- builder_->Bailout("ssa allocator: unsupported start environment");
- }
- }
-
AnalyzeLiveness();
BuildLiveRanges();
@@ -1600,6 +1635,10 @@ void FlowGraphAllocator::AllocateRegisters() {
ResolveControlFlow();
+ GraphEntryInstr* entry = block_order_[0]->AsGraphEntry();
+ ASSERT(entry != NULL);
+ entry->set_spill_slot_count(spill_slots_.length());
+
if (FLAG_trace_ssa_allocator) {
OS::Print("-- ir after allocation -------------------------\n");
FlowGraphPrinter printer(Function::Handle(), block_order_, true);
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | runtime/vm/flow_graph_builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698