| 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/timer.h" | 10 #include "vm/timer.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return; | 30 return; |
| 31 } | 31 } |
| 32 obj_ = raw_obj; | 32 obj_ = raw_obj; |
| 33 if (obj_.GetClassId() == TokenStream::kClassId) { | 33 if (obj_.GetClassId() == TokenStream::kClassId) { |
| 34 TokenStream::Iterator tkit(TokenStream::Cast(obj_), | 34 TokenStream::Iterator tkit(TokenStream::Cast(obj_), |
| 35 0, | 35 0, |
| 36 TokenStream::Iterator::kNoNewlines); | 36 TokenStream::Iterator::kNoNewlines); |
| 37 Token::Kind kind = tkit.CurrentTokenKind(); | 37 Token::Kind kind = tkit.CurrentTokenKind(); |
| 38 while (kind != Token::kEOS) { | 38 while (kind != Token::kEOS) { |
| 39 ++stats_->num_tokens_total; | 39 ++stats_->num_tokens_total; |
| 40 if (kind == Token::kIDENT) { | |
| 41 ++stats_->num_ident_tokens_total; | |
| 42 } else if (Token::NeedsLiteralToken(kind)) { | |
| 43 ++stats_->num_literal_tokens_total; | |
| 44 } | |
| 45 tkit.Advance(); | 40 tkit.Advance(); |
| 46 kind = tkit.CurrentTokenKind(); | 41 kind = tkit.CurrentTokenKind(); |
| 47 } | 42 } |
| 48 } | 43 } |
| 49 } | 44 } |
| 50 | 45 |
| 51 private: | 46 private: |
| 52 Object& obj_; | 47 Object& obj_; |
| 53 CompilerStats* stats_; | 48 CompilerStats* stats_; |
| 54 }; | 49 }; |
| 55 | 50 |
| 56 | 51 |
| 57 CompilerStats::CompilerStats(Isolate* isolate) | 52 CompilerStats::CompilerStats(Isolate* isolate) |
| 58 : isolate_(isolate), | 53 : isolate_(isolate), |
| 59 parser_timer(true, "parser timer"), | 54 parser_timer(true, "parser timer"), |
| 60 scanner_timer(true, "scanner timer"), | 55 scanner_timer(true, "scanner timer"), |
| 61 codegen_timer(true, "codegen timer"), | 56 codegen_timer(true, "codegen timer"), |
| 62 graphbuilder_timer(true, "flow graph builder timer"), | 57 graphbuilder_timer(true, "flow graph builder timer"), |
| 63 ssa_timer(true, "flow graph SSA timer"), | 58 ssa_timer(true, "flow graph SSA timer"), |
| 64 graphinliner_timer(true, "flow graph inliner timer"), | 59 graphinliner_timer(true, "flow graph inliner timer"), |
| 65 graphinliner_parse_timer(true, "inliner parsing timer"), | 60 graphinliner_parse_timer(true, "inliner parsing timer"), |
| 66 graphinliner_build_timer(true, "inliner building timer"), | 61 graphinliner_build_timer(true, "inliner building timer"), |
| 67 graphinliner_ssa_timer(true, "inliner SSA timer"), | 62 graphinliner_ssa_timer(true, "inliner SSA timer"), |
| 68 graphinliner_opt_timer(true, "inliner optimization timer"), | 63 graphinliner_opt_timer(true, "inliner optimization timer"), |
| 69 graphinliner_subst_timer(true, "inliner substitution timer"), | 64 graphinliner_subst_timer(true, "inliner substitution timer"), |
| 70 graphoptimizer_timer(true, "flow graph optimizer timer"), | 65 graphoptimizer_timer(true, "flow graph optimizer timer"), |
| 71 graphcompiler_timer(true, "flow graph compiler timer"), | 66 graphcompiler_timer(true, "flow graph compiler timer"), |
| 72 codefinalizer_timer(true, "code finalization timer"), | 67 codefinalizer_timer(true, "code finalization timer"), |
| 73 num_tokens_total(0), | 68 num_tokens_total(0), |
| 74 num_literal_tokens_total(0), | |
| 75 num_ident_tokens_total(0), | |
| 76 num_tokens_scanned(0), | 69 num_tokens_scanned(0), |
| 77 num_tokens_consumed(0), | 70 num_tokens_consumed(0), |
| 78 num_cached_consts(0), | 71 num_cached_consts(0), |
| 79 num_const_cache_hits(0), | 72 num_const_cache_hits(0), |
| 80 num_classes_parsed(0), | 73 num_classes_parsed(0), |
| 81 num_class_tokens(0), | 74 num_class_tokens(0), |
| 82 num_functions_parsed(0), | 75 num_functions_parsed(0), |
| 83 num_functions_compiled(0), | 76 num_functions_compiled(0), |
| 84 num_functions_optimized(0), | 77 num_functions_optimized(0), |
| 85 num_func_tokens_compiled(0), | 78 num_func_tokens_compiled(0), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 110 va_start(args, format); | 103 va_start(args, format); |
| 111 stats->text = zone->VPrint(format, args); | 104 stats->text = zone->VPrint(format, args); |
| 112 va_end(args); | 105 va_end(args); |
| 113 } | 106 } |
| 114 | 107 |
| 115 | 108 |
| 116 void CompilerStats::Update() { | 109 void CompilerStats::Update() { |
| 117 // Traverse the heap and compute number of tokens in all | 110 // Traverse the heap and compute number of tokens in all |
| 118 // TokenStream objects. | 111 // TokenStream objects. |
| 119 num_tokens_total = 0; | 112 num_tokens_total = 0; |
| 120 num_literal_tokens_total = 0; | |
| 121 num_ident_tokens_total = 0; | |
| 122 TokenStreamVisitor visitor(isolate_, this); | 113 TokenStreamVisitor visitor(isolate_, this); |
| 123 isolate_->heap()->IterateObjects(&visitor); | 114 isolate_->heap()->IterateObjects(&visitor); |
| 124 Dart::vm_isolate()->heap()->IterateObjects(&visitor); | 115 Dart::vm_isolate()->heap()->IterateObjects(&visitor); |
| 125 } | 116 } |
| 126 | 117 |
| 127 | 118 |
| 128 void CompilerStats::EnableBenchmark() { | 119 void CompilerStats::EnableBenchmark() { |
| 129 FLAG_compiler_stats = true; | 120 FLAG_compiler_stats = true; |
| 130 use_benchmark_output = true; | 121 use_benchmark_output = true; |
| 131 } | 122 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 183 } |
| 193 | 184 |
| 194 Update(); | 185 Update(); |
| 195 | 186 |
| 196 Log log(PrintToStats); | 187 Log log(PrintToStats); |
| 197 LogBlock lb(Thread::Current(), &log); | 188 LogBlock lb(Thread::Current(), &log); |
| 198 | 189 |
| 199 log.Print("==== Compiler Stats for isolate '%s' ====\n", | 190 log.Print("==== Compiler Stats for isolate '%s' ====\n", |
| 200 isolate_->debugger_name()); | 191 isolate_->debugger_name()); |
| 201 log.Print("Number of tokens: %" Pd64 "\n", num_tokens_total); | 192 log.Print("Number of tokens: %" Pd64 "\n", num_tokens_total); |
| 202 log.Print(" Literal tokens: %" Pd64 "\n", num_literal_tokens_total); | |
| 203 log.Print(" Ident tokens: %" Pd64 "\n", num_ident_tokens_total); | |
| 204 log.Print("Source length: %" Pd64 " characters\n", src_length); | 193 log.Print("Source length: %" Pd64 " characters\n", src_length); |
| 205 log.Print("Number of source tokens: %" Pd64 "\n", num_tokens_scanned); | 194 log.Print("Number of source tokens: %" Pd64 "\n", num_tokens_scanned); |
| 206 | 195 |
| 207 log.Print("==== Parser stats:\n"); | 196 log.Print("==== Parser stats:\n"); |
| 208 log.Print("Total tokens consumed: %" Pd64 "\n", num_tokens_consumed); | 197 log.Print("Total tokens consumed: %" Pd64 "\n", num_tokens_consumed); |
| 209 log.Print("Classes parsed: %" Pd64 "\n", num_classes_parsed); | 198 log.Print("Classes parsed: %" Pd64 "\n", num_classes_parsed); |
| 210 log.Print(" Tokens consumed: %" Pd64 "\n", num_class_tokens); | 199 log.Print(" Tokens consumed: %" Pd64 "\n", num_class_tokens); |
| 211 log.Print("Functions parsed: %" Pd64 "\n", num_functions_parsed); | 200 log.Print("Functions parsed: %" Pd64 "\n", num_functions_parsed); |
| 212 log.Print(" Tokens consumed: %" Pd64 "\n", num_func_tokens_compiled); | 201 log.Print(" Tokens consumed: %" Pd64 "\n", num_func_tokens_compiled); |
| 213 log.Print("Impl getter funcs: %" Pd64 "\n", num_implicit_final_getters); | 202 log.Print("Impl getter funcs: %" Pd64 "\n", num_implicit_final_getters); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 total_instr_size / 1024); | 275 total_instr_size / 1024); |
| 287 log.Print(" Pc Desc size: %" Pd64 " KB\n", pc_desc_size / 1024); | 276 log.Print(" Pc Desc size: %" Pd64 " KB\n", pc_desc_size / 1024); |
| 288 log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024); | 277 log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024); |
| 289 log.Flush(); | 278 log.Flush(); |
| 290 char* stats_text = text; | 279 char* stats_text = text; |
| 291 text = NULL; | 280 text = NULL; |
| 292 return stats_text; | 281 return stats_text; |
| 293 } | 282 } |
| 294 | 283 |
| 295 } // namespace dart | 284 } // namespace dart |
| OLD | NEW |