| Index: runtime/vm/timeline.cc
|
| diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc
|
| index 5f0448868fa1abf14c9a897418b672f2d47ec9d4..595c0fe135eb5224007e17d95bb8550b6b885175 100644
|
| --- a/runtime/vm/timeline.cc
|
| +++ b/runtime/vm/timeline.cc
|
| @@ -13,7 +13,7 @@
|
|
|
| namespace dart {
|
|
|
| -DEFINE_FLAG(bool, trace_timeline, false, "Trace timeline code.");
|
| +DEFINE_FLAG(bool, trace_timeline, false, "Trace timeline backend");
|
| DEFINE_FLAG(bool, complete_timeline, false, "Record the complete timeline");
|
|
|
| TimelineEvent::TimelineEvent()
|
| @@ -586,4 +586,79 @@ TimelineEvent* TimelineEventBlock::StartEvent() {
|
| return &events_[length_++];
|
| }
|
|
|
| +
|
| +ThreadId TimelineEventBlock::thread() const {
|
| + ASSERT(length_ > 0);
|
| + return events_[0].thread();
|
| +}
|
| +
|
| +
|
| +int64_t TimelineEventBlock::LowerTimeBound() const {
|
| + ASSERT(length_ > 0);
|
| + return events_[0].TimeOrigin();
|
| +}
|
| +
|
| +
|
| +bool TimelineEventBlock::CheckBlock() {
|
| + if (length() == 0) {
|
| + return true;
|
| + }
|
| +
|
| + // - events in the block come from one thread.
|
| + ThreadId tid = thread();
|
| + for (intptr_t i = 0; i < length(); i++) {
|
| + if (At(i)->thread() != tid) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + // - events have monotonically increasing timestamps.
|
| + int64_t last_time = LowerTimeBound();
|
| + for (intptr_t i = 0; i < length(); i++) {
|
| + if (last_time > At(i)->TimeOrigin()) {
|
| + return false;
|
| + }
|
| + last_time = At(i)->TimeOrigin();
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +
|
| +TimelineEventBlockIterator::TimelineEventBlockIterator(
|
| + TimelineEventEndlessRecorder* recorder)
|
| + : current_(NULL),
|
| + recorder_(recorder) {
|
| + if (recorder_ == NULL) {
|
| + return;
|
| + }
|
| + recorder->lock_.Lock();
|
| +}
|
| +
|
| +
|
| +TimelineEventBlockIterator::~TimelineEventBlockIterator() {
|
| + if (recorder_ == NULL) {
|
| + return;
|
| + }
|
| + recorder_->lock_.Unlock();
|
| +}
|
| +
|
| +
|
| +void TimelineEventBlockIterator::Reset() {
|
| + current_ = NULL;
|
| +}
|
| +
|
| +
|
| +bool TimelineEventBlockIterator::Next() {
|
| + if (recorder_ == NULL) {
|
| + return false;
|
| + }
|
| + if (current_ == NULL) {
|
| + current_ = recorder_->head_;
|
| + } else {
|
| + current_ = current_->next();
|
| + }
|
| + return current_ != NULL;
|
| +}
|
| +
|
| } // namespace dart
|
|
|