Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: src/counters.cc

Issue 2464973002: [profiler] Make certain Runtime Call Stats fields atomic. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 value->BeginArray(name); 281 value->BeginArray(name);
282 value->AppendLongInteger(count); 282 value->AppendLongInteger(count);
283 value->AppendLongInteger(time.InMicroseconds()); 283 value->AppendLongInteger(time.InMicroseconds());
284 value->EndArray(); 284 value->EndArray();
285 } 285 }
286 286
287 // static 287 // static
288 void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, 288 void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer,
289 CounterId counter_id) { 289 CounterId counter_id) {
290 RuntimeCallCounter* counter = &(stats->*counter_id); 290 RuntimeCallCounter* counter = &(stats->*counter_id);
291 timer->Start(counter, stats->current_timer_); 291 timer->Start(counter, stats->current_timer_.Value());
292 stats->current_timer_ = timer; 292 stats->current_timer_.SetValue(timer);
293 } 293 }
294 294
295 // static 295 // static
296 void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { 296 void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
297 if (stats->current_timer_ == timer) { 297 if (stats->current_timer_.Value() == timer) {
298 stats->current_timer_ = timer->Stop(); 298 stats->current_timer_.SetValue(timer->Stop());
299 } else { 299 } else {
300 // Must be a Threading cctest. Walk the chain of Timers to find the 300 // Must be a Threading cctest. Walk the chain of Timers to find the
301 // buried one that's leaving. We don't care about keeping nested timings 301 // buried one that's leaving. We don't care about keeping nested timings
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_; 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_ = 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_); 312 DCHECK_NOT_NULL(stats->current_timer_.Value());
313 RuntimeCallCounter* counter = &(stats->*counter_id); 313 RuntimeCallCounter* counter = &(stats->*counter_id);
314 stats->current_timer_->counter_ = counter; 314 stats->current_timer_.Value()->counter_ = counter;
315 } 315 }
316 316
317 void RuntimeCallStats::Print(std::ostream& os) { 317 void RuntimeCallStats::Print(std::ostream& os) {
318 RuntimeCallStatEntries entries; 318 RuntimeCallStatEntries entries;
319 if (current_timer_ != NULL) { 319 if (current_timer_.Value() != nullptr) {
320 current_timer_->Elapsed(); 320 current_timer_.Value()->Elapsed();
321 } 321 }
322 322
323 #define PRINT_COUNTER(name) entries.Add(&this->name); 323 #define PRINT_COUNTER(name) entries.Add(&this->name);
324 FOR_EACH_MANUAL_COUNTER(PRINT_COUNTER) 324 FOR_EACH_MANUAL_COUNTER(PRINT_COUNTER)
325 #undef PRINT_COUNTER 325 #undef PRINT_COUNTER
326 326
327 #define PRINT_COUNTER(name, nargs, ressize) entries.Add(&this->Runtime_##name); 327 #define PRINT_COUNTER(name, nargs, ressize) entries.Add(&this->Runtime_##name);
328 FOR_EACH_INTRINSIC(PRINT_COUNTER) 328 FOR_EACH_INTRINSIC(PRINT_COUNTER)
329 #undef PRINT_COUNTER 329 #undef PRINT_COUNTER
330 330
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 #undef RESET_COUNTER 362 #undef RESET_COUNTER
363 363
364 #define RESET_COUNTER(name) this->Handler_##name.Reset(); 364 #define RESET_COUNTER(name) this->Handler_##name.Reset();
365 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) 365 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER)
366 #undef RESET_COUNTER 366 #undef RESET_COUNTER
367 367
368 in_use_ = true; 368 in_use_ = true;
369 } 369 }
370 370
371 void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) { 371 void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) {
372 if (current_timer_ != NULL) { 372 if (current_timer_.Value() != nullptr) {
373 current_timer_->Elapsed(); 373 current_timer_.Value()->Elapsed();
374 } 374 }
375 #define DUMP_COUNTER(name) \ 375 #define DUMP_COUNTER(name) \
376 if (this->name.count > 0) this->name.Dump(value); 376 if (this->name.count > 0) this->name.Dump(value);
377 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) 377 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER)
378 #undef DUMP_COUNTER 378 #undef DUMP_COUNTER
379 379
380 #define DUMP_COUNTER(name, nargs, result_size) \ 380 #define DUMP_COUNTER(name, nargs, result_size) \
381 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(value); 381 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(value);
382 FOR_EACH_INTRINSIC(DUMP_COUNTER) 382 FOR_EACH_INTRINSIC(DUMP_COUNTER)
383 #undef DUMP_COUNTER 383 #undef DUMP_COUNTER
(...skipping 11 matching lines...) Expand all
395 #define DUMP_COUNTER(name) \ 395 #define DUMP_COUNTER(name) \
396 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value); 396 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value);
397 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) 397 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
398 #undef DUMP_COUNTER 398 #undef DUMP_COUNTER
399 399
400 in_use_ = false; 400 in_use_ = false;
401 } 401 }
402 402
403 } // namespace internal 403 } // namespace internal
404 } // namespace v8 404 } // namespace v8
OLDNEW
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698