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 #include "vm/compiler_stats.h" | 5 #include "vm/compiler_stats.h" |
6 | 6 |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/log.h" | 8 #include "vm/log.h" |
9 #include "vm/object_graph.h" | 9 #include "vm/object_graph.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 private: | 46 private: |
47 Object& obj_; | 47 Object& obj_; |
48 CompilerStats* stats_; | 48 CompilerStats* stats_; |
49 }; | 49 }; |
50 | 50 |
51 | 51 |
52 CompilerStats::CompilerStats(Isolate* isolate) | 52 CompilerStats::CompilerStats(Isolate* isolate) |
53 : isolate_(isolate), | 53 : isolate_(isolate), |
54 parser_timer(true, "parser timer"), | 54 #define INITIALIZE_TIMER(timer_name, description) \ |
55 scanner_timer(true, "scanner timer"), | 55 timer_name(true, description), |
56 codegen_timer(true, "codegen timer"), | 56 STAT_TIMERS(INITIALIZE_TIMER) |
57 graphbuilder_timer(true, "flow graph builder timer"), | 57 #undef INITIALIZE_TIMER |
58 ssa_timer(true, "flow graph SSA timer"), | 58 |
59 graphinliner_timer(true, "flow graph inliner timer"), | 59 #define INITIALIZE_COUNTERS(counter_name) \ |
60 graphinliner_parse_timer(true, "inliner parsing timer"), | 60 counter_name(0), |
61 graphinliner_build_timer(true, "inliner building timer"), | 61 STAT_COUNTERS(INITIALIZE_COUNTERS) |
62 graphinliner_ssa_timer(true, "inliner SSA timer"), | 62 #undef INITIALIZE_COUNTERS |
63 graphinliner_opt_timer(true, "inliner optimization timer"), | |
64 graphinliner_subst_timer(true, "inliner substitution timer"), | |
65 graphoptimizer_timer(true, "flow graph optimizer timer"), | |
66 graphcompiler_timer(true, "flow graph compiler timer"), | |
67 codefinalizer_timer(true, "code finalization timer"), | |
68 num_tokens_total(0), | |
69 num_tokens_scanned(0), | |
70 num_tokens_consumed(0), | |
71 num_cached_consts(0), | |
72 num_const_cache_hits(0), | |
73 num_classes_parsed(0), | |
74 num_class_tokens(0), | |
75 num_functions_parsed(0), | |
76 num_functions_compiled(0), | |
77 num_functions_optimized(0), | |
78 num_func_tokens_compiled(0), | |
79 num_implicit_final_getters(0), | |
80 num_method_extractors(0), | |
81 src_length(0), | |
82 total_code_size(0), | |
83 total_instr_size(0), | |
84 pc_desc_size(0), | |
85 vardesc_size(0), | |
86 text(NULL), | 63 text(NULL), |
87 use_benchmark_output(false) { | 64 use_benchmark_output(false) { |
88 } | 65 } |
89 | 66 |
90 | 67 |
91 #ifndef PRODUCT | 68 #ifndef PRODUCT |
92 | 69 |
| 70 |
| 71 |
| 72 // Used to aggregate stats. Must be atomic. |
| 73 void CompilerStats::Add(const CompilerStats& other) { |
| 74 #define ADD_TOTAL(timer_name, literal) \ |
| 75 timer_name.AddTotal(other.timer_name); |
| 76 |
| 77 STAT_TIMERS(ADD_TOTAL) |
| 78 #undef ADD_TOTAL |
| 79 |
| 80 #define ADD_COUNTER(counter_name) \ |
| 81 AtomicOperations::IncrementInt64By(&counter_name, other.counter_name); |
| 82 |
| 83 STAT_COUNTERS(ADD_COUNTER) |
| 84 #undef ADD_COUNTER |
| 85 } |
| 86 |
| 87 |
| 88 void CompilerStats::Clear() { |
| 89 #define CLEAR_TIMER(timer_name, literal) \ |
| 90 timer_name.Reset(); |
| 91 |
| 92 STAT_TIMERS(CLEAR_TIMER) |
| 93 #undef CLEAR_TIMER |
| 94 |
| 95 #define CLEAR_COUNTER(counter_name) \ |
| 96 counter_name = 0; |
| 97 |
| 98 STAT_COUNTERS(CLEAR_COUNTER) |
| 99 #undef CLEAR_COUNTER |
| 100 } |
| 101 |
| 102 |
| 103 bool CompilerStats::IsCleared() const { |
| 104 #define CHECK_TIMERS(timer_name, literal) \ |
| 105 if (!timer_name.IsReset()) return false; |
| 106 |
| 107 STAT_TIMERS(CHECK_TIMERS) |
| 108 #undef CHECK_TIMERS |
| 109 |
| 110 #define CHECK_COUNTERS(counter_name) \ |
| 111 if (counter_name != 0) return false; |
| 112 |
| 113 STAT_COUNTERS(CHECK_COUNTERS) |
| 114 #undef CHECK_COUNTERS |
| 115 return true; |
| 116 } |
| 117 |
| 118 |
93 // This function is used as a callback in the log object to which the | 119 // This function is used as a callback in the log object to which the |
94 // compiler stats are printed. It will be called only once, to print | 120 // compiler stats are printed. It will be called only once, to print |
95 // the accumulated text when all of the compiler stats values are | 121 // the accumulated text when all of the compiler stats values are |
96 // added to the log. | 122 // added to the log. |
97 static void PrintToStats(const char* format, ...) PRINTF_ATTRIBUTE(1, 2); | 123 static void PrintToStats(const char* format, ...) PRINTF_ATTRIBUTE(1, 2); |
98 static void PrintToStats(const char* format, ...) { | 124 static void PrintToStats(const char* format, ...) { |
99 Thread* thread = Thread::Current(); | 125 Thread* thread = Thread::Current(); |
100 Isolate* isolate = thread->isolate(); | 126 Isolate* isolate = thread->isolate(); |
101 CompilerStats* stats = isolate->compiler_stats(); | 127 CompilerStats* stats = isolate->aggregate_compiler_stats(); |
102 Zone* zone = thread->zone(); | 128 Zone* zone = thread->zone(); |
103 ASSERT(stats != NULL); | 129 ASSERT(stats != NULL); |
104 va_list args; | 130 va_list args; |
105 va_start(args, format); | 131 va_start(args, format); |
106 stats->text = zone->VPrint(format, args); | 132 stats->text = zone->VPrint(format, args); |
107 va_end(args); | 133 va_end(args); |
108 } | 134 } |
109 | 135 |
110 | 136 |
111 void CompilerStats::Update() { | 137 void CompilerStats::Update() { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024); | 309 log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024); |
284 log.Flush(); | 310 log.Flush(); |
285 char* stats_text = text; | 311 char* stats_text = text; |
286 text = NULL; | 312 text = NULL; |
287 return stats_text; | 313 return stats_text; |
288 } | 314 } |
289 | 315 |
290 #endif // !PRODUCT | 316 #endif // !PRODUCT |
291 | 317 |
292 } // namespace dart | 318 } // namespace dart |
OLD | NEW |