Chromium Code Reviews| Index: runtime/vm/compiler_stats.h |
| diff --git a/runtime/vm/compiler_stats.h b/runtime/vm/compiler_stats.h |
| index 9b9e67b7a0898677cf81139b7cfdc66ac1a54b8e..a1a9b88507478b9b35a8085e84744621256639a5 100644 |
| --- a/runtime/vm/compiler_stats.h |
| +++ b/runtime/vm/compiler_stats.h |
| @@ -13,10 +13,47 @@ |
| namespace dart { |
| - |
| DECLARE_FLAG(bool, compiler_stats); |
| DECLARE_FLAG(bool, compiler_benchmark); |
| + |
| +#define STAT_TIMERS(V) \ |
| + V(parser_timer, "parser timer") \ |
| + V(scanner_timer, "scanner timer") \ |
| + V(codegen_timer, "codegen timer") \ |
| + V(graphbuilder_timer, "flow graph builder timer") \ |
| + V(ssa_timer, "flow graph SSA timer") \ |
| + V(graphinliner_timer, "flow graph inliner timer") \ |
| + V(graphinliner_parse_timer, "inliner parsing timer") \ |
| + V(graphinliner_build_timer, "inliner building timer") \ |
| + V(graphinliner_ssa_timer, "inliner SSA timer") \ |
| + V(graphinliner_opt_timer, "inliner optimization timer") \ |
| + V(graphinliner_subst_timer, "inliner substitution timer") \ |
| + V(graphoptimizer_timer, "flow graph optimizer timer") \ |
| + V(graphcompiler_timer, "flow graph compiler timer") \ |
| + V(codefinalizer_timer, "code finalization timer") \ |
| + |
| + |
| +#define STAT_COUNTERS(V) \ |
| + V(num_tokens_total) \ |
| + V(num_tokens_scanned) \ |
| + V(num_tokens_consumed) \ |
| + V(num_cached_consts) \ |
| + V(num_const_cache_hits) \ |
| + V(num_classes_parsed) \ |
| + V(num_class_tokens) \ |
| + V(num_functions_parsed) \ |
| + V(num_functions_compiled) \ |
| + V(num_functions_optimized) \ |
| + V(num_func_tokens_compiled) \ |
| + V(num_implicit_final_getters) \ |
| + V(num_method_extractors) \ |
| + V(src_length) \ |
| + V(total_code_size) \ |
| + V(total_instr_size) \ |
| + V(pc_desc_size) \ |
| + V(vardesc_size) \ |
| + |
| class CompilerStats { |
| public: |
| explicit CompilerStats(Isolate* isolate); |
| @@ -24,6 +61,8 @@ class CompilerStats { |
| Isolate* isolate_; |
| + // We could use STAT_TIMERS and STAT_COUNTERS to declare fields, but then |
| + // we would be loosing the comments. |
|
hausner
2016/03/30 19:49:20
loosing -> losing
srdjan
2016/03/30 20:14:04
Done.
|
| Timer parser_timer; // Cumulative runtime of parser. |
| Timer scanner_timer; // Cumulative runtime of scanner. |
| Timer codegen_timer; // Cumulative runtime of code generator. |
| @@ -63,28 +102,35 @@ class CompilerStats { |
| char* text; |
| bool use_benchmark_output; |
| - // Update stats that are computed, e.g. token count. |
| - void Update(); |
| void EnableBenchmark(); |
| char* BenchmarkOutput(); |
| char* PrintToZone(); |
| + |
| + // Used to aggregate stats. |
| + void Add(const CompilerStats& other); |
| + void Clear(); |
| + |
| + bool IsCleared() const; |
| + |
| + private: |
| + // Update stats that are computed, e.g. token count. |
| + void Update(); |
| }; |
| #define INC_STAT(thread, counter, incr) \ |
| if (FLAG_support_compiler_stats && FLAG_compiler_stats) { \ |
| - MutexLocker ml((thread)->isolate()->mutex()); \ |
| - (thread)->isolate()->compiler_stats()->counter += (incr); \ |
| + (thread)->compiler_stats()->counter += (incr); \ |
|
hausner
2016/03/30 19:49:20
Does this work correctly if the background thread
srdjan
2016/03/30 20:14:04
Added AtomicOperation on it (and total_ in Timer).
|
| } |
| #define STAT_VALUE(thread, counter) \ |
| ((FLAG_support_compiler_stats && FLAG_compiler_stats) ? \ |
| - (thread)->isolate()->compiler_stats()->counter : 0) |
| + (thread)->compiler_stats()->counter : 0) |
| #define CSTAT_TIMER_SCOPE(thr, t) \ |
| TimerScope timer(FLAG_support_compiler_stats && FLAG_compiler_stats, \ |
| (FLAG_support_compiler_stats && FLAG_compiler_stats) ? \ |
| - &((thr)->isolate()->compiler_stats()->t) : NULL, \ |
| + &((thr)->compiler_stats()->t) : NULL, \ |
| thr); |