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

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

Issue 1283093004: Ensure TimelineEventRingRecorder outputs blocks in increasing time order (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_test.cc » ('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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 for (intptr_t i = 0; i < num_blocks_; i++) { 413 for (intptr_t i = 0; i < num_blocks_; i++) {
414 TimelineEventBlock* block = blocks_[i]; 414 TimelineEventBlock* block = blocks_[i];
415 delete block; 415 delete block;
416 } 416 }
417 free(blocks_); 417 free(blocks_);
418 event_objects_ = Array::null(); 418 event_objects_ = Array::null();
419 } 419 }
420 420
421 421
422 void TimelineEventRingRecorder::PrintJSONEvents(JSONArray* events) const { 422 void TimelineEventRingRecorder::PrintJSONEvents(JSONArray* events) const {
423 // TODO(johnmccutchan): This output needs to start with the oldest block 423 intptr_t block_offset = FindOldestBlockIndex();
424 // first. 424 if (block_offset == -1) {
425 // All blocks are empty.
426 return;
427 }
425 for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) { 428 for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) {
426 TimelineEventBlock* block = blocks_[block_idx]; 429 TimelineEventBlock* block =
430 blocks_[(block_idx + block_offset) % num_blocks_];
427 if (block->IsEmpty()) { 431 if (block->IsEmpty()) {
428 // Skip empty blocks. 432 // Skip empty blocks.
429 continue; 433 continue;
430 } 434 }
431 for (intptr_t event_idx = 0; event_idx < block->length(); event_idx++) { 435 for (intptr_t event_idx = 0; event_idx < block->length(); event_idx++) {
432 TimelineEvent* event = block->At(event_idx); 436 TimelineEvent* event = block->At(event_idx);
433 if (event->IsValid()) { 437 if (event->IsValid()) {
434 events->AddValue(event); 438 events->AddValue(event);
435 } 439 }
436 } 440 }
(...skipping 27 matching lines...) Expand all
464 TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() { 468 TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() {
465 if (block_cursor_ == num_blocks_) { 469 if (block_cursor_ == num_blocks_) {
466 block_cursor_ = 0; 470 block_cursor_ = 0;
467 } 471 }
468 TimelineEventBlock* block = blocks_[block_cursor_++]; 472 TimelineEventBlock* block = blocks_[block_cursor_++];
469 block->Reset(); 473 block->Reset();
470 return block; 474 return block;
471 } 475 }
472 476
473 477
478 intptr_t TimelineEventRingRecorder::FindOldestBlockIndex() const {
479 int64_t earliest_time = kMaxInt64;
480 intptr_t earliest_index = -1;
481 for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) {
482 TimelineEventBlock* block = blocks_[block_idx];
483 if (block->IsEmpty()) {
484 // Skip empty blocks.
485 continue;
486 }
487 if (block->LowerTimeBound() < earliest_time) {
488 earliest_time = block->LowerTimeBound();
489 earliest_index = block_idx;
490 }
491 }
492 return earliest_index;
493 }
494
495
474 void TimelineEventRingRecorder::VisitObjectPointers( 496 void TimelineEventRingRecorder::VisitObjectPointers(
475 ObjectPointerVisitor* visitor) { 497 ObjectPointerVisitor* visitor) {
476 visitor->VisitPointer(reinterpret_cast<RawObject**>(&event_objects_)); 498 visitor->VisitPointer(reinterpret_cast<RawObject**>(&event_objects_));
477 } 499 }
478 500
479 501
480 TimelineEvent* TimelineEventRingRecorder::StartEvent(const Object& obj) { 502 TimelineEvent* TimelineEventRingRecorder::StartEvent(const Object& obj) {
481 TimelineEvent* event = StartEvent(); 503 TimelineEvent* event = StartEvent();
482 if (event == NULL) { 504 if (event == NULL) {
483 return NULL; 505 return NULL;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 741 }
720 if (current_ == NULL) { 742 if (current_ == NULL) {
721 current_ = recorder_->GetHeadBlock(); 743 current_ = recorder_->GetHeadBlock();
722 } else { 744 } else {
723 current_ = current_->next(); 745 current_ = current_->next();
724 } 746 }
725 return current_ != NULL; 747 return current_ != NULL;
726 } 748 }
727 749
728 } // namespace dart 750 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698