Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
compiler_pass.h File Reference
#include <initializer_list>
#include "vm/growable_array.h"
#include "vm/timer.h"
#include "vm/token_position.h"
#include "vm/zone.h"

Go to the source code of this file.

Classes

struct  dart::CompilerPassState
 
class  dart::CompilerPass
 

Namespaces

namespace  dart
 

Macros

#define COMPILER_PASS_LIST(V)
 
#define DEF(name)   k##name,
 
#define ADD_ONE(name)   +1
 

Macro Definition Documentation

◆ ADD_ONE

#define ADD_ONE (   name)    +1

Definition at line 115 of file compiler_pass.h.

◆ COMPILER_PASS_LIST

#define COMPILER_PASS_LIST (   V)

Definition at line 21 of file compiler_pass.h.

71 {
72 CompilerPassState(Thread* thread,
73 FlowGraph* flow_graph,
74 SpeculativeInliningPolicy* speculative_policy,
75 Precompiler* precompiler = nullptr);
76
77 FlowGraph* flow_graph() const { return flow_graph_; }
78
79 void set_flow_graph(FlowGraph* flow_graph);
80
81 Thread* const thread;
82 Precompiler* const precompiler;
83 int inlining_depth;
84 AllocationSinking* sinking;
85
86 // Maps inline_id_to_function[inline_id] -> function. Top scope
87 // function has inline_id 0. The map is populated by the inliner.
88 GrowableArray<const Function*> inline_id_to_function;
89 // Token position where inlining occurred.
90 GrowableArray<TokenPosition> inline_id_to_token_pos;
91 // For a given inlining-id(index) specifies the caller's inlining-id.
92 GrowableArray<intptr_t> caller_inline_id;
93
94 CallSpecializer* call_specializer;
95
96 SpeculativeInliningPolicy* speculative_policy;
97
98 intptr_t sticky_flags;
99
100 FlowGraphCompiler* graph_compiler = nullptr;
101
102 private:
103 FlowGraph* flow_graph_;
104};
105
106class CompilerPass {
107 public:
108 enum Id {
109#define DEF(name) k##name,
111#undef DEF
112 };
113
114#define ADD_ONE(name) +1
115 static constexpr intptr_t kNumPasses = 0 COMPILER_PASS_LIST(ADD_ONE);
116#undef ADD_ONE
117
118 CompilerPass(Id id, const char* name) : id_(id), name_(name) {
119 ASSERT(passes_[id] == nullptr);
120 passes_[id] = this;
121
122 // By default print the final flow-graph after the register allocation.
123 if (id == kAllocateRegisters) {
124 flags_[id] = kTraceAfter;
125 } else {
126 flags_[id] = 0;
127 }
128 }
129 virtual ~CompilerPass() {}
130
131 enum Flag {
132 kDisabled = 1 << 0,
133 kTraceBefore = 1 << 1,
134 kTraceAfter = 1 << 2,
135 kSticky = 1 << 3,
136 kTraceBeforeOrAfter = kTraceBefore | kTraceAfter,
137 };
138
139 void Run(CompilerPassState* state) const;
140
141 uint8_t flags() const { return flags_[id()]; }
142 const char* name() const { return name_; }
143 Id id() const { return id_; }
144
145 static CompilerPass* Get(Id id) { return passes_[id]; }
146
147 static void ParseFiltersFromFlag(const char* filter);
148 static uint8_t* ParseFiltersFromPragma(const char* filter);
149 static void ParseFilters(const char* filter, uint8_t* flags);
150 static void ParseOneFilter(const char* start,
151 const char* end,
152 uint8_t* flags);
153
154 enum PipelineMode { kJIT, kAOT };
155
156 static void GenerateCode(CompilerPassState* state) {
157 CompilerPass::Get(CompilerPass::kGenerateCode)->Run(state);
158 }
159
160 static void RunGraphIntrinsicPipeline(CompilerPassState* state);
161
162 static void RunInliningPipeline(PipelineMode mode, CompilerPassState* state);
163
164 // RunPipeline(WithPasses) may have the side effect of changing the FlowGraph
165 // stored in the CompilerPassState. However, existing callers may depend on
166 // the old invariant that the FlowGraph stored in the CompilerPassState was
167 // always updated, never entirely replaced.
168 //
169 // To make sure callers are updated properly, these methods also return
170 // the final FlowGraph and we add a check that callers use this result.
172 static FlowGraph* RunPipeline(PipelineMode mode, CompilerPassState* state);
174 static FlowGraph* RunPipelineWithPasses(
175 CompilerPassState* state,
176 std::initializer_list<CompilerPass::Id> passes);
177
178 protected:
179 // This function executes the pass. If it returns true then
180 // we will run Canonicalize on the graph and execute the pass
181 // again.
182 virtual bool DoBody(CompilerPassState* state) const = 0;
183
184 private:
185 static CompilerPass* FindPassByName(const char* name) {
186 for (intptr_t i = 0; i < kNumPasses; i++) {
187 if ((passes_[i] != nullptr) && (strcmp(passes_[i]->name_, name) == 0)) {
188 return passes_[i];
189 }
190 }
191 return nullptr;
192 }
193
194 void PrintGraph(CompilerPassState* state, Flag mask, intptr_t round) const;
195
196 static CompilerPass* passes_[];
197 static uint8_t flags_[];
198
199 Id id_;
200 const char* name_;
201};
202
203} // namespace dart
204
205#endif // RUNTIME_VM_COMPILER_COMPILER_PASS_H_
static void round(SkPoint *p)
#define DEF(name)
#define COMPILER_PASS_LIST(V)
#define ADD_ONE(name)
#define DART_WARN_UNUSED_RESULT
Definition dart_api.h:66
#define ASSERT(E)
AtkStateType state
FlutterSemanticsFlag flags
glong glong end
const char * name
Definition fuchsia.cc:50
const GrXPFactory * Get(SkBlendMode mode)
const uintptr_t id

◆ DEF

#define DEF (   name)    k##name,

Definition at line 110 of file compiler_pass.h.