21#if defined(DART_PRECOMPILER)
28#define COMPILER_PASS_REPEAT(Name, Body) \
29 class CompilerPass_##Name : public CompilerPass { \
31 CompilerPass_##Name() : CompilerPass(k##Name, #Name) {} \
33 static bool Register() { \
38 virtual bool DoBody(CompilerPassState* state) const { \
39 FlowGraph* flow_graph = state->flow_graph(); \
44 static CompilerPass_##Name compiler_pass_##Name;
46#define COMPILER_PASS(Name, Body) \
47 COMPILER_PASS_REPEAT(Name, { \
60 precompiler(precompiler),
63 call_specializer(nullptr),
64 speculative_policy(speculative_policy),
66 flow_graph_(flow_graph) {
83 "List of comma separated compilation passes flags. "
84 "Use -Name to disable a pass, Name to print IL after it. "
85 "Do --compiler-passes=help for more information.");
88DEFINE_FLAG(
bool, test_il_serialization,
false,
"Test IL serialization.");
98 "=== How to use --compiler-passes flag\n"
100 "Pass the list of comma separated compiler pass filter flags.\n"
102 "For the given pass Name the following flags are supported:\n"
104 " -Name disable the pass\n"
105 " ]Name or Name print IL after the pass\n"
106 " [Name print IL before the pass\n"
107 " *Name print IL before and after the pass\n"
108 " * print IL after each pass.\n"
110 " The flag can be followed by '+' which makes it sticky, e.g. Inlining+\n"
111 " would cause IL to be printed after all passes that follow inlining and\n"
112 " are not disabled.\n"
114 "List of compiler passes:\n";
128 if (filter ==
nullptr || *filter == 0) {
132 if (strcmp(filter,
"help") == 0) {
135 if (passes_[
i] !=
nullptr) {
145 for (
const char *
start = filter, *
end = filter; *
end != 0;
149 while (*
end !=
',' && *
end !=
'\0') {
163 uint8_t* pass_flags) {
167 }
else if (*
start ==
']') {
169 }
else if (*
start ==
'[') {
171 }
else if (*
start ==
'*') {
181 if (
end[-1] ==
'+') {
183 OS::PrintErr(
"Sticky modifier '+' should follow pass name\n");
194 if (pass !=
nullptr) {
195 pass_flags[pass->
id()] |=
flags;
216 const intptr_t kMaxRounds = 2;
237 FlowGraphChecker(
state->flow_graph(),
state->inline_id_to_function)
247 intptr_t
round)
const {
250 const uint8_t current_flags =
251 (graph_flags !=
nullptr ? graph_flags[
id()] :
flags()) |
254 if ((FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) &&
255 flow_graph->
should_print() && ((current_flags & mask) != 0)) {
257 const char* when = mask ==
kTraceBefore ?
"Before" :
"After";
267#define INVOKE_PASS(Name) \
268 CompilerPass::Get(CompilerPass::k##Name)->Run(pass_state);
270#if defined(DART_PRECOMPILER)
271#define INVOKE_PASS_AOT(Name) \
272 if (mode == kAOT) { \
276#define INVOKE_PASS_AOT(Name)
363 INVOKE_PASS(AllocationSinking_DetachMaterializations);
377 std::initializer_list<CompilerPass::Id> passes) {
378 for (
auto pass_id : passes) {
381 return state->flow_graph();
398 flow_graph, &
state->inline_id_to_function, &
state->inline_id_to_token_pos,
399 &
state->caller_inline_id,
state->speculative_policy,
state->precompiler);
404 { FlowGraphTypePropagator::Propagate(flow_graph); });
410 CheckStackOverflowElimination::EliminateStackOverflow(flow_graph);
417 flow_graph->Canonicalize();
433 LICM licm(flow_graph);
452 state->call_specializer->ReplaceInstanceCallsWithDispatchTableCalls();
460 LICM licm(flow_graph);
502 state->sinking = new AllocationSinking(flow_graph);
503 state->sinking->Optimize();
508 if (
state->sinking !=
nullptr) {
513 state->sinking->DetachMaterializations();
543 intptr_t instruction_count = 0;
544 intptr_t call_site_count = 0;
547 true, &instruction_count,
549 flow_graph->
function().set_inlining_depth(
state->inlining_depth);
static void round(SkPoint *p)
static unsigned repeat(SkFixed fx, int max)
#define DEBUG_ASSERT(cond)
DART_FORCE_INLINE intptr_t bytes_written() const
static void ReorderBlocks(FlowGraph *flow_graph)
static void Simplify(FlowGraph *flow_graph)
void set_flow_graph(FlowGraph *flow_graph)
void Run(CompilerPassState *state) const
static void ParseOneFilter(const char *start, const char *end, uint8_t *flags)
static CompilerPass * Get(Id id)
virtual bool DoBody(CompilerPassState *state) const =0
static uint8_t * ParseFiltersFromPragma(const char *filter)
static void RunGraphIntrinsicPipeline(CompilerPassState *state)
static void ParseFilters(const char *filter, uint8_t *flags)
static void RunInliningPipeline(PipelineMode mode, CompilerPassState *state)
static constexpr intptr_t kNumPasses
static void ParseFiltersFromFlag(const char *filter)
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipeline(PipelineMode mode, CompilerPassState *state, bool compute_ssa=true)
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipelineWithPasses(CompilerPassState *state, std::initializer_list< CompilerPass::Id > passes)
const char * name() const
void set_current_pass(const CompilerPass *pass, const CompilerPassState *pass_state)
static CompilerState & Current()
static void Optimize(FlowGraph *graph)
static void OptimizeBranches(FlowGraph *graph)
static void EliminateDeadPhis(FlowGraph *graph)
static void EliminateDeadCode(FlowGraph *graph)
static void Optimize(FlowGraph *graph)
static void Optimize(FlowGraph *graph)
static bool Optimize(FlowGraph *graph, bool run_load_optimization=true)
FlowGraph * ReadFlowGraph()
static void SetInliningId(FlowGraph *flow_graph, intptr_t inlining_id)
static void CollectGraphInfo(FlowGraph *flow_graph, intptr_t num_constant_args, bool force, intptr_t *instruction_count, intptr_t *call_site_count)
static void PrintGraph(const char *phase, FlowGraph *flow_graph)
void WriteFlowGraph(const FlowGraph &flow_graph, const ZoneGrowableArray< Definition * > &detached_defs)
GraphEntryInstr * graph_entry() const
bool should_print() const
bool VerifyRedefinitions()
void CompactSSA(ZoneGrowableArray< Definition * > *detached_defs=nullptr)
bool IsCompiledForOsr() const
const uint8_t * compiler_pass_filters() const
void RemoveRedefinitions(bool keep_checks=false)
void set_max_argument_slot_count(intptr_t count)
void InsertMoveArguments()
void EliminateEnvironments()
void disallow_unmatched_representations()
const LoopHierarchy & GetLoopHierarchy()
const Function & function() const
const ParsedFunction & parsed_function() const
void RenameUsesDominatedByRedefinitions()
void TryOptimizePatterns()
void ComputeSSA(ZoneGrowableArray< Definition * > *inlining_parameters)
void SelectRepresentations()
void ExtractNonInternalTypedDataPayloads()
const GrowableArray< CatchBlockEntryInstr * > & catch_entries() const
static void Simplify(FlowGraph *flow_graph)
void OptimisticallySpecializeSmiPhis()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
const Function & function() const
static ThreadState * Current()
static void Optimize(FlowGraph *flow_graph)
static char * StrNDup(const char *s, intptr_t n)
char * PrintToString(const char *format,...) PRINTF_ATTRIBUTE(2
ElementType * Alloc(intptr_t length)
#define INVOKE_PASS_AOT(Name)
#define INVOKE_PASS(Name)
#define COMPILER_TIMINGS_PASS_TIMER_SCOPE(thread, pass_id)
void OptimizeCatchEntryStates(FlowGraph *flow_graph, bool is_aot)
static const char * kCompilerPassesUsage
void EliminateWriteBarriers(FlowGraph *flow_graph)
DEFINE_OPTION_HANDLER(CompilerPass::ParseFiltersFromFlag, compiler_passes, "List of comma separated compilation passes flags. " "Use -Name to disable a pass, Name to print IL after it. " "Do --compiler-passes=help for more information.")
COMPILER_PASS(ComputeSSA, { flow_graph->ComputeSSA(nullptr);})
DEFINE_FLAG(bool, print_cluster_information, false, "Print information about clusters written to snapshot")
COMPILER_PASS_REPEAT(ConstantPropagation, { ConstantPropagator::Optimize(flow_graph);return true;})
DECLARE_FLAG(bool, show_invisible_frames)
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
CompilerPassState(Thread *thread, FlowGraph *flow_graph, SpeculativeInliningPolicy *speculative_policy, Precompiler *precompiler=nullptr)
CallSpecializer * call_specializer
FlowGraph * flow_graph() const
GrowableArray< intptr_t > caller_inline_id
GrowableArray< const Function * > inline_id_to_function
void set_flow_graph(FlowGraph *flow_graph)
#define TIMELINE_DURATION(thread, stream, name)