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
87
88 GrowableArray<const Function*> inline_id_to_function;
89
90 GrowableArray<TokenPosition> inline_id_to_token_pos;
91
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
116#undef ADD_ONE
117
118 CompilerPass(Id
id,
const char*
name) : id_(
id), name_(
name) {
119 ASSERT(passes_[
id] ==
nullptr);
121
122
123 if (id == kAllocateRegisters) {
124 flags_[
id] = kTraceAfter;
125 } else {
127 }
128 }
129 virtual ~CompilerPass() {}
130
131 enum Flag {
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,
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
165
166
167
168
169
170
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
180
181
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}
204
205#endif
static void round(SkPoint *p)
#define COMPILER_PASS_LIST(V)
#define DART_WARN_UNUSED_RESULT
FlutterSemanticsFlag flags
const GrXPFactory * Get(SkBlendMode mode)