Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dart::FlowGraphAllocator Class Reference

#include <linearscan.h>

Inheritance diagram for dart::FlowGraphAllocator:
dart::ValueObject

Public Member Functions

 FlowGraphAllocator (const FlowGraph &flow_graph, bool intrinsic_mode=false)
 
void AllocateRegisters ()
 
LiveRangeGetLiveRange (intptr_t vreg)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Member Functions

static DART_FORCE_INLINE void SetLifetimePosition (Instruction *instr, intptr_t pos)
 
static DART_FORCE_INLINE bool HasLifetimePosition (Instruction *instr)
 
static DART_FORCE_INLINE intptr_t GetLifetimePosition (const Instruction *instr)
 

Static Public Attributes

static constexpr intptr_t kDoubleSpillFactor
 

Detailed Description

Definition at line 55 of file linearscan.h.

Constructor & Destructor Documentation

◆ FlowGraphAllocator()

dart::FlowGraphAllocator::FlowGraphAllocator ( const FlowGraph flow_graph,
bool  intrinsic_mode = false 
)
explicit

Definition at line 88 of file linearscan.cc.

90 : flow_graph_(flow_graph),
91 reaching_defs_(flow_graph),
92 value_representations_(flow_graph.max_vreg()),
93 block_order_(BlockOrderForAllocation(flow_graph)),
94 postorder_(flow_graph.postorder()),
95 instructions_(),
96 block_entries_(),
97 extra_loop_info_(),
98 liveness_(flow_graph),
99 vreg_count_(flow_graph.max_vreg()),
100 live_ranges_(flow_graph.max_vreg()),
101 unallocated_cpu_(),
102 unallocated_fpu_(),
103 cpu_regs_(),
104 fpu_regs_(),
105 blocked_cpu_registers_(),
106 blocked_fpu_registers_(),
107 spilled_(),
108 safepoints_(),
109 register_kind_(),
110 number_of_registers_(0),
111 registers_(),
112 blocked_registers_(),
113 unallocated_(),
114 spill_slots_(),
115 quad_spill_slots_(),
116 untagged_spill_slots_(),
117 cpu_spill_slot_count_(0),
118 intrinsic_mode_(intrinsic_mode) {
119 for (intptr_t i = 0; i < vreg_count_; i++) {
120 live_ranges_.Add(nullptr);
121 }
122 for (intptr_t i = 0; i < vreg_count_; i++) {
123 value_representations_.Add(kNoRepresentation);
124 }
125
126 // All registers are marked as "not blocked" (array initialized to false).
127 // Mark the unavailable ones as "blocked" (true).
128 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) {
129 if ((kDartAvailableCpuRegs & (1 << i)) == 0) {
130 blocked_cpu_registers_[i] = true;
131 }
132 }
133
134 // FpuTMP is used as scratch by optimized code and parallel move resolver.
135 blocked_fpu_registers_[FpuTMP] = true;
136
137 // Block additional registers needed preserved when generating intrinsics.
138 // TODO(fschneider): Handle saving and restoring these registers when
139 // generating intrinsic code.
140 if (intrinsic_mode) {
141 blocked_cpu_registers_[ARGS_DESC_REG] = true;
142
143#if !defined(TARGET_ARCH_IA32)
144 // Need to preserve CODE_REG to be able to store the PC marker
145 // and load the pool pointer.
146 blocked_cpu_registers_[CODE_REG] = true;
147#endif
148 }
149}
void Add(const T &value)
static const GrowableArray< BlockEntryInstr * > & BlockOrderForAllocation(const FlowGraph &flow_graph)
Definition linearscan.cc:80
const FpuRegister FpuTMP
const Register CODE_REG
const Register ARGS_DESC_REG
@ kNumberOfCpuRegisters
constexpr RegList kDartAvailableCpuRegs

Member Function Documentation

◆ AllocateRegisters()

void dart::FlowGraphAllocator::AllocateRegisters ( )

Definition at line 3441 of file linearscan.cc.

3441 {
3442 CollectRepresentations();
3443
3444 liveness_.Analyze();
3445
3446 NumberInstructions();
3447
3448 // Reserve spill slot for :suspend_state synthetic variable before
3449 // reserving spill slots for parameter variables.
3450 AllocateSpillSlotForSuspendState();
3451
3452 BuildLiveRanges();
3453
3454 // Update stackmaps after all safepoints are collected.
3455 UpdateStackmapsForSuspendState();
3456
3457 if (FLAG_print_ssa_liveranges && CompilerState::ShouldTrace()) {
3458 const Function& function = flow_graph_.function();
3459 THR_Print("-- [before ssa allocator] ranges [%s] ---------\n",
3460 function.ToFullyQualifiedCString());
3461 PrintLiveRanges();
3462 THR_Print("----------------------------------------------\n");
3463
3464 THR_Print("-- [before ssa allocator] ir [%s] -------------\n",
3465 function.ToFullyQualifiedCString());
3467#ifndef PRODUCT
3468 FlowGraphPrinter printer(flow_graph_, true);
3469 printer.PrintBlocks();
3470#endif
3471 }
3472 THR_Print("----------------------------------------------\n");
3473 }
3474
3475 PrepareForAllocation(Location::kRegister, kNumberOfCpuRegisters,
3476 unallocated_cpu_, cpu_regs_, blocked_cpu_registers_);
3477 AllocateUnallocatedRanges();
3478 // GraphEntryInstr::fixed_slot_count() stack slots are reserved for catch
3479 // entries. When allocating a spill slot, AllocateSpillSlotFor() accounts for
3480 // these reserved slots and allocates spill slots on top of them.
3481 // However, if there are no spill slots allocated, we still need to reserve
3482 // slots for catch entries in the spill area.
3483 cpu_spill_slot_count_ = Utils::Maximum(
3484 spill_slots_.length(), flow_graph_.graph_entry()->fixed_slot_count());
3485 spill_slots_.Clear();
3486 quad_spill_slots_.Clear();
3487 untagged_spill_slots_.Clear();
3488
3489 PrepareForAllocation(Location::kFpuRegister, kNumberOfFpuRegisters,
3490 unallocated_fpu_, fpu_regs_, blocked_fpu_registers_);
3491 AllocateUnallocatedRanges();
3492
3493 GraphEntryInstr* entry = block_order_[0]->AsGraphEntry();
3494 ASSERT(entry != nullptr);
3495 intptr_t double_spill_slot_count = spill_slots_.length() * kDoubleSpillFactor;
3496 entry->set_spill_slot_count(cpu_spill_slot_count_ + double_spill_slot_count +
3497 flow_graph_.max_argument_slot_count());
3498
3499 RemoveFrameIfNotNeeded();
3500
3501 AllocateOutgoingArguments();
3502
3503 ResolveControlFlow();
3504
3505 ScheduleParallelMoves();
3506
3507 if (FLAG_print_ssa_liveranges && CompilerState::ShouldTrace()) {
3508 const Function& function = flow_graph_.function();
3509
3510 THR_Print("-- [after ssa allocator] ranges [%s] ---------\n",
3511 function.ToFullyQualifiedCString());
3512 PrintLiveRanges();
3513 THR_Print("----------------------------------------------\n");
3514
3515 THR_Print("-- [after ssa allocator] ir [%s] -------------\n",
3516 function.ToFullyQualifiedCString());
3518#ifndef PRODUCT
3519 FlowGraphPrinter printer(flow_graph_, true);
3520 printer.PrintBlocks();
3521#endif
3522 }
3523 THR_Print("----------------------------------------------\n");
3524 }
3525}
intptr_t length() const
static bool ShouldTrace()
static constexpr intptr_t kDoubleSpillFactor
Definition linearscan.h:58
GraphEntryInstr * graph_entry() const
Definition flow_graph.h:268
intptr_t max_argument_slot_count() const
Definition flow_graph.h:564
const Function & function() const
Definition flow_graph.h:130
intptr_t fixed_slot_count() const
Definition il.h:1981
static constexpr T Maximum(T x, T y)
Definition utils.h:26
#define THR_Print(format,...)
Definition log.h:20
#define ASSERT(E)
constexpr bool FLAG_support_il_printer
Definition flag_list.h:48
Dart_NativeFunction function
Definition fuchsia.cc:51
const int kNumberOfFpuRegisters

◆ GetLifetimePosition()

static DART_FORCE_INLINE intptr_t dart::FlowGraphAllocator::GetLifetimePosition ( const Instruction instr)
inlinestatic

Definition at line 78 of file linearscan.h.

79 {
80 return instr->GetPassSpecificId(CompilerPass::kAllocateRegisters);
81 }

◆ GetLiveRange()

LiveRange * dart::FlowGraphAllocator::GetLiveRange ( intptr_t  vreg)

Definition at line 431 of file linearscan.cc.

431 {
432 if (live_ranges_[vreg] == nullptr) {
433 Representation rep = value_representations_[vreg];
434 ASSERT(rep != kNoRepresentation);
435 live_ranges_[vreg] = new LiveRange(vreg, rep);
436 }
437 return live_ranges_[vreg];
438}
Representation
Definition locations.h:66

◆ HasLifetimePosition()

static DART_FORCE_INLINE bool dart::FlowGraphAllocator::HasLifetimePosition ( Instruction instr)
inlinestatic

Definition at line 74 of file linearscan.h.

74 {
75 return instr->HasPassSpecificId(CompilerPass::kAllocateRegisters);
76 }

◆ SetLifetimePosition()

static DART_FORCE_INLINE void dart::FlowGraphAllocator::SetLifetimePosition ( Instruction instr,
intptr_t  pos 
)
inlinestatic

Definition at line 69 of file linearscan.h.

70 {
71 instr->SetPassSpecificId(CompilerPass::kAllocateRegisters, pos);
72 }
SkPoint pos

Member Data Documentation

◆ kDoubleSpillFactor

constexpr intptr_t dart::FlowGraphAllocator::kDoubleSpillFactor
staticconstexpr
Initial value:
=
kDoubleSize / compiler::target::kWordSize
constexpr intptr_t kDoubleSize
Definition globals.h:456

Definition at line 58 of file linearscan.h.


The documentation for this class was generated from the following files: