| OLD | NEW |
| 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 #ifndef VM_TIMELINE_H_ | 5 #ifndef VM_TIMELINE_H_ |
| 6 #define VM_TIMELINE_H_ | 6 #define VM_TIMELINE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/bitfield.h" | 9 #include "vm/bitfield.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void StealArguments(intptr_t arguments_length, | 155 void StealArguments(intptr_t arguments_length, |
| 156 TimelineEventArgument* arguments); | 156 TimelineEventArgument* arguments); |
| 157 // Mandatory to call when this event is completely filled out. | 157 // Mandatory to call when this event is completely filled out. |
| 158 void Complete(); | 158 void Complete(); |
| 159 | 159 |
| 160 EventType event_type() const { | 160 EventType event_type() const { |
| 161 return EventTypeField::decode(state_); | 161 return EventTypeField::decode(state_); |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool IsFinishedDuration() const { | 164 bool IsFinishedDuration() const { |
| 165 return (event_type() == kDuration) && (timestamp1_ > timestamp0_); | 165 return (SerializedJSONIsDuration() || (event_type() == kDuration)) && |
| 166 (timestamp1_ > timestamp0_); |
| 166 } | 167 } |
| 167 | 168 |
| 168 int64_t TimeOrigin() const; | 169 int64_t TimeOrigin() const; |
| 169 int64_t AsyncId() const; | 170 int64_t AsyncId() const; |
| 170 int64_t TimeDuration() const; | 171 int64_t TimeDuration() const; |
| 171 int64_t TimeEnd() const { | 172 int64_t TimeEnd() const { |
| 172 ASSERT(IsFinishedDuration()); | 173 ASSERT(IsFinishedDuration()); |
| 173 return timestamp1_; | 174 return timestamp1_; |
| 174 } | 175 } |
| 175 | 176 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 if (other->TimeOrigin() > TimeEnd()) { | 232 if (other->TimeOrigin() > TimeEnd()) { |
| 232 return false; | 233 return false; |
| 233 } | 234 } |
| 234 if (other->TimeEnd() > TimeEnd()) { | 235 if (other->TimeEnd() > TimeEnd()) { |
| 235 return false; | 236 return false; |
| 236 } | 237 } |
| 237 return true; | 238 return true; |
| 238 } | 239 } |
| 239 } | 240 } |
| 240 | 241 |
| 242 bool Within(int64_t time_origin_micros, |
| 243 int64_t time_extent_micros); |
| 244 |
| 241 const char* GetSerializedJSON() const; | 245 const char* GetSerializedJSON() const; |
| 242 | 246 |
| 247 void SetSerializedJSONIsDuration(bool duration) { |
| 248 state_ = SerializedJSONIsDurationField::update(duration, state_); |
| 249 } |
| 250 |
| 251 bool SerializedJSONIsDuration() const { |
| 252 return SerializedJSONIsDurationField::decode(state_); |
| 253 } |
| 254 |
| 243 private: | 255 private: |
| 244 void FreeArguments(); | 256 void FreeArguments(); |
| 245 | 257 |
| 246 void StreamInit(TimelineStream* stream); | 258 void StreamInit(TimelineStream* stream); |
| 247 void Init(EventType event_type, const char* label); | 259 void Init(EventType event_type, const char* label); |
| 248 | 260 |
| 249 void set_event_type(EventType event_type) { | 261 void set_event_type(EventType event_type) { |
| 250 // We only reserve 4 bits to hold the event type. | 262 // We only reserve 4 bits to hold the event type. |
| 251 COMPILE_ASSERT(kNumEventTypes < 16); | 263 COMPILE_ASSERT(kNumEventTypes < 16); |
| 252 state_ = EventTypeField::update(event_type, state_); | 264 state_ = EventTypeField::update(event_type, state_); |
| 253 } | 265 } |
| 254 | 266 |
| 255 void set_timestamp0(int64_t value) { | 267 void set_timestamp0(int64_t value) { |
| 256 ASSERT(timestamp0_ == 0); | 268 ASSERT(timestamp0_ == 0); |
| 257 timestamp0_ = value; | 269 timestamp0_ = value; |
| 258 } | 270 } |
| 259 void set_timestamp1(int64_t value) { | 271 void set_timestamp1(int64_t value) { |
| 260 ASSERT(timestamp1_ == 0); | 272 ASSERT(timestamp1_ == 0); |
| 261 timestamp1_ = value; | 273 timestamp1_ = value; |
| 262 } | 274 } |
| 263 | 275 |
| 264 enum StateBits { | 276 enum StateBits { |
| 265 kEventTypeBit = 0, // reserve 4 bits for type. | 277 kEventTypeBit = 0, // reserve 4 bits for type. |
| 266 kNextBit = 4, | 278 kSerializedJSONIsDuration = 4, |
| 279 kNextBit = 5, |
| 267 }; | 280 }; |
| 268 | 281 |
| 269 class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {}; | 282 class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {}; |
| 283 class SerializedJSONIsDurationField : |
| 284 public BitField<bool, kSerializedJSONIsDuration, 1> {}; |
| 270 | 285 |
| 271 int64_t timestamp0_; | 286 int64_t timestamp0_; |
| 272 int64_t timestamp1_; | 287 int64_t timestamp1_; |
| 273 TimelineEventArgument* arguments_; | 288 TimelineEventArgument* arguments_; |
| 274 intptr_t arguments_length_; | 289 intptr_t arguments_length_; |
| 275 uword state_; | 290 uword state_; |
| 276 const char* label_; | 291 const char* label_; |
| 277 const char* category_; | 292 const char* category_; |
| 278 ThreadId thread_; | 293 ThreadId thread_; |
| 279 Dart_Port isolate_id_; | 294 Dart_Port isolate_id_; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return !block->IsEmpty() && !block->in_use(); | 552 return !block->IsEmpty() && !block->in_use(); |
| 538 } | 553 } |
| 539 | 554 |
| 540 virtual bool IncludeEvent(TimelineEvent* event) { | 555 virtual bool IncludeEvent(TimelineEvent* event) { |
| 541 if (event == NULL) { | 556 if (event == NULL) { |
| 542 return false; | 557 return false; |
| 543 } | 558 } |
| 544 return event->IsValid(); | 559 return event->IsValid(); |
| 545 } | 560 } |
| 546 | 561 |
| 547 bool EventInTimeRange(TimelineEvent* event); | 562 int64_t time_origin_micros() const { |
| 563 return time_origin_micros_; |
| 564 } |
| 565 |
| 566 int64_t time_extent_micros() const { |
| 567 return time_extent_micros_; |
| 568 } |
| 548 | 569 |
| 549 private: | 570 private: |
| 550 int64_t time_origin_micros_; | 571 int64_t time_origin_micros_; |
| 551 int64_t time_extent_micros_; | 572 int64_t time_extent_micros_; |
| 552 }; | 573 }; |
| 553 | 574 |
| 554 | 575 |
| 555 class IsolateTimelineEventFilter : public TimelineEventFilter { | 576 class IsolateTimelineEventFilter : public TimelineEventFilter { |
| 556 public: | 577 public: |
| 557 explicit IsolateTimelineEventFilter(Dart_Port isolate_id, | 578 explicit IsolateTimelineEventFilter(Dart_Port isolate_id, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 739 |
| 719 private: | 740 private: |
| 720 TimelineEventBlock* current_; | 741 TimelineEventBlock* current_; |
| 721 TimelineEventRecorder* recorder_; | 742 TimelineEventRecorder* recorder_; |
| 722 }; | 743 }; |
| 723 | 744 |
| 724 | 745 |
| 725 } // namespace dart | 746 } // namespace dart |
| 726 | 747 |
| 727 #endif // VM_TIMELINE_H_ | 748 #endif // VM_TIMELINE_H_ |
| OLD | NEW |