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 e70a5b781eec4f1a248a02ceca48921dbac1fdbe..1e6cd5a6e39b7daa932c8ac62671ebda0d0fec98 100644 |
| --- a/runtime/vm/flow_graph_allocator.cc |
| +++ b/runtime/vm/flow_graph_allocator.cc |
| @@ -631,10 +631,10 @@ void FlowGraphAllocator::SplitInitialDefinitionAt(LiveRange* range, |
| } |
| } |
| +#if defined(TARGET_ARCH_DBC) |
|
Vyacheslav Egorov (Google)
2017/08/13 13:19:23
I think I liked original version of the function t
zra
2017/08/14 19:59:05
I'll defer to Slava here.
|
| void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| LiveRange* range, |
| BlockEntryInstr* block) { |
| -#if defined(TARGET_ARCH_DBC) |
| if (block->IsCatchBlockEntry()) { |
| if (defn->IsParameter()) { |
| // This must be in sync with FlowGraphCompiler::CatchEntryRegForVariable. |
| @@ -666,7 +666,6 @@ void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| } |
| return; |
| } |
| -#endif |
| // Save the range end because it may change below. |
| intptr_t range_end = range->End(); |
| @@ -684,8 +683,6 @@ void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| // Slot index for the rightmost fixed parameter is -1. |
| slot_index -= flow_graph_.num_non_copied_params(); |
| } |
| - |
| -#if defined(TARGET_ARCH_DBC) |
| ASSERT(param->base_reg() == FPREG); |
| if (slot_index >= 0) { |
| AssignSafepoints(defn, range); |
| @@ -695,20 +692,104 @@ void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| ConvertAllUses(range); |
| return; |
| } |
| -#endif // defined(TARGET_ARCH_DBC) |
| range->set_assigned_location( |
| Location::StackSlot(slot_index, param->base_reg())); |
| range->set_spill_slot(Location::StackSlot(slot_index, param->base_reg())); |
| - |
| } else if (defn->IsSpecialParameter()) { |
| SpecialParameterInstr* param = defn->AsSpecialParameter(); |
| if (param->kind() == SpecialParameterInstr::kContext) { |
| -#if !defined(TARGET_ARCH_DBC) |
| - const Register context_reg = CTX; |
| + intptr_t context_reg = flow_graph_.num_copied_params(); |
| + ASSERT(-flow_graph_.parsed_function().first_stack_local_index() - 1 == |
| + context_reg); |
| + if (flow_graph_.parsed_function().function_type_arguments() != NULL) { |
| + // The first slot is used for function type arguments, either as their |
| + // permanent location or as their temporary location when captured. |
| + // So use the next one for the context. |
| + context_reg++; |
| + } |
| + AssignSafepoints(defn, range); |
|
Vyacheslav Egorov (Google)
2017/08/13 13:19:23
I think lines 710-717 and 724-729 should be almost
regis
2017/08/14 23:29:19
Done.
|
| + range->finger()->Initialize(range); |
| + range->set_assigned_location(Location::RegisterLocation(context_reg)); |
| + if (range->End() > kNormalEntryPos) { |
| + LiveRange* tail = range->SplitAt(kNormalEntryPos); |
| + CompleteRange(tail, Location::kRegister); |
| + } |
| + ConvertAllUses(range); |
| + return; |
| + } |
| + ASSERT(param->kind() == SpecialParameterInstr::kTypeArgs); |
| + const intptr_t slot_index = flow_graph_.num_copied_params(); |
| + ASSERT(-flow_graph_.parsed_function().first_stack_local_index() - 1 == |
| + slot_index); |
| + range->set_assigned_location(Location::RegisterLocation(slot_index)); |
| + if (range->End() > kNormalEntryPos) { |
| + LiveRange* tail = range->SplitAt(kNormalEntryPos); |
| + CompleteRange(tail, Location::kRegister); |
| + } |
| + ConvertAllUses(range); |
| + return; |
| + } else { |
| + ConstantInstr* constant = defn->AsConstant(); |
| + ASSERT(constant != NULL); |
| + range->set_assigned_location(Location::Constant(constant)); |
| + range->set_spill_slot(Location::Constant(constant)); |
| + } |
| + AssignSafepoints(defn, range); |
| + range->finger()->Initialize(range); |
| + UsePosition* use = |
| + range->finger()->FirstRegisterBeneficialUse(block->start_pos()); |
| + if (use != NULL) { |
| + LiveRange* tail = SplitBetween(range, block->start_pos(), use->pos()); |
| + // Parameters and constants are tagged, so allocated to CPU registers. |
| + CompleteRange(tail, Location::kRegister); |
| + } |
| + ConvertAllUses(range); |
| + if (range->spill_slot().IsStackSlot() && |
| + (range->spill_slot().stack_index() >= 0)) { |
| + // On entry to the function, range is stored on the stack above the FP in |
| + // the same space which is used for spill slots. Update spill slot state to |
| + // reflect that and prevent register allocator from reusing this space as a |
| + // spill slot. |
| + spill_slots_.Add(range_end); |
| + quad_spill_slots_.Add(false); |
| + untagged_spill_slots_.Add(false); |
| + // Note, all incoming parameters are assumed to be tagged. |
| + MarkAsObjectAtSafepoints(range); |
| + } else if (defn->IsConstant() && block->IsCatchBlockEntry()) { |
| + // Constants at catch block entries consume spill slots. |
| + spill_slots_.Add(range_end); |
| + quad_spill_slots_.Add(false); |
| + untagged_spill_slots_.Add(false); |
| + } |
| +} |
| #else |
| - const intptr_t context_reg = flow_graph_.num_copied_params(); |
| -#endif |
| +void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| + LiveRange* range, |
| + BlockEntryInstr* block) { |
| + // Save the range end because it may change below. |
| + intptr_t range_end = 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)); |
| + intptr_t slot_index = param->index(); |
| + ASSERT(slot_index >= 0); |
| + ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG)); |
| + if (param->base_reg() == FPREG) { |
| + // Slot index for the leftmost copied parameter is 0. |
| + // 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, param->base_reg())); |
| + range->set_spill_slot(Location::StackSlot(slot_index, param->base_reg())); |
| + } else if (defn->IsSpecialParameter()) { |
| + SpecialParameterInstr* param = defn->AsSpecialParameter(); |
| + if (param->kind() == SpecialParameterInstr::kContext) { |
| + const Register context_reg = CTX; |
| AssignSafepoints(defn, range); |
| range->finger()->Initialize(range); |
| range->set_assigned_location(Location::RegisterLocation(context_reg)); |
| @@ -720,9 +801,6 @@ void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| return; |
| } |
| ASSERT(param->kind() == SpecialParameterInstr::kTypeArgs); |
| -#if defined(TARGET_ARCH_DBC) |
| - UNIMPLEMENTED(); |
| -#endif |
| const intptr_t slot_index = flow_graph_.num_copied_params(); |
| range->set_assigned_location(Location::StackSlot(slot_index, FPREG)); |
| range->set_spill_slot(Location::StackSlot(slot_index, FPREG)); |
| @@ -760,6 +838,7 @@ void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| untagged_spill_slots_.Add(false); |
| } |
| } |
| +#endif // defined(TARGET_ARCH_DBC) |
| static Location::Kind RegisterKindFromPolicy(Location loc) { |
| if (loc.policy() == Location::kRequiresFpuRegister) { |