Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
compiler_timings.h File Reference
#include <memory>
#include "platform/allocation.h"
#include "vm/compiler/compiler_pass.h"
#include "vm/thread.h"
#include "vm/timer.h"

Go to the source code of this file.

Classes

class  dart::CompilerTimings
 
class  dart::CompilerTimings::Scope
 

Namespaces

namespace  dart
 

Macros

#define PRECOMPILER_TIMERS_LIST(V)
 
#define INLINING_TIMERS_LIST(V)
 
#define COMPILER_TIMERS_LIST(V)
 
#define INC(Name)   +1
 
#define DECLARE_TIMER_ID(Name)   k##Name,
 
#define TIMER_SCOPE_NAME2(counter)   timer_scope_##counter
 
#define TIMER_SCOPE_NAME(counter)   TIMER_SCOPE_NAME2(counter)
 
#define COMPILER_TIMINGS_TIMER_SCOPE(thread, timer_id)
 
#define COMPILER_TIMINGS_PASS_TIMER_SCOPE(thread, pass_id)
 
#define PRECOMPILER_TIMER_SCOPE(precompiler, timer_id)
 

Macro Definition Documentation

◆ COMPILER_TIMERS_LIST

#define COMPILER_TIMERS_LIST (   V)
Value:
PRECOMPILER_TIMERS_LIST(V) \
INLINING_TIMERS_LIST(V) \
V(BuildGraph) \
V(EmitCode) \
V(FinalizeCode)
#define COMPILER_PASS_LIST(V)
T __attribute__((ext_vector_type(N))) V

Definition at line 51 of file compiler_timings.h.

58 {
59
60// |CompilerTimings| provides a way to track time taken by various compiler
61// passes via a fixed number of timers (specified in |COMPILER_TIMERS_LIST|).
62//
63// It supports arbitrary nesting of timers e.g. if |DiscoverBlocks| is invoked
64// within two different compiler passes like |IfConvert| and |BranchSimplify|
65// then |CompilerTimings| will separate these two invocations and measure each
66// separately.
67class CompilerTimings : public MallocAllocated {
68 private:
69#define INC(Name) +1
70 static constexpr intptr_t kNumTimers = 0 COMPILER_TIMERS_LIST(INC);
71#undef INC
72
73 struct Timers : public MallocAllocated {
74 Timer timers_[kNumTimers];
75 std::unique_ptr<Timers> nested_[kNumTimers];
76 };
77
78 public:
79 enum TimerId {
80#define DECLARE_TIMER_ID(Name) k##Name,
82#undef DECLARE_TIMER_ID
83 };
84
85 // Timing scope which starts and stop the timer with the given |id|.
86 class Scope : public StackResource {
87 public:
88 Scope(Thread* thread, TimerId id)
89 : StackResource(thread), stats_(thread->compiler_timings()) {
90 if (stats_ != nullptr) {
91 outer_nested_ = stats_->nested_;
92 if (*outer_nested_ == nullptr) {
93 // Created array of nested timers if we don't have one yet.
94 *outer_nested_ = std::make_unique<Timers>();
95 }
96
97 timer_ = &(*outer_nested_)->timers_[id];
98 stats_->nested_ = &(*outer_nested_)->nested_[id];
99
100 timer_->Start();
101 }
102 }
103
104 ~Scope() {
105 if (stats_ != nullptr) {
106 timer_->Stop();
107 stats_->nested_ = outer_nested_;
108 }
109 }
110
111 private:
112 CompilerTimings* const stats_;
113 Timer* timer_;
114 std::unique_ptr<Timers>* outer_nested_;
115 };
116
117 CompilerTimings() { total_.Start(); }
118
119 void RecordInliningStatsByOutcome(bool success, const Timer& timer) {
120 if (success) {
121 try_inlining_success_.AddTotal(timer);
122 } else {
123 try_inlining_failure_.AddTotal(timer);
124 }
125 }
126
127 void Print();
128
129 private:
130 void PrintTimers(Zone* zone,
131 const std::unique_ptr<CompilerTimings::Timers>& timers,
132 const Timer& total,
133 intptr_t level);
134
135 Timer total_;
136 std::unique_ptr<Timers> root_ = std::make_unique<Timers>();
137
138 // Timers nested under the currently running timer(s).
139 std::unique_ptr<Timers>* nested_ = &root_;
140
141 Timer try_inlining_success_;
142 Timer try_inlining_failure_;
143};
144
145#define TIMER_SCOPE_NAME2(counter) timer_scope_##counter
146#define TIMER_SCOPE_NAME(counter) TIMER_SCOPE_NAME2(counter)
147
148#define COMPILER_TIMINGS_TIMER_SCOPE(thread, timer_id) \
149 CompilerTimings::Scope TIMER_SCOPE_NAME(__COUNTER__)( \
150 thread, CompilerTimings::k##timer_id)
151
152#define COMPILER_TIMINGS_PASS_TIMER_SCOPE(thread, pass_id) \
153 CompilerTimings::Scope TIMER_SCOPE_NAME(__COUNTER__)( \
154 thread, static_cast<CompilerTimings::TimerId>(pass_id))
155
156#define PRECOMPILER_TIMER_SCOPE(precompiler, timer_id) \
157 CompilerTimings::Scope TIMER_SCOPE_NAME(__COUNTER__)( \
158 (precompiler) -> thread(), CompilerTimings::k##timer_id)
159
160} // namespace dart
161
162#endif // RUNTIME_VM_COMPILER_COMPILER_TIMINGS_H_
#define DECLARE_TIMER_ID(Name)
#define INC(Name)
#define COMPILER_TIMERS_LIST(V)
const uintptr_t id

◆ COMPILER_TIMINGS_PASS_TIMER_SCOPE

#define COMPILER_TIMINGS_PASS_TIMER_SCOPE (   thread,
  pass_id 
)
Value:
CompilerTimings::Scope TIMER_SCOPE_NAME(__COUNTER__)( \
thread, static_cast<CompilerTimings::TimerId>(pass_id))
#define TIMER_SCOPE_NAME(counter)

Definition at line 153 of file compiler_timings.h.

◆ COMPILER_TIMINGS_TIMER_SCOPE

#define COMPILER_TIMINGS_TIMER_SCOPE (   thread,
  timer_id 
)
Value:
CompilerTimings::Scope TIMER_SCOPE_NAME(__COUNTER__)( \
thread, CompilerTimings::k##timer_id)

Definition at line 149 of file compiler_timings.h.

◆ DECLARE_TIMER_ID

#define DECLARE_TIMER_ID (   Name)    k##Name,

Definition at line 81 of file compiler_timings.h.

◆ INC

#define INC (   Name)    +1

Definition at line 70 of file compiler_timings.h.

◆ INLINING_TIMERS_LIST

#define INLINING_TIMERS_LIST (   V)
Value:
V(CollectGraphInfo) \
V(PopulateWithICData) \
V(FindCallSites) \
V(SetInliningId) \
V(MakeInliningDecision) \
V(CheckForPragma) \
V(InlineCall) \
V(InlineRecognizedMethod) \
V(DiscoverBlocks) \
V(BuildDecisionGraph) \
V(PrepareGraphs)
#define V(name)
Definition raw_object.h:124

Definition at line 36 of file compiler_timings.h.

◆ PRECOMPILER_TIMER_SCOPE

#define PRECOMPILER_TIMER_SCOPE (   precompiler,
  timer_id 
)
Value:
CompilerTimings::Scope TIMER_SCOPE_NAME(__COUNTER__)( \
(precompiler) -> thread(), CompilerTimings::k##timer_id)

Definition at line 157 of file compiler_timings.h.

◆ PRECOMPILER_TIMERS_LIST

#define PRECOMPILER_TIMERS_LIST (   V)
Value:
V(CompileAll) \
V(Iterate) \
V(CompileFunction) \
V(AddCalleesOf) \
V(CheckForNewDynamicFunctions) \
V(CollectCallbackFields) \
V(PrecompileConstructors) \
V(AttachOptimizedTypeTestingStub) \
V(TraceForRetainedFunctions) \
V(FinalizeDispatchTable) \
V(ReplaceFunctionStaticCallEntries) \
V(Drop) \
V(Obfuscate) \
V(Dedup) \
V(SymbolsCompact)

Definition at line 19 of file compiler_timings.h.

◆ TIMER_SCOPE_NAME

#define TIMER_SCOPE_NAME (   counter)    TIMER_SCOPE_NAME2(counter)

Definition at line 147 of file compiler_timings.h.

◆ TIMER_SCOPE_NAME2

#define TIMER_SCOPE_NAME2 (   counter)    timer_scope_##counter

Definition at line 146 of file compiler_timings.h.