OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/counters.h" | 5 #include "src/counters.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void RuntimeCallStats::Leave(RuntimeCallTimer* timer) { | 292 void RuntimeCallStats::Leave(RuntimeCallTimer* timer) { |
293 current_timer_ = timer->Stop(); | 293 current_timer_ = timer->Stop(); |
294 } | 294 } |
295 | 295 |
296 void RuntimeCallStats::Print(std::ostream& os) { | 296 void RuntimeCallStats::Print(std::ostream& os) { |
297 RuntimeCallStatEntries entries; | 297 RuntimeCallStatEntries entries; |
298 | 298 |
299 #define PRINT_COUNTER(name, nargs, ressize) entries.Add(&this->Runtime_##name); | 299 #define PRINT_COUNTER(name, nargs, ressize) entries.Add(&this->Runtime_##name); |
300 FOR_EACH_INTRINSIC(PRINT_COUNTER) | 300 FOR_EACH_INTRINSIC(PRINT_COUNTER) |
301 #undef PRINT_COUNTER | 301 #undef PRINT_COUNTER |
302 | |
303 #define PRINT_COUNTER(name, type) entries.Add(&this->Builtin_##name); | 302 #define PRINT_COUNTER(name, type) entries.Add(&this->Builtin_##name); |
304 BUILTIN_LIST_C(PRINT_COUNTER) | 303 BUILTIN_LIST_C(PRINT_COUNTER) |
305 #undef PRINT_COUNTER | 304 #undef PRINT_COUNTER |
306 | 305 #define PRINT_COUNTER(name) entries.Add(&this->API_##name); |
307 entries.Add(&this->ExternalCallback); | 306 API_COUNTER(PRINT_COUNTER) |
308 entries.Add(&this->GC); | 307 #undef PRINT_COUNTER |
309 entries.Add(&this->UnexpectedStubMiss); | 308 #define PRINT_COUNTER(name) entries.Add(&this->name); |
| 309 OTHER_COUNTER(PRINT_COUNTER) |
| 310 #undef PRINT_COUNTER |
310 | 311 |
311 entries.Print(os); | 312 entries.Print(os); |
312 } | 313 } |
313 | 314 |
314 void RuntimeCallStats::Reset() { | 315 void RuntimeCallStats::Reset() { |
315 if (!FLAG_runtime_call_stats) return; | 316 if (!FLAG_runtime_call_stats) return; |
316 #define RESET_COUNTER(name, nargs, ressize) this->Runtime_##name.Reset(); | 317 #define RESET_COUNTER(name, nargs, result_size) this->Runtime_##name.Reset(); |
317 FOR_EACH_INTRINSIC(RESET_COUNTER) | 318 FOR_EACH_INTRINSIC(RESET_COUNTER) |
318 #undef RESET_COUNTER | 319 #undef RESET_COUNTER |
319 #define RESET_COUNTER(name, type) this->Builtin_##name.Reset(); | 320 #define RESET_COUNTER(name, type) this->Builtin_##name.Reset(); |
320 BUILTIN_LIST_C(RESET_COUNTER) | 321 BUILTIN_LIST_C(RESET_COUNTER) |
321 #undef RESET_COUNTER | 322 #undef RESET_COUNTER |
322 this->ExternalCallback.Reset(); | 323 #define RESET_COUNTER(name) this->API_##name.Reset(); |
323 this->GC.Reset(); | 324 API_COUNTER(RESET_COUNTER) |
324 this->UnexpectedStubMiss.Reset(); | 325 #undef RESET_COUNTER |
| 326 #define RESET_COUNTER(name) this->name.Reset(); |
| 327 OTHER_COUNTER(RESET_COUNTER) |
| 328 #undef RESET_COUNTER |
| 329 |
| 330 if (FLAG_api_call_stats) { |
| 331 #define RESET_COUNTER(name, nargs, result_size) \ |
| 332 this->Runtime_##name.enabled = false; |
| 333 FOR_EACH_INTRINSIC(RESET_COUNTER) |
| 334 #undef RESET_COUNTER |
| 335 #define RESET_COUNTER(name, type) this->Builtin_##name.enabled = false; |
| 336 BUILTIN_LIST_C(RESET_COUNTER) |
| 337 #undef RESET_COUNTER |
| 338 } |
325 } | 339 } |
326 | 340 |
327 void RuntimeCallTimerScope::Enter(Isolate* isolate, | 341 void RuntimeCallTimerScope::Enter(Isolate* isolate, |
328 RuntimeCallCounter* counter) { | 342 RuntimeCallCounter* counter) { |
| 343 if (!counter->enabled) { |
| 344 timer_.Initialize(NULL, NULL); |
| 345 return; |
| 346 } |
329 isolate_ = isolate; | 347 isolate_ = isolate; |
330 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); | 348 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
331 timer_.Initialize(counter, stats->current_timer()); | 349 timer_.Initialize(counter, stats->current_timer()); |
332 stats->Enter(&timer_); | 350 stats->Enter(&timer_); |
333 } | 351 } |
334 | 352 |
335 void RuntimeCallTimerScope::Leave() { | 353 void RuntimeCallTimerScope::Leave() { |
| 354 if (!timer_.enabled()) return; |
336 isolate_->counters()->runtime_call_stats()->Leave(&timer_); | 355 isolate_->counters()->runtime_call_stats()->Leave(&timer_); |
337 } | 356 } |
338 | 357 |
339 } // namespace internal | 358 } // namespace internal |
340 } // namespace v8 | 359 } // namespace v8 |
OLD | NEW |