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

Side by Side 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, 8 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/compiler_stats.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_COMPILER_STATS_H_ 5 #ifndef VM_COMPILER_STATS_H_
6 #define VM_COMPILER_STATS_H_ 6 #define VM_COMPILER_STATS_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/atomic.h"
9 #include "vm/flags.h" 10 #include "vm/flags.h"
10 #include "vm/isolate.h" 11 #include "vm/isolate.h"
11 #include "vm/timer.h" 12 #include "vm/timer.h"
12 13
13 14
14 namespace dart { 15 namespace dart {
15 16
16
17 DECLARE_FLAG(bool, compiler_stats); 17 DECLARE_FLAG(bool, compiler_stats);
18 DECLARE_FLAG(bool, compiler_benchmark); 18 DECLARE_FLAG(bool, compiler_benchmark);
19 19
20
21 #define STAT_TIMERS(V) \
22 V(parser_timer, "parser timer") \
23 V(scanner_timer, "scanner timer") \
24 V(codegen_timer, "codegen timer") \
25 V(graphbuilder_timer, "flow graph builder timer") \
26 V(ssa_timer, "flow graph SSA timer") \
27 V(graphinliner_timer, "flow graph inliner timer") \
28 V(graphinliner_parse_timer, "inliner parsing timer") \
29 V(graphinliner_build_timer, "inliner building timer") \
30 V(graphinliner_ssa_timer, "inliner SSA timer") \
31 V(graphinliner_opt_timer, "inliner optimization timer") \
32 V(graphinliner_subst_timer, "inliner substitution timer") \
33 V(graphoptimizer_timer, "flow graph optimizer timer") \
34 V(graphcompiler_timer, "flow graph compiler timer") \
35 V(codefinalizer_timer, "code finalization timer") \
36
37
38 #define STAT_COUNTERS(V) \
39 V(num_tokens_total) \
40 V(num_tokens_scanned) \
41 V(num_tokens_consumed) \
42 V(num_cached_consts) \
43 V(num_const_cache_hits) \
44 V(num_classes_parsed) \
45 V(num_class_tokens) \
46 V(num_functions_parsed) \
47 V(num_functions_compiled) \
48 V(num_functions_optimized) \
49 V(num_func_tokens_compiled) \
50 V(num_implicit_final_getters) \
51 V(num_method_extractors) \
52 V(src_length) \
53 V(total_code_size) \
54 V(total_instr_size) \
55 V(pc_desc_size) \
56 V(vardesc_size) \
57
20 class CompilerStats { 58 class CompilerStats {
21 public: 59 public:
22 explicit CompilerStats(Isolate* isolate); 60 explicit CompilerStats(Isolate* isolate);
23 ~CompilerStats() { } 61 ~CompilerStats() { }
24 62
25 Isolate* isolate_; 63 Isolate* isolate_;
26 64
65 // We could use STAT_TIMERS and STAT_COUNTERS to declare fields, but then
66 // we would be losing the comments.
27 Timer parser_timer; // Cumulative runtime of parser. 67 Timer parser_timer; // Cumulative runtime of parser.
28 Timer scanner_timer; // Cumulative runtime of scanner. 68 Timer scanner_timer; // Cumulative runtime of scanner.
29 Timer codegen_timer; // Cumulative runtime of code generator. 69 Timer codegen_timer; // Cumulative runtime of code generator.
30 Timer graphbuilder_timer; // Included in codegen_timer. 70 Timer graphbuilder_timer; // Included in codegen_timer.
31 Timer ssa_timer; // Included in codegen_timer. 71 Timer ssa_timer; // Included in codegen_timer.
32 Timer graphinliner_timer; // Included in codegen_timer. 72 Timer graphinliner_timer; // Included in codegen_timer.
33 Timer graphinliner_parse_timer; // Included in codegen_timer. 73 Timer graphinliner_parse_timer; // Included in codegen_timer.
34 Timer graphinliner_build_timer; // Included in codegen_timer. 74 Timer graphinliner_build_timer; // Included in codegen_timer.
35 Timer graphinliner_ssa_timer; // Included in codegen_timer. 75 Timer graphinliner_ssa_timer; // Included in codegen_timer.
36 Timer graphinliner_opt_timer; // Included in codegen_timer. 76 Timer graphinliner_opt_timer; // Included in codegen_timer.
(...skipping 19 matching lines...) Expand all
56 int64_t num_method_extractors; 96 int64_t num_method_extractors;
57 97
58 int64_t src_length; // Total number of characters in source. 98 int64_t src_length; // Total number of characters in source.
59 int64_t total_code_size; // Bytes allocated for code and meta info. 99 int64_t total_code_size; // Bytes allocated for code and meta info.
60 int64_t total_instr_size; // Total size of generated code in bytes. 100 int64_t total_instr_size; // Total size of generated code in bytes.
61 int64_t pc_desc_size; 101 int64_t pc_desc_size;
62 int64_t vardesc_size; 102 int64_t vardesc_size;
63 char* text; 103 char* text;
64 bool use_benchmark_output; 104 bool use_benchmark_output;
65 105
66 // Update stats that are computed, e.g. token count.
67 void Update();
68 106
69 void EnableBenchmark(); 107 void EnableBenchmark();
70 char* BenchmarkOutput(); 108 char* BenchmarkOutput();
71 char* PrintToZone(); 109 char* PrintToZone();
110
111 // Used to aggregate stats.
112 void Add(const CompilerStats& other);
113 void Clear();
114
115 bool IsCleared() const;
116
117 private:
118 // Update stats that are computed, e.g. token count.
119 void Update();
72 }; 120 };
73 121
122 // Make increment atomic in case it occurs in parallel with aggregation from
123 // other thread.
74 #define INC_STAT(thread, counter, incr) \ 124 #define INC_STAT(thread, counter, incr) \
75 if (FLAG_support_compiler_stats && FLAG_compiler_stats) { \ 125 if (FLAG_support_compiler_stats && FLAG_compiler_stats) { \
76 MutexLocker ml((thread)->isolate()->mutex()); \ 126 AtomicOperations::IncrementInt64By( \
77 (thread)->isolate()->compiler_stats()->counter += (incr); \ 127 &(thread)->compiler_stats()->counter, (incr)); \
78 } 128 }
79 129
80 #define STAT_VALUE(thread, counter) \ 130 #define STAT_VALUE(thread, counter) \
81 ((FLAG_support_compiler_stats && FLAG_compiler_stats) ? \ 131 ((FLAG_support_compiler_stats && FLAG_compiler_stats) ? \
82 (thread)->isolate()->compiler_stats()->counter : 0) 132 (thread)->compiler_stats()->counter : 0)
83 133
84 #define CSTAT_TIMER_SCOPE(thr, t) \ 134 #define CSTAT_TIMER_SCOPE(thr, t) \
85 TimerScope timer(FLAG_support_compiler_stats && FLAG_compiler_stats, \ 135 TimerScope timer(FLAG_support_compiler_stats && FLAG_compiler_stats, \
86 (FLAG_support_compiler_stats && FLAG_compiler_stats) ? \ 136 (FLAG_support_compiler_stats && FLAG_compiler_stats) ? \
87 &((thr)->isolate()->compiler_stats()->t) : NULL, \ 137 &((thr)->compiler_stats()->t) : NULL, \
88 thr); 138 thr);
89 139
90 140
91 } // namespace dart 141 } // namespace dart
92 142
93 #endif // VM_COMPILER_STATS_H_ 143 #endif // VM_COMPILER_STATS_H_
OLDNEW
« 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