OLD | NEW |
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 | 16 |
17 DECLARE_FLAG(bool, compiler_stats); | 17 DECLARE_FLAG(bool, compiler_stats); |
| 18 DECLARE_FLAG(bool, compiler_benchmark); |
18 | 19 |
19 class CompilerStats { | 20 class CompilerStats { |
20 public: | 21 public: |
21 explicit CompilerStats(Isolate* isolate); | 22 explicit CompilerStats(Isolate* isolate); |
22 ~CompilerStats() { } | 23 ~CompilerStats() { } |
23 | 24 |
24 Isolate* isolate_; | 25 Isolate* isolate_; |
25 | 26 |
26 // TODO(hausner): add these timers to the timer list maintained | |
27 // in the isolate? | |
28 Timer parser_timer; // Cumulative runtime of parser. | 27 Timer parser_timer; // Cumulative runtime of parser. |
29 Timer scanner_timer; // Cumulative runtime of scanner. | 28 Timer scanner_timer; // Cumulative runtime of scanner. |
30 Timer codegen_timer; // Cumulative runtime of code generator. | 29 Timer codegen_timer; // Cumulative runtime of code generator. |
31 Timer graphbuilder_timer; // Included in codegen_timer. | 30 Timer graphbuilder_timer; // Included in codegen_timer. |
32 Timer ssa_timer; // Included in codegen_timer. | 31 Timer ssa_timer; // Included in codegen_timer. |
33 Timer graphinliner_timer; // Included in codegen_timer. | 32 Timer graphinliner_timer; // Included in codegen_timer. |
34 Timer graphinliner_parse_timer; // Included in codegen_timer. | 33 Timer graphinliner_parse_timer; // Included in codegen_timer. |
35 Timer graphinliner_build_timer; // Included in codegen_timer. | 34 Timer graphinliner_build_timer; // Included in codegen_timer. |
36 Timer graphinliner_ssa_timer; // Included in codegen_timer. | 35 Timer graphinliner_ssa_timer; // Included in codegen_timer. |
37 Timer graphinliner_opt_timer; // Included in codegen_timer. | 36 Timer graphinliner_opt_timer; // Included in codegen_timer. |
38 Timer graphinliner_subst_timer; // Included in codegen_timer. | 37 Timer graphinliner_subst_timer; // Included in codegen_timer. |
39 | 38 |
40 Timer graphoptimizer_timer; // Included in codegen_timer. | 39 Timer graphoptimizer_timer; // Included in codegen_timer. |
41 Timer graphcompiler_timer; // Included in codegen_timer. | 40 Timer graphcompiler_timer; // Included in codegen_timer. |
42 Timer codefinalizer_timer; // Included in codegen_timer. | 41 Timer codefinalizer_timer; // Included in codegen_timer. |
43 | 42 |
44 int64_t num_tokens_total; // Isolate + VM isolate | 43 int64_t num_tokens_total; // Isolate + VM isolate |
45 int64_t num_literal_tokens_total; | 44 int64_t num_literal_tokens_total; |
46 int64_t num_ident_tokens_total; | 45 int64_t num_ident_tokens_total; |
| 46 int64_t num_tokens_scanned; |
47 int64_t num_tokens_consumed; | 47 int64_t num_tokens_consumed; |
48 int64_t num_cached_consts; | 48 int64_t num_cached_consts; |
49 int64_t num_const_cache_hits; | 49 int64_t num_const_cache_hits; |
50 | 50 |
51 int64_t num_classes_parsed; | 51 int64_t num_classes_parsed; |
52 int64_t num_class_tokens; | 52 int64_t num_class_tokens; |
53 int64_t num_functions_parsed; // Num parsed functions. | 53 int64_t num_functions_parsed; // Num parsed functions. |
54 int64_t num_functions_compiled; // Num unoptimized compilations. | 54 int64_t num_functions_compiled; // Num unoptimized compilations. |
55 int64_t num_functions_optimized; // Num optimized compilations. | 55 int64_t num_functions_optimized; // Num optimized compilations. |
56 int64_t num_func_tokens_compiled; | 56 int64_t num_func_tokens_compiled; |
57 int64_t num_implicit_final_getters; | 57 int64_t num_implicit_final_getters; |
58 int64_t num_method_extractors; | 58 int64_t num_method_extractors; |
59 | 59 |
60 int64_t src_length; // Total number of characters in source. | 60 int64_t src_length; // Total number of characters in source. |
61 int64_t total_code_size; // Bytes allocated for code and meta info. | 61 int64_t total_code_size; // Bytes allocated for code and meta info. |
62 int64_t total_instr_size; // Total size of generated code in bytes. | 62 int64_t total_instr_size; // Total size of generated code in bytes. |
63 int64_t pc_desc_size; | 63 int64_t pc_desc_size; |
64 int64_t vardesc_size; | 64 int64_t vardesc_size; |
65 char* text; | 65 char* text; |
| 66 bool use_benchmark_output; |
66 | 67 |
| 68 // Update stats that are computed, e.g. token count. |
| 69 void Update(); |
| 70 |
| 71 void EnableBenchmark(); |
| 72 char* BenchmarkOutput(); |
67 char* PrintToZone(); | 73 char* PrintToZone(); |
68 }; | 74 }; |
69 | 75 |
70 // TODO(hausner): make the increment thread-safe. | 76 // TODO(hausner): make the increment thread-safe. |
71 #define INC_STAT(thread, counter, incr) \ | 77 #define INC_STAT(thread, counter, incr) \ |
72 if (FLAG_compiler_stats) { \ | 78 if (FLAG_compiler_stats) { \ |
73 (thread)->isolate()->compiler_stats()->counter += (incr); } | 79 (thread)->isolate()->compiler_stats()->counter += (incr); } |
74 | 80 |
75 #define STAT_VALUE(thread, counter) \ | 81 #define STAT_VALUE(thread, counter) \ |
76 ((FLAG_compiler_stats != false) ? \ | 82 ((FLAG_compiler_stats != false) ? \ |
77 (thread)->isolate()->compiler_stats()->counter : 0) | 83 (thread)->isolate()->compiler_stats()->counter : 0) |
78 | 84 |
79 #define CSTAT_TIMER_SCOPE(thr, t) \ | 85 #define CSTAT_TIMER_SCOPE(thr, t) \ |
80 TimerScope timer(FLAG_compiler_stats, \ | 86 TimerScope timer(FLAG_compiler_stats, \ |
81 FLAG_compiler_stats ? &((thr)->isolate()->compiler_stats()->t) : NULL, \ | 87 FLAG_compiler_stats ? &((thr)->isolate()->compiler_stats()->t) : NULL, \ |
82 thr); | 88 thr); |
83 | 89 |
84 } // namespace dart | 90 } // namespace dart |
85 | 91 |
86 #endif // VM_COMPILER_STATS_H_ | 92 #endif // VM_COMPILER_STATS_H_ |
OLD | NEW |