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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 CounterId counter_id) { | 278 CounterId counter_id) { |
279 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); | 279 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
280 RuntimeCallCounter* counter = &(stats->*counter_id); | 280 RuntimeCallCounter* counter = &(stats->*counter_id); |
281 timer->Start(counter, stats->current_timer_); | 281 timer->Start(counter, stats->current_timer_); |
282 stats->current_timer_ = timer; | 282 stats->current_timer_ = timer; |
283 } | 283 } |
284 | 284 |
285 // static | 285 // static |
286 void RuntimeCallStats::Leave(Isolate* isolate, RuntimeCallTimer* timer) { | 286 void RuntimeCallStats::Leave(Isolate* isolate, RuntimeCallTimer* timer) { |
287 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); | 287 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
288 DCHECK_EQ(stats->current_timer_, timer); | 288 |
289 stats->current_timer_ = timer->Stop(); | 289 if (stats->current_timer_ == timer) { |
| 290 stats->current_timer_ = timer->Stop(); |
| 291 } else { |
| 292 // Must be a Threading cctest. Walk the chain of Timers to find the |
| 293 // buried one that's leaving. We don't care about keeping nested timings |
| 294 // accurate, just avoid crashing by keeping the chain intact. |
| 295 RuntimeCallTimer* next = stats->current_timer_; |
| 296 while (next->parent_ != timer) next = next->parent_; |
| 297 next->parent_ = timer->Stop(); |
| 298 } |
290 } | 299 } |
291 | 300 |
292 // static | 301 // static |
293 void RuntimeCallStats::CorrectCurrentCounterId(Isolate* isolate, | 302 void RuntimeCallStats::CorrectCurrentCounterId(Isolate* isolate, |
294 CounterId counter_id) { | 303 CounterId counter_id) { |
295 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); | 304 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
296 DCHECK_NOT_NULL(stats->current_timer_); | 305 DCHECK_NOT_NULL(stats->current_timer_); |
297 RuntimeCallCounter* counter = &(stats->*counter_id); | 306 RuntimeCallCounter* counter = &(stats->*counter_id); |
298 stats->current_timer_->counter_ = counter; | 307 stats->current_timer_->counter_ = counter; |
299 } | 308 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 FOR_EACH_API_COUNTER(RESET_COUNTER) | 351 FOR_EACH_API_COUNTER(RESET_COUNTER) |
343 #undef RESET_COUNTER | 352 #undef RESET_COUNTER |
344 | 353 |
345 #define RESET_COUNTER(name) this->Handler_##name.Reset(); | 354 #define RESET_COUNTER(name) this->Handler_##name.Reset(); |
346 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) | 355 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) |
347 #undef RESET_COUNTER | 356 #undef RESET_COUNTER |
348 } | 357 } |
349 | 358 |
350 } // namespace internal | 359 } // namespace internal |
351 } // namespace v8 | 360 } // namespace v8 |
OLD | NEW |