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

Side by Side Diff: runtime/vm/timeline.cc

Issue 1295563002: Allow TimelineAnalysis to work on any TimelineEventRecorder (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months 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 | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_analysis.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 <cstdlib> 5 #include <cstdlib>
6 6
7 #include "vm/isolate.h" 7 #include "vm/isolate.h"
8 #include "vm/json_stream.h" 8 #include "vm/json_stream.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 449 }
450 } 450 }
451 451
452 452
453 TimelineEventBlock* TimelineEventRingRecorder::GetNewBlock() { 453 TimelineEventBlock* TimelineEventRingRecorder::GetNewBlock() {
454 MutexLocker ml(&lock_); 454 MutexLocker ml(&lock_);
455 return GetNewBlockLocked(); 455 return GetNewBlockLocked();
456 } 456 }
457 457
458 458
459 TimelineEventBlock* TimelineEventRingRecorder::GetHeadBlock() {
460 return blocks_[0];
461 }
462
463
459 TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() { 464 TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() {
460 if (block_cursor_ == num_blocks_) { 465 if (block_cursor_ == num_blocks_) {
461 block_cursor_ = 0; 466 block_cursor_ = 0;
462 } 467 }
463 TimelineEventBlock* block = blocks_[block_cursor_++]; 468 TimelineEventBlock* block = blocks_[block_cursor_++];
464 block->Reset(); 469 block->Reset();
465 return block; 470 return block;
466 } 471 }
467 472
468 473
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 567 }
563 } 568 }
564 569
565 570
566 TimelineEventBlock* TimelineEventEndlessRecorder::GetNewBlock() { 571 TimelineEventBlock* TimelineEventEndlessRecorder::GetNewBlock() {
567 MutexLocker ml(&lock_); 572 MutexLocker ml(&lock_);
568 return GetNewBlockLocked(); 573 return GetNewBlockLocked();
569 } 574 }
570 575
571 576
577 TimelineEventBlock* TimelineEventEndlessRecorder::GetHeadBlock() {
578 return head_;
579 }
580
581
572 void TimelineEventEndlessRecorder::VisitObjectPointers( 582 void TimelineEventEndlessRecorder::VisitObjectPointers(
573 ObjectPointerVisitor* visitor) { 583 ObjectPointerVisitor* visitor) {
574 // no-op. 584 // no-op.
575 } 585 }
576 586
577 587
578 TimelineEvent* TimelineEventEndlessRecorder::StartEvent(const Object& object) { 588 TimelineEvent* TimelineEventEndlessRecorder::StartEvent(const Object& object) {
579 return StartEvent(); 589 return StartEvent();
580 } 590 }
581 591
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 void TimelineEventBlock::Reset() { 683 void TimelineEventBlock::Reset() {
674 for (intptr_t i = 0; i < kBlockSize; i++) { 684 for (intptr_t i = 0; i < kBlockSize; i++) {
675 // Clear any extra data. 685 // Clear any extra data.
676 events_[i].Reset(); 686 events_[i].Reset();
677 } 687 }
678 length_ = 0; 688 length_ = 0;
679 } 689 }
680 690
681 691
682 TimelineEventBlockIterator::TimelineEventBlockIterator( 692 TimelineEventBlockIterator::TimelineEventBlockIterator(
683 TimelineEventEndlessRecorder* recorder) 693 TimelineEventRecorder* recorder)
684 : current_(NULL), 694 : current_(NULL),
685 recorder_(recorder) { 695 recorder_(recorder) {
686 if (recorder_ == NULL) { 696 if (recorder_ == NULL) {
687 return; 697 return;
688 } 698 }
689 recorder->lock_.Lock(); 699 recorder->lock_.Lock();
690 } 700 }
691 701
692 702
693 TimelineEventBlockIterator::~TimelineEventBlockIterator() { 703 TimelineEventBlockIterator::~TimelineEventBlockIterator() {
694 if (recorder_ == NULL) { 704 if (recorder_ == NULL) {
695 return; 705 return;
696 } 706 }
697 recorder_->lock_.Unlock(); 707 recorder_->lock_.Unlock();
698 } 708 }
699 709
700 710
701 void TimelineEventBlockIterator::Reset() { 711 void TimelineEventBlockIterator::Reset() {
702 current_ = NULL; 712 current_ = NULL;
703 } 713 }
704 714
705 715
706 bool TimelineEventBlockIterator::Next() { 716 bool TimelineEventBlockIterator::Next() {
707 if (recorder_ == NULL) { 717 if (recorder_ == NULL) {
708 return false; 718 return false;
709 } 719 }
710 if (current_ == NULL) { 720 if (current_ == NULL) {
711 current_ = recorder_->head_; 721 current_ = recorder_->GetHeadBlock();
712 } else { 722 } else {
713 current_ = current_->next(); 723 current_ = current_->next();
714 } 724 }
715 return current_ != NULL; 725 return current_ != NULL;
716 } 726 }
717 727
718 } // namespace dart 728 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_analysis.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698