Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 ()
 
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()

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

Definition at line 75 of file il_test_helper.h.

78 : function_(function),
79 thread_(Thread::Current()),
80 compiler_state_(thread_,
82 is_optimizing,
84 hierarchy_info_(thread_),
85 speculative_policy_(std::unique_ptr<SpeculativeInliningPolicy>(
86 new SpeculativeInliningPolicy(/*enable_suppresson=*/false))),
87 mode_(mode) {}
static bool ShouldTrace()
static Thread * Current()
Definition thread.h:361
Dart_NativeFunction function
Definition fuchsia.cc:51

◆ ~TestPipeline()

dart::TestPipeline::~TestPipeline ( )
inline

Definition at line 88 of file il_test_helper.h.

88{ delete pass_state_; }

Member Function Documentation

◆ CompileGraphAndAttachFunction()

void dart::TestPipeline::CompileGraphAndAttachFunction ( )

Definition at line 213 of file il_test_helper.cc.

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

◆ RunAdditionalPasses()

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

Definition at line 172 of file il_test_helper.cc.

173 {
174 JitCallSpecializer jit_call_specializer(flow_graph_,
175 speculative_policy_.get());
176 AotCallSpecializer aot_call_specializer(/*precompiler=*/nullptr, flow_graph_,
177 speculative_policy_.get());
178 if (mode_ == CompilerPass::kAOT) {
179 pass_state_->call_specializer = &aot_call_specializer;
180 } else {
181 pass_state_->call_specializer = &jit_call_specializer;
182 }
183
184 flow_graph_ = CompilerPass::RunPipelineWithPasses(pass_state_, passes);
185 pass_state_->call_specializer = nullptr;
186}
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipelineWithPasses(CompilerPassState *state, std::initializer_list< CompilerPass::Id > passes)
CallSpecializer * call_specializer

◆ RunForcedOptimizedAfterSSAPasses()

void dart::TestPipeline::RunForcedOptimizedAfterSSAPasses ( )

Definition at line 188 of file il_test_helper.cc.

188 {
190 CompilerPass::kSetOuterInliningId,
191 CompilerPass::kTypePropagation,
192 CompilerPass::kCanonicalize,
193 CompilerPass::kBranchSimplify,
194 CompilerPass::kIfConvert,
195 CompilerPass::kConstantPropagation,
196 CompilerPass::kTypePropagation,
197 CompilerPass::kWidenSmiToInt32,
198 CompilerPass::kSelectRepresentations_Final,
199 CompilerPass::kTypePropagation,
200 CompilerPass::kTryCatchOptimization,
201 CompilerPass::kEliminateEnvironments,
202 CompilerPass::kEliminateDeadPhis,
203 CompilerPass::kDCE,
204 CompilerPass::kCanonicalize,
205 CompilerPass::kDelayAllocations,
206 CompilerPass::kEliminateWriteBarriers,
207 CompilerPass::kFinalizeGraph,
208 CompilerPass::kAllocateRegisters,
209 CompilerPass::kReorderBlocks,
210 });
211}
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 auto pipeline = CompilationPipeline::New(zone, function_);
124
125 parsed_function_ = new (zone)
126 ParsedFunction(thread, Function::ZoneHandle(zone, function_.ptr()));
127 pipeline->ParseFunction(parsed_function_);
128
129 // Extract type feedback before the graph is built, as the graph
130 // builder uses it to attach it to nodes.
131 ic_data_array_ = new (zone) ZoneGrowableArray<const ICData*>();
132 if (mode_ == CompilerPass::kJIT) {
133 function_.RestoreICDataMap(ic_data_array_, /*clone_ic_data=*/false);
134 }
135
136 flow_graph_ = pipeline->BuildFlowGraph(zone, parsed_function_, ic_data_array_,
137 osr_id, optimized);
138
139 if (mode_ == CompilerPass::kAOT) {
140 flow_graph_->PopulateWithICData(function_);
141 }
142
143 if (mode_ == CompilerPass::kJIT && flow_graph_->should_reorder_blocks()) {
145 }
146
147 pass_state_ =
148 new CompilerPassState(thread, flow_graph_, speculative_policy_.get());
149
150 if (optimized) {
151 JitCallSpecializer jit_call_specializer(flow_graph_,
152 speculative_policy_.get());
153 AotCallSpecializer aot_call_specializer(
154 /*precompiler=*/nullptr, flow_graph_, speculative_policy_.get());
155 if (mode_ == CompilerPass::kAOT) {
156 pass_state_->call_specializer = &aot_call_specializer;
157 } else {
158 pass_state_->call_specializer = &jit_call_specializer;
159 }
160
161 if (passes.size() > 0) {
162 flow_graph_ = CompilerPass::RunPipelineWithPasses(pass_state_, passes);
163 } else {
164 flow_graph_ = CompilerPass::RunPipeline(mode_, pass_state_);
165 }
166 pass_state_->call_specializer = nullptr;
167 }
168
169 return flow_graph_;
170}
static void AssignEdgeWeights(FlowGraph *flow_graph)
static CompilationPipeline * New(Zone *zone, const Function &function)
Definition compiler.cc:202
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipeline(PipelineMode mode, CompilerPassState *state)
static constexpr intptr_t kNoOSRDeoptId
Definition compiler.h:73
void PopulateWithICData(const Function &function)
bool should_reorder_blocks() const
Definition flow_graph.h:510
void RestoreICDataMap(ZoneGrowableArray< const ICData * > *deopt_id_to_ic_data, bool clone_ic_data) const
Definition object.cc:11275
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: