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

Unified Diff: runtime/vm/flow_graph_allocator.cc

Issue 10939031: Replace start_env with initial_definitions in GraphEntryInstr. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
Index: runtime/vm/flow_graph_allocator.cc
diff --git a/runtime/vm/flow_graph_allocator.cc b/runtime/vm/flow_graph_allocator.cc
index 458533da7dbbf09aeab10563cade4a58d56228e1..48dbc8fae74e6c2a0e226d43758b49bd41d8efaa 100644
--- a/runtime/vm/flow_graph_allocator.cc
+++ b/runtime/vm/flow_graph_allocator.cc
@@ -187,20 +187,14 @@ void FlowGraphAllocator::ComputeInitialSets() {
}
}
- // Process incoming parameters.
- GraphEntryInstr* graph_entry = postorder_.Last()->AsGraphEntry();
- for (intptr_t i = 0; i < graph_entry->start_env()->Length(); i++) {
- Value* val = graph_entry->start_env()->ValueAt(i);
- intptr_t vreg = val->definition()->ssa_temp_index();
+ // Process initial definitions, ie, constants and incoming parameters.
+ GraphEntryInstr* graph_entry = flow_graph_.graph_entry();
+ for (intptr_t i = 0; i < graph_entry->initial_definitions().length(); i++) {
+ intptr_t vreg = graph_entry->initial_definitions()[i]->ssa_temp_index();
kill_[graph_entry->postorder_number()]->Add(vreg);
live_in_[graph_entry->postorder_number()]->Remove(vreg);
}
- // Process global constants.
- intptr_t vreg = graph_entry->constant_null()->ssa_temp_index();
- kill_[graph_entry->postorder_number()]->Add(vreg);
- live_in_[graph_entry->postorder_number()]->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++) {
@@ -520,37 +514,37 @@ void FlowGraphAllocator::BuildLiveRanges() {
ConnectIncomingPhiMoves(block);
}
- // Process incoming parameters. Do this after all other instructions so
- // that safepoints for all calls have already been found.
- GraphEntryInstr* graph_entry = postorder_.Last()->AsGraphEntry();
- for (intptr_t i = 0; i < graph_entry->start_env()->Length(); i++) {
- Value* val = graph_entry->start_env()->ValueAt(i);
- ParameterInstr* param = val->definition()->AsParameter();
- if (param == NULL) continue;
-
- // Handle the parameters specially. They are spilled on entry.
- LiveRange* range = GetLiveRange(param->ssa_temp_index());
+ // Process incoming parameters and constants. Do this after all other
+ // instructions so that safepoints for all calls have already been found.
+ GraphEntryInstr* graph_entry = flow_graph_.graph_entry();
+ for (intptr_t i = 0; i < graph_entry->initial_definitions().length(); i++) {
+ Definition* defn = graph_entry->initial_definitions()[i];
+ LiveRange* range = GetLiveRange(defn->ssa_temp_index());
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_.num_copied_params() == 0) ||
- (flow_graph_.num_non_copied_params() == 0));
- // Slot index for the leftmost copied parameter is 0.
- intptr_t slot_index = param->index();
- // Slot index for the rightmost fixed parameter is -1.
- slot_index -= flow_graph_.num_non_copied_params();
-
- range->set_assigned_location(Location::StackSlot(slot_index));
- range->set_spill_slot(Location::StackSlot(slot_index));
- if (flow_graph_.num_copied_params() > 0) {
- ASSERT(spill_slots_.length() == slot_index);
- spill_slots_.Add(range->End());
+ if (defn->IsParameter()) {
+ ParameterInstr* param = defn->AsParameter();
+ // 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_.num_copied_params() == 0) ||
+ (flow_graph_.num_non_copied_params() == 0));
+ // Slot index for the leftmost copied parameter is 0.
+ intptr_t slot_index = param->index();
+ // Slot index for the rightmost fixed parameter is -1.
+ slot_index -= flow_graph_.num_non_copied_params();
+
+ range->set_assigned_location(Location::StackSlot(slot_index));
+ range->set_spill_slot(Location::StackSlot(slot_index));
+ if (flow_graph_.num_copied_params() > 0) {
+ ASSERT(spill_slots_.length() == slot_index);
+ spill_slots_.Add(range->End());
+ }
+ AssignSafepoints(range);
+ } else if (defn->IsConstant()) {
+ ConstantInstr* constant = defn->AsConstant();
+ range->set_assigned_location(Location::Constant(constant->value()));
+ range->set_spill_slot(Location::Constant(constant->value()));
}
Kevin Millikin (Google) 2012/09/19 11:49:29 } else { UNREACHABLE(); }
zerny-google 2012/09/19 12:15:05 Done.
-
- AssignSafepoints(range);
-
range->finger()->Initialize(range);
UsePosition* use =
range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos());
@@ -561,26 +555,11 @@ void FlowGraphAllocator::BuildLiveRanges() {
CompleteRange(tail, Location::kRegister);
}
ConvertAllUses(range);
- if (flow_graph_.num_copied_params() > 0) {
+
+ if (defn->IsParameter() && flow_graph_.num_copied_params() > 0) {
MarkAsObjectAtSafepoints(range);
}
}
-
- // Process global constants.
- ConstantInstr* null_defn = graph_entry->constant_null();
- LiveRange* range = GetLiveRange(null_defn->ssa_temp_index());
- range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos());
- range->DefineAt(graph_entry->start_pos());
- range->set_assigned_location(Location::Constant(null_defn->value()));
- range->set_spill_slot(Location::Constant(null_defn->value()));
- 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());
- CompleteRange(tail, Location::kRegister);
- }
- ConvertAllUses(range);
}

Powered by Google App Engine
This is Rietveld 408576698