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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/timeline.cc
diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc
index d29b057d87380267231fe153c4830eb2cbccdc51..d2cb26cef0fe24204917450c541f5c673491651c 100644
--- a/runtime/vm/timeline.cc
+++ b/runtime/vm/timeline.cc
@@ -420,10 +420,14 @@ TimelineEventRingRecorder::~TimelineEventRingRecorder() {
void TimelineEventRingRecorder::PrintJSONEvents(JSONArray* events) const {
- // TODO(johnmccutchan): This output needs to start with the oldest block
- // first.
+ intptr_t block_offset = FindOldestBlockIndex();
+ if (block_offset == -1) {
+ // All blocks are empty.
+ return;
+ }
for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) {
- TimelineEventBlock* block = blocks_[block_idx];
+ TimelineEventBlock* block =
+ blocks_[(block_idx + block_offset) % num_blocks_];
if (block->IsEmpty()) {
// Skip empty blocks.
continue;
@@ -471,6 +475,24 @@ TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() {
}
+intptr_t TimelineEventRingRecorder::FindOldestBlockIndex() const {
+ int64_t earliest_time = kMaxInt64;
+ intptr_t earliest_index = -1;
+ for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) {
+ TimelineEventBlock* block = blocks_[block_idx];
+ if (block->IsEmpty()) {
+ // Skip empty blocks.
+ continue;
+ }
+ if (block->LowerTimeBound() < earliest_time) {
+ earliest_time = block->LowerTimeBound();
+ earliest_index = block_idx;
+ }
+ }
+ return earliest_index;
+}
+
+
void TimelineEventRingRecorder::VisitObjectPointers(
ObjectPointerVisitor* visitor) {
visitor->VisitPointer(reinterpret_cast<RawObject**>(&event_objects_));
« 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