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 | |
15 namespace dart { | 14 namespace dart { |
16 | 15 |
| 16 |
17 DECLARE_FLAG(bool, compiler_stats); | 17 DECLARE_FLAG(bool, compiler_stats); |
18 | 18 |
19 // TODO(hausner): Might want to expose some of these values in the | |
20 // observatory. Use the metrics mechanism (metrics.h) for this. | |
21 | |
22 class CompilerStats { | 19 class CompilerStats { |
23 public: | 20 public: |
24 explicit CompilerStats(Isolate* isolate); | 21 explicit CompilerStats(Isolate* isolate); |
25 ~CompilerStats() { } | 22 ~CompilerStats() { } |
26 | 23 |
27 Isolate* isolate_; | 24 Isolate* isolate_; |
28 | 25 |
29 // TODO(hausner): add these timers to the timer list maintained | 26 // TODO(hausner): add these timers to the timer list maintained |
30 // in the isolate? | 27 // in the isolate? |
31 Timer parser_timer; // Cumulative runtime of parser. | 28 Timer parser_timer; // Cumulative runtime of parser. |
32 Timer scanner_timer; // Cumulative runtime of scanner. | 29 Timer scanner_timer; // Cumulative runtime of scanner. |
33 Timer codegen_timer; // Cumulative runtime of code generator. | 30 Timer codegen_timer; // Cumulative runtime of code generator. |
34 Timer graphbuilder_timer; // Included in codegen_timer. | 31 Timer graphbuilder_timer; // Included in codegen_timer. |
35 Timer ssa_timer; // Included in codegen_timer. | 32 Timer ssa_timer; // Included in codegen_timer. |
36 Timer graphinliner_timer; // Included in codegen_timer. | 33 Timer graphinliner_timer; // Included in codegen_timer. |
37 Timer graphinliner_parse_timer; // Included in codegen_timer. | 34 Timer graphinliner_parse_timer; // Included in codegen_timer. |
38 Timer graphinliner_build_timer; // Included in codegen_timer. | 35 Timer graphinliner_build_timer; // Included in codegen_timer. |
39 Timer graphinliner_ssa_timer; // Included in codegen_timer. | 36 Timer graphinliner_ssa_timer; // Included in codegen_timer. |
40 Timer graphinliner_opt_timer; // Included in codegen_timer. | 37 Timer graphinliner_opt_timer; // Included in codegen_timer. |
41 Timer graphinliner_subst_timer; // Included in codegen_timer. | 38 Timer graphinliner_subst_timer; // Included in codegen_timer. |
42 | 39 |
43 Timer graphoptimizer_timer; // Included in codegen_timer. | 40 Timer graphoptimizer_timer; // Included in codegen_timer. |
44 Timer graphcompiler_timer; // Included in codegen_timer. | 41 Timer graphcompiler_timer; // Included in codegen_timer. |
45 Timer codefinalizer_timer; // Included in codegen_timer. | 42 Timer codefinalizer_timer; // Included in codegen_timer. |
46 | 43 |
47 int64_t num_tokens_total; | 44 int64_t num_tokens_total; // Isolate + VM isolate |
48 int64_t num_literal_tokens_total; | 45 int64_t num_literal_tokens_total; |
49 int64_t num_ident_tokens_total; | 46 int64_t num_ident_tokens_total; |
50 int64_t num_tokens_consumed; | 47 int64_t num_tokens_consumed; |
51 int64_t num_token_checks; | |
52 int64_t num_tokens_lookahead; | |
53 int64_t num_cached_consts; | 48 int64_t num_cached_consts; |
54 int64_t num_const_cache_hits; | 49 int64_t num_const_cache_hits; |
55 | 50 |
56 int64_t num_classes_compiled; | 51 int64_t num_classes_parsed; |
57 int64_t num_functions_compiled; | 52 int64_t num_class_tokens; |
| 53 int64_t num_functions_parsed; // Num parsed functions. |
| 54 int64_t num_functions_compiled; // Num unoptimized compilations. |
| 55 int64_t num_functions_optimized; // Num optimized compilations. |
| 56 int64_t num_func_tokens_compiled; |
58 int64_t num_implicit_final_getters; | 57 int64_t num_implicit_final_getters; |
| 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 | 66 |
66 void Print(); | 67 char* PrintToZone(); |
67 }; | 68 }; |
68 | 69 |
69 #define INC_STAT(isolate, counter, incr) \ | 70 // TODO(hausner): make the increment thread-safe. |
70 if (FLAG_compiler_stats) { (isolate)->compiler_stats()->counter += (incr); } | 71 #define INC_STAT(thread, counter, incr) \ |
| 72 if (FLAG_compiler_stats) { \ |
| 73 (thread)->isolate()->compiler_stats()->counter += (incr); } |
| 74 |
| 75 #define STAT_VALUE(thread, counter) \ |
| 76 ((FLAG_compiler_stats != false) ? \ |
| 77 (thread)->isolate()->compiler_stats()->counter : 0) |
71 | 78 |
72 #define CSTAT_TIMER_SCOPE(thr, t) \ | 79 #define CSTAT_TIMER_SCOPE(thr, t) \ |
73 TimerScope timer(FLAG_compiler_stats, \ | 80 TimerScope timer(FLAG_compiler_stats, \ |
74 FLAG_compiler_stats ? &((thr)->isolate()->compiler_stats()->t) : NULL, \ | 81 FLAG_compiler_stats ? &((thr)->isolate()->compiler_stats()->t) : NULL, \ |
75 thr); | 82 thr); |
76 | 83 |
77 } // namespace dart | 84 } // namespace dart |
78 | 85 |
79 #endif // VM_COMPILER_STATS_H_ | 86 #endif // VM_COMPILER_STATS_H_ |
OLD | NEW |