Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Unified Diff: runtime/vm/compiler_stats.h

Issue 1841213003: Move CompilerStats from isolate to thread. Aggregate stats. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: review comments addressed Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/compiler_stats.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler_stats.h
diff --git a/runtime/vm/compiler_stats.h b/runtime/vm/compiler_stats.h
index 9b9e67b7a0898677cf81139b7cfdc66ac1a54b8e..5ed753703f311b300399d9bb109bdf9a70dfd862 100644
--- a/runtime/vm/compiler_stats.h
+++ b/runtime/vm/compiler_stats.h
@@ -6,6 +6,7 @@
#define VM_COMPILER_STATS_H_
#include "vm/allocation.h"
+#include "vm/atomic.h"
#include "vm/flags.h"
#include "vm/isolate.h"
#include "vm/timer.h"
@@ -13,10 +14,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 +62,8 @@ class CompilerStats {
Isolate* isolate_;
+ // We could use STAT_TIMERS and STAT_COUNTERS to declare fields, but then
+ // we would be losing the comments.
Timer parser_timer; // Cumulative runtime of parser.
Timer scanner_timer; // Cumulative runtime of scanner.
Timer codegen_timer; // Cumulative runtime of code generator.
@@ -63,28 +103,38 @@ 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();
};
+// Make increment atomic in case it occurs in parallel with aggregation from
+// other thread.
#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); \
+ AtomicOperations::IncrementInt64By( \
+ &(thread)->compiler_stats()->counter, (incr)); \
}
#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);
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/compiler_stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698