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

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: cleanup 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
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/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
11 #include "vm/timer.h" 11 #include "vm/timer.h"
12 12
13 13
14 namespace dart { 14 namespace dart {
15 15
16
17 DECLARE_FLAG(bool, compiler_stats); 16 DECLARE_FLAG(bool, compiler_stats);
18 DECLARE_FLAG(bool, compiler_benchmark); 17 DECLARE_FLAG(bool, compiler_benchmark);
19 18
19
20 #define STAT_TIMERS(V) \
21 V(parser_timer, "parser timer") \
22 V(scanner_timer, "scanner timer") \
23 V(codegen_timer, "codegen timer") \
24 V(graphbuilder_timer, "flow graph builder timer") \
25 V(ssa_timer, "flow graph SSA timer") \
26 V(graphinliner_timer, "flow graph inliner timer") \
27 V(graphinliner_parse_timer, "inliner parsing timer") \
28 V(graphinliner_build_timer, "inliner building timer") \
29 V(graphinliner_ssa_timer, "inliner SSA timer") \
30 V(graphinliner_opt_timer, "inliner optimization timer") \
31 V(graphinliner_subst_timer, "inliner substitution timer") \
32 V(graphoptimizer_timer, "flow graph optimizer timer") \
33 V(graphcompiler_timer, "flow graph compiler timer") \
34 V(codefinalizer_timer, "code finalization timer") \
35
36
37 #define STAT_COUNTERS(V) \
38 V(num_tokens_total) \
39 V(num_tokens_scanned) \
40 V(num_tokens_consumed) \
41 V(num_cached_consts) \
42 V(num_const_cache_hits) \
43 V(num_classes_parsed) \
44 V(num_class_tokens) \
45 V(num_functions_parsed) \
46 V(num_functions_compiled) \
47 V(num_functions_optimized) \
48 V(num_func_tokens_compiled) \
49 V(num_implicit_final_getters) \
50 V(num_method_extractors) \
51 V(src_length) \
52 V(total_code_size) \
53 V(total_instr_size) \
54 V(pc_desc_size) \
55 V(vardesc_size) \
56
20 class CompilerStats { 57 class CompilerStats {
21 public: 58 public:
22 explicit CompilerStats(Isolate* isolate); 59 explicit CompilerStats(Isolate* isolate);
23 ~CompilerStats() { } 60 ~CompilerStats() { }
24 61
25 Isolate* isolate_; 62 Isolate* isolate_;
26 63
64 // We could use STAT_TIMERS and STAT_COUNTERS to declare fields, but then
65 // we would be loosing the comments.
hausner 2016/03/30 19:49:20 loosing -> losing
srdjan 2016/03/30 20:14:04 Done.
27 Timer parser_timer; // Cumulative runtime of parser. 66 Timer parser_timer; // Cumulative runtime of parser.
28 Timer scanner_timer; // Cumulative runtime of scanner. 67 Timer scanner_timer; // Cumulative runtime of scanner.
29 Timer codegen_timer; // Cumulative runtime of code generator. 68 Timer codegen_timer; // Cumulative runtime of code generator.
30 Timer graphbuilder_timer; // Included in codegen_timer. 69 Timer graphbuilder_timer; // Included in codegen_timer.
31 Timer ssa_timer; // Included in codegen_timer. 70 Timer ssa_timer; // Included in codegen_timer.
32 Timer graphinliner_timer; // Included in codegen_timer. 71 Timer graphinliner_timer; // Included in codegen_timer.
33 Timer graphinliner_parse_timer; // Included in codegen_timer. 72 Timer graphinliner_parse_timer; // Included in codegen_timer.
34 Timer graphinliner_build_timer; // Included in codegen_timer. 73 Timer graphinliner_build_timer; // Included in codegen_timer.
35 Timer graphinliner_ssa_timer; // Included in codegen_timer. 74 Timer graphinliner_ssa_timer; // Included in codegen_timer.
36 Timer graphinliner_opt_timer; // Included in codegen_timer. 75 Timer graphinliner_opt_timer; // Included in codegen_timer.
(...skipping 19 matching lines...) Expand all
56 int64_t num_method_extractors; 95 int64_t num_method_extractors;
57 96
58 int64_t src_length; // Total number of characters in source. 97 int64_t src_length; // Total number of characters in source.
59 int64_t total_code_size; // Bytes allocated for code and meta info. 98 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. 99 int64_t total_instr_size; // Total size of generated code in bytes.
61 int64_t pc_desc_size; 100 int64_t pc_desc_size;
62 int64_t vardesc_size; 101 int64_t vardesc_size;
63 char* text; 102 char* text;
64 bool use_benchmark_output; 103 bool use_benchmark_output;
65 104
66 // Update stats that are computed, e.g. token count.
67 void Update();
68 105
69 void EnableBenchmark(); 106 void EnableBenchmark();
70 char* BenchmarkOutput(); 107 char* BenchmarkOutput();
71 char* PrintToZone(); 108 char* PrintToZone();
109
110 // Used to aggregate stats.
111 void Add(const CompilerStats& other);
112 void Clear();
113
114 bool IsCleared() const;
115
116 private:
117 // Update stats that are computed, e.g. token count.
118 void Update();
72 }; 119 };
73 120
74 #define INC_STAT(thread, counter, incr) \ 121 #define INC_STAT(thread, counter, incr) \
75 if (FLAG_support_compiler_stats && FLAG_compiler_stats) { \ 122 if (FLAG_support_compiler_stats && FLAG_compiler_stats) { \
76 MutexLocker ml((thread)->isolate()->mutex()); \ 123 (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).
77 (thread)->isolate()->compiler_stats()->counter += (incr); \
78 } 124 }
79 125
80 #define STAT_VALUE(thread, counter) \ 126 #define STAT_VALUE(thread, counter) \
81 ((FLAG_support_compiler_stats && FLAG_compiler_stats) ? \ 127 ((FLAG_support_compiler_stats && FLAG_compiler_stats) ? \
82 (thread)->isolate()->compiler_stats()->counter : 0) 128 (thread)->compiler_stats()->counter : 0)
83 129
84 #define CSTAT_TIMER_SCOPE(thr, t) \ 130 #define CSTAT_TIMER_SCOPE(thr, t) \
85 TimerScope timer(FLAG_support_compiler_stats && FLAG_compiler_stats, \ 131 TimerScope timer(FLAG_support_compiler_stats && FLAG_compiler_stats, \
86 (FLAG_support_compiler_stats && FLAG_compiler_stats) ? \ 132 (FLAG_support_compiler_stats && FLAG_compiler_stats) ? \
87 &((thr)->isolate()->compiler_stats()->t) : NULL, \ 133 &((thr)->compiler_stats()->t) : NULL, \
88 thr); 134 thr);
89 135
90 136
91 } // namespace dart 137 } // namespace dart
92 138
93 #endif // VM_COMPILER_STATS_H_ 139 #endif // VM_COMPILER_STATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698