Flutter Engine
The Flutter Engine
Static Public Member Functions | List of all members
dart::BlockScheduler Class Reference

#include <block_scheduler.h>

Inheritance diagram for dart::BlockScheduler:
dart::AllStatic

Static Public Member Functions

static void AssignEdgeWeights (FlowGraph *flow_graph)
 
static void ReorderBlocks (FlowGraph *flow_graph)
 

Detailed Description

Definition at line 18 of file block_scheduler.h.

Member Function Documentation

◆ AssignEdgeWeights()

void dart::BlockScheduler::AssignEdgeWeights ( FlowGraph flow_graph)
static

Definition at line 49 of file block_scheduler.cc.

49 {
50 if (!FLAG_reorder_basic_blocks) {
51 return;
52 }
53 if (CompilerState::Current().is_aot()) {
54 return;
55 }
56
57 const Function& function = flow_graph->parsed_function().function();
58 const Array& ic_data_array =
59 Array::Handle(flow_graph->zone(), function.ic_data_array());
60 if (ic_data_array.IsNull()) {
61 DEBUG_ASSERT(IsolateGroup::Current()->HasAttemptedReload() ||
62 function.ForceOptimize());
63 return;
64 }
65 Array& edge_counters = Array::Handle();
66 edge_counters ^=
68 if (edge_counters.IsNull()) {
69 return;
70 }
71
72 auto graph_entry = flow_graph->graph_entry();
73 BlockEntryInstr* entry = graph_entry->normal_entry();
74 if (entry == nullptr) {
75 entry = graph_entry->osr_entry();
76 ASSERT(entry != nullptr);
77 }
78 const intptr_t entry_count =
79 GetEdgeCount(edge_counters, entry->preorder_number());
80 graph_entry->set_entry_count(entry_count);
81 if (entry_count == 0) {
82 return; // Nothing to do.
83 }
84
85 for (BlockIterator it = flow_graph->reverse_postorder_iterator(); !it.Done();
86 it.Advance()) {
87 BlockEntryInstr* block = it.Current();
88 Instruction* last = block->last_instruction();
89 for (intptr_t i = 0; i < last->SuccessorCount(); ++i) {
90 BlockEntryInstr* succ = last->SuccessorAt(i);
91 SetEdgeWeight(block, succ, edge_counters, entry_count);
92 }
93 }
94}
#define DEBUG_ASSERT(cond)
Definition: assert.h:321
static CompilerState & Current()
static IsolateGroup * Current()
Definition: isolate.h:539
static Object & Handle()
Definition: object.h:407
#define ASSERT(E)
Dart_NativeFunction function
Definition: fuchsia.cc:51
static void SetEdgeWeight(BlockEntryInstr *block, BlockEntryInstr *successor, const Array &edge_counters, intptr_t entry_count)
static intptr_t GetEdgeCount(const Array &edge_counters, intptr_t edge_id)
static constexpr intptr_t kEdgeCounters
Definition: object.h:4058

◆ ReorderBlocks()

void dart::BlockScheduler::ReorderBlocks ( FlowGraph flow_graph)
static

Definition at line 158 of file block_scheduler.cc.

158 {
159 if (!flow_graph->should_reorder_blocks()) {
160 return;
161 }
162
163 if (CompilerState::Current().is_aot()) {
164 ReorderBlocksAOT(flow_graph);
165 } else {
166 ReorderBlocksJIT(flow_graph);
167 }
168}

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