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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // accurate, just avoid crashing by keeping the chain intact. | 302 // accurate, just avoid crashing by keeping the chain intact. |
303 RuntimeCallTimer* next = stats->current_timer_.Value(); | 303 RuntimeCallTimer* next = stats->current_timer_.Value(); |
304 while (next->parent() != timer) next = next->parent(); | 304 while (next->parent() != timer) next = next->parent(); |
305 next->parent_.SetValue(timer->Stop()); | 305 next->parent_.SetValue(timer->Stop()); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 // static | 309 // static |
310 void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, | 310 void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, |
311 CounterId counter_id) { | 311 CounterId counter_id) { |
312 DCHECK_NOT_NULL(stats->current_timer_.Value()); | 312 RuntimeCallTimer* timer = stats->current_timer_.Value(); |
313 RuntimeCallCounter* counter = &(stats->*counter_id); | 313 // When RCS are enabled dynamically there might be no current timer set up. |
314 stats->current_timer_.Value()->counter_ = counter; | 314 if (timer == nullptr) return; |
| 315 timer->counter_ = &(stats->*counter_id); |
315 } | 316 } |
316 | 317 |
317 void RuntimeCallStats::Print(std::ostream& os) { | 318 void RuntimeCallStats::Print(std::ostream& os) { |
318 RuntimeCallStatEntries entries; | 319 RuntimeCallStatEntries entries; |
319 if (current_timer_.Value() != nullptr) { | 320 if (current_timer_.Value() != nullptr) { |
320 current_timer_.Value()->Elapsed(); | 321 current_timer_.Value()->Elapsed(); |
321 } | 322 } |
322 | 323 |
323 #define PRINT_COUNTER(name) entries.Add(&this->name); | 324 #define PRINT_COUNTER(name) entries.Add(&this->name); |
324 FOR_EACH_MANUAL_COUNTER(PRINT_COUNTER) | 325 FOR_EACH_MANUAL_COUNTER(PRINT_COUNTER) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 #define DUMP_COUNTER(name) \ | 397 #define DUMP_COUNTER(name) \ |
397 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value); | 398 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value); |
398 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) | 399 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) |
399 #undef DUMP_COUNTER | 400 #undef DUMP_COUNTER |
400 | 401 |
401 in_use_ = false; | 402 in_use_ = false; |
402 } | 403 } |
403 | 404 |
404 } // namespace internal | 405 } // namespace internal |
405 } // namespace v8 | 406 } // namespace v8 |
OLD | NEW |