| 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" |
| 11 #include "vm/timer.h" | 11 #include "vm/timer.h" |
| 12 | 12 |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 DEFINE_FLAG(bool, compiler_stats, false, "Compiler stat counters."); | 16 DEFINE_FLAG(bool, compiler_stats, false, "Compiler stat counters."); |
| 17 DEFINE_FLAG(bool, compiler_benchmark, false, | 17 DEFINE_FLAG(bool, compiler_benchmark, false, |
| 18 "Compiler stat counters for benchmark."); | 18 "Compiler stat counters for benchmark."); |
| 19 | 19 |
| 20 | 20 |
| 21 class TokenStreamVisitor : public ObjectVisitor { | 21 class TokenStreamVisitor : public ObjectVisitor { |
| 22 public: | 22 public: |
| 23 TokenStreamVisitor(Isolate* isolate, CompilerStats* compiler_stats) | 23 explicit TokenStreamVisitor(CompilerStats* compiler_stats) |
| 24 : ObjectVisitor(isolate), | 24 : obj_(Object::Handle()), |
| 25 obj_(Object::Handle()), | |
| 26 stats_(compiler_stats) { | 25 stats_(compiler_stats) { |
| 27 } | 26 } |
| 28 | 27 |
| 29 void VisitObject(RawObject* raw_obj) { | 28 void VisitObject(RawObject* raw_obj) { |
| 30 if (raw_obj->IsFreeListElement()) { | 29 if (raw_obj->IsFreeListElement()) { |
| 31 return; | 30 return; |
| 32 } | 31 } |
| 33 obj_ = raw_obj; | 32 obj_ = raw_obj; |
| 34 if (obj_.GetClassId() == TokenStream::kClassId) { | 33 if (obj_.GetClassId() == TokenStream::kClassId) { |
| 35 TokenStream::Iterator tkit(TokenStream::Cast(obj_), | 34 TokenStream::Iterator tkit(TokenStream::Cast(obj_), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 va_start(args, format); | 105 va_start(args, format); |
| 107 stats->text = zone->VPrint(format, args); | 106 stats->text = zone->VPrint(format, args); |
| 108 va_end(args); | 107 va_end(args); |
| 109 } | 108 } |
| 110 | 109 |
| 111 | 110 |
| 112 void CompilerStats::Update() { | 111 void CompilerStats::Update() { |
| 113 // Traverse the heap and compute number of tokens in all | 112 // Traverse the heap and compute number of tokens in all |
| 114 // TokenStream objects. | 113 // TokenStream objects. |
| 115 num_tokens_total = 0; | 114 num_tokens_total = 0; |
| 116 TokenStreamVisitor visitor(isolate_, this); | 115 TokenStreamVisitor visitor(this); |
| 117 isolate_->heap()->IterateObjects(&visitor); | 116 isolate_->heap()->IterateObjects(&visitor); |
| 118 Dart::vm_isolate()->heap()->IterateObjects(&visitor); | 117 Dart::vm_isolate()->heap()->IterateObjects(&visitor); |
| 119 } | 118 } |
| 120 | 119 |
| 121 | 120 |
| 122 void CompilerStats::EnableBenchmark() { | 121 void CompilerStats::EnableBenchmark() { |
| 123 FLAG_compiler_stats = true; | 122 FLAG_compiler_stats = true; |
| 124 use_benchmark_output = true; | 123 use_benchmark_output = true; |
| 125 } | 124 } |
| 126 | 125 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024); | 283 log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024); |
| 285 log.Flush(); | 284 log.Flush(); |
| 286 char* stats_text = text; | 285 char* stats_text = text; |
| 287 text = NULL; | 286 text = NULL; |
| 288 return stats_text; | 287 return stats_text; |
| 289 } | 288 } |
| 290 | 289 |
| 291 #endif // !PRODUCT | 290 #endif // !PRODUCT |
| 292 | 291 |
| 293 } // namespace dart | 292 } // namespace dart |
| OLD | NEW |