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

#include <il_test_helper.h>

Inheritance diagram for dart::TestPipeline:
dart::ValueObject

Public Member Functions

 TestPipeline (const Function &function, CompilerPass::PipelineMode mode, bool is_optimizing=true)
 
 ~TestPipeline ()
 
 TestPipeline (CompilerPass::PipelineMode mode, std::function< FlowGraph *()> fn)
 
FlowGraphRunPasses (std::initializer_list< CompilerPass::Id > passes)
 
void RunAdditionalPasses (std::initializer_list< CompilerPass::Id > passes)
 
void RunForcedOptimizedAfterSSAPasses ()
 
void CompileGraphAndAttachFunction ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 73 of file il_test_helper.h.

Constructor & Destructor Documentation

◆ TestPipeline() [1/2]

dart::TestPipeline::TestPipeline ( const Function function,
CompilerPass::PipelineMode  mode,
bool  is_optimizing = true 
)
inline

Definition at line 75 of file il_test_helper.h.

78 : thread_(Thread::Current()),
79 compiler_state_(thread_,
80 mode == CompilerPass::PipelineMode::kAOT,
81 is_optimizing,
83 hierarchy_info_(thread_),
84 speculative_policy_(std::unique_ptr<SpeculativeInliningPolicy>(
85 new SpeculativeInliningPolicy(/*enable_suppresson=*/false))),
86 mode_(mode),
87 flow_graph_(nullptr),
88 function_(function),
89 parsed_function_(nullptr) {}
static bool ShouldTrace()
static Thread * Current()
Definition: thread.h:362
Dart_NativeFunction function
Definition: fuchsia.cc:51
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ ~TestPipeline()

dart::TestPipeline::~TestPipeline ( )
inline

Definition at line 90 of file il_test_helper.h.

90{ delete pass_state_; }

◆ TestPipeline() [2/2]

dart::TestPipeline::TestPipeline ( CompilerPass::PipelineMode  mode,
std::function< FlowGraph *()>  fn 
)
inline

Definition at line 92 of file il_test_helper.h.

93 : thread_(Thread::Current()),
94 compiler_state_(thread_,
95 mode == CompilerPass::PipelineMode::kAOT,
96 /*is_optimizing=*/true,
98 hierarchy_info_(thread_),
99 speculative_policy_(std::unique_ptr<SpeculativeInliningPolicy>(
100 new SpeculativeInliningPolicy(/*enable_suppresson=*/false))),
101 mode_(mode),
102 flow_graph_(fn()),
103 function_(flow_graph_->function()),
104 parsed_function_(
105 const_cast<ParsedFunction*>(&flow_graph_->parsed_function())) {}
const Function & function() const
Definition: flow_graph.h:130
const ParsedFunction & parsed_function() const
Definition: flow_graph.h:129

Member Function Documentation

◆ CompileGraphAndAttachFunction()

void dart::TestPipeline::CompileGraphAndAttachFunction ( )

Definition at line 218 of file il_test_helper.cc.

218 {
219 Zone* zone = thread_->zone();
220 const bool optimized = true;
221
222 SpeculativeInliningPolicy speculative_policy(/*enable_suppression=*/false);
223
224#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_IA32)
225 const intptr_t far_branch_level = 0;
226#else
227 const intptr_t far_branch_level = 1;
228#endif
229
230 ASSERT(pass_state_->inline_id_to_function.length() ==
231 pass_state_->caller_inline_id.length());
232 compiler::ObjectPoolBuilder object_pool_builder;
233 compiler::Assembler assembler(&object_pool_builder, far_branch_level);
234 FlowGraphCompiler graph_compiler(
235 &assembler, flow_graph_, *parsed_function_, optimized,
236 &speculative_policy, pass_state_->inline_id_to_function,
237 pass_state_->inline_id_to_token_pos, pass_state_->caller_inline_id,
238 ic_data_array_);
239
240 graph_compiler.CompileGraph();
241
242 const auto& deopt_info_array =
243 Array::Handle(zone, graph_compiler.CreateDeoptInfo(&assembler));
244 const auto pool_attachment = Code::PoolAttachment::kAttachPool;
245 Code& code = Code::Handle();
246 {
247 SafepointWriteRwLocker ml(thread_,
248 thread_->isolate_group()->program_lock());
249 code ^= Code::FinalizeCode(&graph_compiler, &assembler, pool_attachment,
250 optimized, nullptr);
251 }
252 code.set_is_optimized(optimized);
253 code.set_owner(function_);
254
255 graph_compiler.FinalizePcDescriptors(code);
256 code.set_deopt_info_array(deopt_info_array);
257
258 graph_compiler.FinalizeStackMaps(code);
259 graph_compiler.FinalizeVarDescriptors(code);
260 graph_compiler.FinalizeExceptionHandlers(code);
261 graph_compiler.FinalizeCatchEntryMovesMap(code);
262 graph_compiler.FinalizeStaticCallTargetsTable(code);
263 graph_compiler.FinalizeCodeSourceMap(code);
264
265 {
266 SafepointWriteRwLocker ml(thread_,
267 thread_->isolate_group()->program_lock());
268 if (optimized) {
269 function_.InstallOptimizedCode(code);
270 } else {
271 function_.set_unoptimized_code(code);
272 function_.AttachCode(code);
273 }
274 }
275
276 // We expect there to be no deoptimizations.
277 if (mode_ == CompilerPass::kAOT) {
278 EXPECT(deopt_info_array.IsNull() || deopt_info_array.Length() == 0);
279 }
280
281#if !defined(PRODUCT)
282 if (FLAG_disassemble_optimized) {
283 Disassembler::DisassembleCode(function_, code, optimized);
284 }
285#endif
286}
#define EXPECT(type, expectedAlignment, expectedSize)
intptr_t length() const
static CodePtr FinalizeCode(FlowGraphCompiler *compiler, compiler::Assembler *assembler, PoolAttachment pool_attachment, bool optimized, CodeStatistics *stats)
Definition: object.cc:18018
static void DisassembleCode(const Function &function, const Code &code, bool optimized)
void set_unoptimized_code(const Code &value) const
Definition: object.cc:8038
void InstallOptimizedCode(const Code &code) const
Definition: object.cc:7899
void AttachCode(const Code &value) const
Definition: object.cc:7927
SafepointRwLock * program_lock()
Definition: isolate.h:537
static Object & Handle()
Definition: object.h:407
Zone * zone() const
Definition: thread_state.h:37
IsolateGroup * isolate_group() const
Definition: thread.h:541
#define ASSERT(E)
GrowableArray< TokenPosition > inline_id_to_token_pos
Definition: compiler_pass.h:90
GrowableArray< intptr_t > caller_inline_id
Definition: compiler_pass.h:92
GrowableArray< const Function * > inline_id_to_function
Definition: compiler_pass.h:88

◆ RunAdditionalPasses()

void dart::TestPipeline::RunAdditionalPasses ( std::initializer_list< CompilerPass::Id passes)

Definition at line 178 of file il_test_helper.cc.

179 {
180 JitCallSpecializer jit_call_specializer(flow_graph_,
181 speculative_policy_.get());
182 AotCallSpecializer aot_call_specializer(/*precompiler=*/nullptr, flow_graph_,
183 speculative_policy_.get());
184 if (mode_ == CompilerPass::kAOT) {
185 pass_state_->call_specializer = &aot_call_specializer;
186 } else {
187 pass_state_->call_specializer = &jit_call_specializer;
188 }
189
190 flow_graph_ = CompilerPass::RunPipelineWithPasses(pass_state_, passes);
191 pass_state_->call_specializer = nullptr;
192}
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipelineWithPasses(CompilerPassState *state, std::initializer_list< CompilerPass::Id > passes)
CallSpecializer * call_specializer
Definition: compiler_pass.h:94

◆ RunForcedOptimizedAfterSSAPasses()

void dart::TestPipeline::RunForcedOptimizedAfterSSAPasses ( )

Definition at line 194 of file il_test_helper.cc.

194 {
196 CompilerPass::kSetOuterInliningId,
197 CompilerPass::kTypePropagation,
198 CompilerPass::kCanonicalize,
199 CompilerPass::kBranchSimplify,
200 CompilerPass::kIfConvert,
201 CompilerPass::kConstantPropagation,
202 CompilerPass::kTypePropagation,
203 CompilerPass::kSelectRepresentations_Final,
204 CompilerPass::kTypePropagation,
205 CompilerPass::kTryCatchOptimization,
206 CompilerPass::kEliminateEnvironments,
207 CompilerPass::kEliminateDeadPhis,
208 CompilerPass::kDCE,
209 CompilerPass::kCanonicalize,
210 CompilerPass::kDelayAllocations,
211 CompilerPass::kEliminateWriteBarriers,
212 CompilerPass::kFinalizeGraph,
213 CompilerPass::kAllocateRegisters,
214 CompilerPass::kReorderBlocks,
215 });
216}
void RunAdditionalPasses(std::initializer_list< CompilerPass::Id > passes)

◆ RunPasses()

FlowGraph * dart::TestPipeline::RunPasses ( std::initializer_list< CompilerPass::Id passes)

Definition at line 116 of file il_test_helper.cc.

117 {
118 auto thread = Thread::Current();
119 auto zone = thread->zone();
120 const bool optimized = true;
121 const intptr_t osr_id = Compiler::kNoOSRDeoptId;
122
123 // We assume that prebuilt graph is already in SSA form so we should
124 // avoid running ComputeSSA on it (it will just crash).
125 const bool is_ssa = (flow_graph_ != nullptr);
126 if (flow_graph_ == nullptr) {
127 auto pipeline = CompilationPipeline::New(zone, function_);
128
129 parsed_function_ = new (zone)
130 ParsedFunction(thread, Function::ZoneHandle(zone, function_.ptr()));
131 pipeline->ParseFunction(parsed_function_);
132
133 // Extract type feedback before the graph is built, as the graph
134 // builder uses it to attach it to nodes.
135 ic_data_array_ = new (zone) ZoneGrowableArray<const ICData*>();
136 if (mode_ == CompilerPass::kJIT) {
137 function_.RestoreICDataMap(ic_data_array_, /*clone_ic_data=*/false);
138 }
139
140 flow_graph_ = pipeline->BuildFlowGraph(zone, parsed_function_,
141 ic_data_array_, osr_id, optimized);
142 }
143
144 if (mode_ == CompilerPass::kAOT) {
145 flow_graph_->PopulateWithICData(function_);
146 }
147
148 if (mode_ == CompilerPass::kJIT && flow_graph_->should_reorder_blocks()) {
150 }
151
152 pass_state_ =
153 new CompilerPassState(thread, flow_graph_, speculative_policy_.get());
154
155 if (optimized) {
156 JitCallSpecializer jit_call_specializer(flow_graph_,
157 speculative_policy_.get());
158 AotCallSpecializer aot_call_specializer(
159 /*precompiler=*/nullptr, flow_graph_, speculative_policy_.get());
160 if (mode_ == CompilerPass::kAOT) {
161 pass_state_->call_specializer = &aot_call_specializer;
162 } else {
163 pass_state_->call_specializer = &jit_call_specializer;
164 }
165
166 if (passes.size() > 0) {
167 flow_graph_ = CompilerPass::RunPipelineWithPasses(pass_state_, passes);
168 } else {
169 flow_graph_ = CompilerPass::RunPipeline(mode_, pass_state_,
170 /*compute_ssa=*/!is_ssa);
171 }
172 pass_state_->call_specializer = nullptr;
173 }
174
175 return flow_graph_;
176}
static void AssignEdgeWeights(FlowGraph *flow_graph)
static CompilationPipeline * New(Zone *zone, const Function &function)
Definition: compiler.cc:201
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipeline(PipelineMode mode, CompilerPassState *state, bool compute_ssa=true)
static constexpr intptr_t kNoOSRDeoptId
Definition: compiler.h:73
void PopulateWithICData(const Function &function)
Definition: flow_graph.cc:2528
bool should_reorder_blocks() const
Definition: flow_graph.h:508
void RestoreICDataMap(ZoneGrowableArray< const ICData * > *deopt_id_to_ic_data, bool clone_ic_data) const
Definition: object.cc:11217
ObjectPtr ptr() const
Definition: object.h:332
static Object & ZoneHandle()
Definition: object.h:419

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