| 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 RUNTIME_VM_TIMELINE_H_ | 5 #ifndef RUNTIME_VM_TIMELINE_H_ |
| 6 #define RUNTIME_VM_TIMELINE_H_ | 6 #define RUNTIME_VM_TIMELINE_H_ |
| 7 | 7 |
| 8 #include "include/dart_tools_api.h" | 8 #include "include/dart_tools_api.h" |
| 9 | 9 |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 #define TIMELINE_STREAM_DECLARE(name, not_used) \ | 130 #define TIMELINE_STREAM_DECLARE(name, not_used) \ |
| 131 static bool stream_##name##_enabled_; \ | 131 static bool stream_##name##_enabled_; \ |
| 132 static TimelineStream stream_##name##_; | 132 static TimelineStream stream_##name##_; |
| 133 TIMELINE_STREAM_LIST(TIMELINE_STREAM_DECLARE) | 133 TIMELINE_STREAM_LIST(TIMELINE_STREAM_DECLARE) |
| 134 #undef TIMELINE_STREAM_DECLARE | 134 #undef TIMELINE_STREAM_DECLARE |
| 135 | 135 |
| 136 friend class TimelineRecorderOverride; | 136 friend class TimelineRecorderOverride; |
| 137 friend class ReclaimBlocksIsolateVisitor; | 137 friend class ReclaimBlocksIsolateVisitor; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 | |
| 141 struct TimelineEventArgument { | 140 struct TimelineEventArgument { |
| 142 const char* name; | 141 const char* name; |
| 143 char* value; | 142 char* value; |
| 144 }; | 143 }; |
| 145 | 144 |
| 146 | |
| 147 // You should get a |TimelineEvent| from a |TimelineStream|. | 145 // You should get a |TimelineEvent| from a |TimelineStream|. |
| 148 class TimelineEvent { | 146 class TimelineEvent { |
| 149 public: | 147 public: |
| 150 // Keep in sync with StateBits below. | 148 // Keep in sync with StateBits below. |
| 151 enum EventType { | 149 enum EventType { |
| 152 kNone, | 150 kNone, |
| 153 kBegin, | 151 kBegin, |
| 154 kEnd, | 152 kEnd, |
| 155 kDuration, | 153 kDuration, |
| 156 kInstant, | 154 kInstant, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 friend class TimelineEventEndlessRecorder; | 387 friend class TimelineEventEndlessRecorder; |
| 390 friend class TimelineEventRingRecorder; | 388 friend class TimelineEventRingRecorder; |
| 391 friend class TimelineEventStartupRecorder; | 389 friend class TimelineEventStartupRecorder; |
| 392 friend class TimelineEventSystraceRecorder; | 390 friend class TimelineEventSystraceRecorder; |
| 393 friend class TimelineEventFuchsiaRecorder; | 391 friend class TimelineEventFuchsiaRecorder; |
| 394 friend class TimelineStream; | 392 friend class TimelineStream; |
| 395 friend class TimelineTestHelper; | 393 friend class TimelineTestHelper; |
| 396 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); | 394 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); |
| 397 }; | 395 }; |
| 398 | 396 |
| 399 | |
| 400 #ifndef PRODUCT | 397 #ifndef PRODUCT |
| 401 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \ | 398 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \ |
| 402 TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), name); \ | 399 TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), name); \ |
| 403 if (tds.enabled()) { \ | 400 if (tds.enabled()) { \ |
| 404 tds.SetNumArguments(1); \ | 401 tds.SetNumArguments(1); \ |
| 405 tds.CopyArgument(0, "function", \ | 402 tds.CopyArgument(0, "function", \ |
| 406 function.ToLibNamePrefixedQualifiedCString()); \ | 403 function.ToLibNamePrefixedQualifiedCString()); \ |
| 407 } | 404 } |
| 408 | 405 |
| 409 #define TIMELINE_FUNCTION_GC_DURATION(thread, name) \ | 406 #define TIMELINE_FUNCTION_GC_DURATION(thread, name) \ |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 451 |
| 455 TimelineStream* stream_; | 452 TimelineStream* stream_; |
| 456 const char* label_; | 453 const char* label_; |
| 457 TimelineEventArgument* arguments_; | 454 TimelineEventArgument* arguments_; |
| 458 intptr_t arguments_length_; | 455 intptr_t arguments_length_; |
| 459 bool enabled_; | 456 bool enabled_; |
| 460 | 457 |
| 461 DISALLOW_COPY_AND_ASSIGN(TimelineEventScope); | 458 DISALLOW_COPY_AND_ASSIGN(TimelineEventScope); |
| 462 }; | 459 }; |
| 463 | 460 |
| 464 | |
| 465 class TimelineDurationScope : public TimelineEventScope { | 461 class TimelineDurationScope : public TimelineEventScope { |
| 466 public: | 462 public: |
| 467 TimelineDurationScope(TimelineStream* stream, const char* label); | 463 TimelineDurationScope(TimelineStream* stream, const char* label); |
| 468 | 464 |
| 469 TimelineDurationScope(Thread* thread, | 465 TimelineDurationScope(Thread* thread, |
| 470 TimelineStream* stream, | 466 TimelineStream* stream, |
| 471 const char* label); | 467 const char* label); |
| 472 | 468 |
| 473 virtual ~TimelineDurationScope(); | 469 virtual ~TimelineDurationScope(); |
| 474 | 470 |
| 475 private: | 471 private: |
| 476 int64_t timestamp_; | 472 int64_t timestamp_; |
| 477 int64_t thread_timestamp_; | 473 int64_t thread_timestamp_; |
| 478 | 474 |
| 479 DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope); | 475 DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope); |
| 480 }; | 476 }; |
| 481 | 477 |
| 482 | |
| 483 class TimelineBeginEndScope : public TimelineEventScope { | 478 class TimelineBeginEndScope : public TimelineEventScope { |
| 484 public: | 479 public: |
| 485 TimelineBeginEndScope(TimelineStream* stream, const char* label); | 480 TimelineBeginEndScope(TimelineStream* stream, const char* label); |
| 486 | 481 |
| 487 TimelineBeginEndScope(Thread* thread, | 482 TimelineBeginEndScope(Thread* thread, |
| 488 TimelineStream* stream, | 483 TimelineStream* stream, |
| 489 const char* label); | 484 const char* label); |
| 490 | 485 |
| 491 virtual ~TimelineBeginEndScope(); | 486 virtual ~TimelineBeginEndScope(); |
| 492 | 487 |
| 493 private: | 488 private: |
| 494 void EmitBegin(); | 489 void EmitBegin(); |
| 495 void EmitEnd(); | 490 void EmitEnd(); |
| 496 | 491 |
| 497 DISALLOW_COPY_AND_ASSIGN(TimelineBeginEndScope); | 492 DISALLOW_COPY_AND_ASSIGN(TimelineBeginEndScope); |
| 498 }; | 493 }; |
| 499 | 494 |
| 500 | |
| 501 // A block of |TimelineEvent|s. Not thread safe. | 495 // A block of |TimelineEvent|s. Not thread safe. |
| 502 class TimelineEventBlock { | 496 class TimelineEventBlock { |
| 503 public: | 497 public: |
| 504 static const intptr_t kBlockSize = 64; | 498 static const intptr_t kBlockSize = 64; |
| 505 | 499 |
| 506 explicit TimelineEventBlock(intptr_t index); | 500 explicit TimelineEventBlock(intptr_t index); |
| 507 ~TimelineEventBlock(); | 501 ~TimelineEventBlock(); |
| 508 | 502 |
| 509 TimelineEventBlock* next() const { return next_; } | 503 TimelineEventBlock* next() const { return next_; } |
| 510 void set_next(TimelineEventBlock* next) { next_ = next; } | 504 void set_next(TimelineEventBlock* next) { next_ = next; } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 friend class TimelineEventStartupRecorder; | 564 friend class TimelineEventStartupRecorder; |
| 571 friend class TimelineEventSystraceRecorder; | 565 friend class TimelineEventSystraceRecorder; |
| 572 friend class TimelineEventFuchsiaRecorder; | 566 friend class TimelineEventFuchsiaRecorder; |
| 573 friend class TimelineTestHelper; | 567 friend class TimelineTestHelper; |
| 574 friend class JSONStream; | 568 friend class JSONStream; |
| 575 | 569 |
| 576 private: | 570 private: |
| 577 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); | 571 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); |
| 578 }; | 572 }; |
| 579 | 573 |
| 580 | |
| 581 class TimelineEventFilter : public ValueObject { | 574 class TimelineEventFilter : public ValueObject { |
| 582 public: | 575 public: |
| 583 TimelineEventFilter(int64_t time_origin_micros = -1, | 576 TimelineEventFilter(int64_t time_origin_micros = -1, |
| 584 int64_t time_extent_micros = -1); | 577 int64_t time_extent_micros = -1); |
| 585 | 578 |
| 586 virtual ~TimelineEventFilter(); | 579 virtual ~TimelineEventFilter(); |
| 587 | 580 |
| 588 virtual bool IncludeBlock(TimelineEventBlock* block) { | 581 virtual bool IncludeBlock(TimelineEventBlock* block) { |
| 589 if (block == NULL) { | 582 if (block == NULL) { |
| 590 return false; | 583 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 602 | 595 |
| 603 int64_t time_origin_micros() const { return time_origin_micros_; } | 596 int64_t time_origin_micros() const { return time_origin_micros_; } |
| 604 | 597 |
| 605 int64_t time_extent_micros() const { return time_extent_micros_; } | 598 int64_t time_extent_micros() const { return time_extent_micros_; } |
| 606 | 599 |
| 607 private: | 600 private: |
| 608 int64_t time_origin_micros_; | 601 int64_t time_origin_micros_; |
| 609 int64_t time_extent_micros_; | 602 int64_t time_extent_micros_; |
| 610 }; | 603 }; |
| 611 | 604 |
| 612 | |
| 613 class IsolateTimelineEventFilter : public TimelineEventFilter { | 605 class IsolateTimelineEventFilter : public TimelineEventFilter { |
| 614 public: | 606 public: |
| 615 explicit IsolateTimelineEventFilter(Dart_Port isolate_id, | 607 explicit IsolateTimelineEventFilter(Dart_Port isolate_id, |
| 616 int64_t time_origin_micros = -1, | 608 int64_t time_origin_micros = -1, |
| 617 int64_t time_extent_micros = -1); | 609 int64_t time_extent_micros = -1); |
| 618 | 610 |
| 619 bool IncludeBlock(TimelineEventBlock* block) { | 611 bool IncludeBlock(TimelineEventBlock* block) { |
| 620 if (block == NULL) { | 612 if (block == NULL) { |
| 621 return false; | 613 return false; |
| 622 } | 614 } |
| 623 // Not empty, not in use, and isolate match. | 615 // Not empty, not in use, and isolate match. |
| 624 return !block->IsEmpty() && !block->in_use(); | 616 return !block->IsEmpty() && !block->in_use(); |
| 625 } | 617 } |
| 626 | 618 |
| 627 bool IncludeEvent(TimelineEvent* event) { | 619 bool IncludeEvent(TimelineEvent* event) { |
| 628 return event->IsValid() && (event->isolate_id() == isolate_id_); | 620 return event->IsValid() && (event->isolate_id() == isolate_id_); |
| 629 } | 621 } |
| 630 | 622 |
| 631 private: | 623 private: |
| 632 Dart_Port isolate_id_; | 624 Dart_Port isolate_id_; |
| 633 }; | 625 }; |
| 634 | 626 |
| 635 | |
| 636 // Recorder of |TimelineEvent|s. | 627 // Recorder of |TimelineEvent|s. |
| 637 class TimelineEventRecorder { | 628 class TimelineEventRecorder { |
| 638 public: | 629 public: |
| 639 TimelineEventRecorder(); | 630 TimelineEventRecorder(); |
| 640 virtual ~TimelineEventRecorder() {} | 631 virtual ~TimelineEventRecorder() {} |
| 641 | 632 |
| 642 TimelineEventBlock* GetNewBlock(); | 633 TimelineEventBlock* GetNewBlock(); |
| 643 | 634 |
| 644 // Interface method(s) which must be implemented. | 635 // Interface method(s) which must be implemented. |
| 645 virtual void PrintJSON(JSONStream* js, TimelineEventFilter* filter) = 0; | 636 virtual void PrintJSON(JSONStream* js, TimelineEventFilter* filter) = 0; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 friend class TimelineEvent; | 668 friend class TimelineEvent; |
| 678 friend class TimelineEventBlockIterator; | 669 friend class TimelineEventBlockIterator; |
| 679 friend class TimelineStream; | 670 friend class TimelineStream; |
| 680 friend class TimelineTestHelper; | 671 friend class TimelineTestHelper; |
| 681 friend class Timeline; | 672 friend class Timeline; |
| 682 | 673 |
| 683 private: | 674 private: |
| 684 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder); | 675 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder); |
| 685 }; | 676 }; |
| 686 | 677 |
| 687 | |
| 688 // An abstract recorder that stores events in a buffer of fixed capacity. | 678 // An abstract recorder that stores events in a buffer of fixed capacity. |
| 689 class TimelineEventFixedBufferRecorder : public TimelineEventRecorder { | 679 class TimelineEventFixedBufferRecorder : public TimelineEventRecorder { |
| 690 public: | 680 public: |
| 691 static const intptr_t kDefaultCapacity = 8192; | 681 static const intptr_t kDefaultCapacity = 8192; |
| 692 | 682 |
| 693 explicit TimelineEventFixedBufferRecorder(intptr_t capacity); | 683 explicit TimelineEventFixedBufferRecorder(intptr_t capacity); |
| 694 virtual ~TimelineEventFixedBufferRecorder(); | 684 virtual ~TimelineEventFixedBufferRecorder(); |
| 695 | 685 |
| 696 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 686 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 697 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); | 687 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
| 698 | 688 |
| 699 protected: | 689 protected: |
| 700 TimelineEvent* StartEvent(); | 690 TimelineEvent* StartEvent(); |
| 701 void CompleteEvent(TimelineEvent* event); | 691 void CompleteEvent(TimelineEvent* event); |
| 702 TimelineEventBlock* GetHeadBlockLocked(); | 692 TimelineEventBlock* GetHeadBlockLocked(); |
| 703 intptr_t FindOldestBlockIndex() const; | 693 intptr_t FindOldestBlockIndex() const; |
| 704 void Clear(); | 694 void Clear(); |
| 705 | 695 |
| 706 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); | 696 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); |
| 707 | 697 |
| 708 TimelineEventBlock** blocks_; | 698 TimelineEventBlock** blocks_; |
| 709 intptr_t capacity_; | 699 intptr_t capacity_; |
| 710 intptr_t num_blocks_; | 700 intptr_t num_blocks_; |
| 711 intptr_t block_cursor_; | 701 intptr_t block_cursor_; |
| 712 }; | 702 }; |
| 713 | 703 |
| 714 | |
| 715 // A recorder that stores events in a buffer of fixed capacity. When the buffer | 704 // A recorder that stores events in a buffer of fixed capacity. When the buffer |
| 716 // is full, new events overwrite old events. | 705 // is full, new events overwrite old events. |
| 717 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder { | 706 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder { |
| 718 public: | 707 public: |
| 719 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity) | 708 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity) |
| 720 : TimelineEventFixedBufferRecorder(capacity) {} | 709 : TimelineEventFixedBufferRecorder(capacity) {} |
| 721 virtual ~TimelineEventRingRecorder() {} | 710 virtual ~TimelineEventRingRecorder() {} |
| 722 | 711 |
| 723 const char* name() const { return "Ring"; } | 712 const char* name() const { return "Ring"; } |
| 724 | 713 |
| 725 protected: | 714 protected: |
| 726 TimelineEventBlock* GetNewBlockLocked(); | 715 TimelineEventBlock* GetNewBlockLocked(); |
| 727 }; | 716 }; |
| 728 | 717 |
| 729 | |
| 730 // A recorder that writes events to Android Systrace. Events are also stored in | 718 // A recorder that writes events to Android Systrace. Events are also stored in |
| 731 // a buffer of fixed capacity. When the buffer is full, new events overwrite | 719 // a buffer of fixed capacity. When the buffer is full, new events overwrite |
| 732 // old events. | 720 // old events. |
| 733 class TimelineEventSystraceRecorder : public TimelineEventFixedBufferRecorder { | 721 class TimelineEventSystraceRecorder : public TimelineEventFixedBufferRecorder { |
| 734 public: | 722 public: |
| 735 explicit TimelineEventSystraceRecorder(intptr_t capacity = kDefaultCapacity); | 723 explicit TimelineEventSystraceRecorder(intptr_t capacity = kDefaultCapacity); |
| 736 virtual ~TimelineEventSystraceRecorder(); | 724 virtual ~TimelineEventSystraceRecorder(); |
| 737 | 725 |
| 738 const char* name() const { return "Systrace"; } | 726 const char* name() const { return "Systrace"; } |
| 739 | 727 |
| 740 protected: | 728 protected: |
| 741 TimelineEventBlock* GetNewBlockLocked(); | 729 TimelineEventBlock* GetNewBlockLocked(); |
| 742 void CompleteEvent(TimelineEvent* event); | 730 void CompleteEvent(TimelineEvent* event); |
| 743 | 731 |
| 744 int systrace_fd_; | 732 int systrace_fd_; |
| 745 }; | 733 }; |
| 746 | 734 |
| 747 | |
| 748 #if defined(HOST_OS_FUCHSIA) | 735 #if defined(HOST_OS_FUCHSIA) |
| 749 // A recorder that sends events to Fuchsia's tracing app. Events are also stored | 736 // A recorder that sends events to Fuchsia's tracing app. Events are also stored |
| 750 // in a buffer of fixed capacity. When the buffer is full, new events overwrite | 737 // in a buffer of fixed capacity. When the buffer is full, new events overwrite |
| 751 // old events. | 738 // old events. |
| 752 // See: https://fuchsia.googlesource.com/tracing/+/HEAD/docs/usage_guide.md | 739 // See: https://fuchsia.googlesource.com/tracing/+/HEAD/docs/usage_guide.md |
| 753 class TimelineEventFuchsiaRecorder : public TimelineEventFixedBufferRecorder { | 740 class TimelineEventFuchsiaRecorder : public TimelineEventFixedBufferRecorder { |
| 754 public: | 741 public: |
| 755 explicit TimelineEventFuchsiaRecorder(intptr_t capacity = kDefaultCapacity); | 742 explicit TimelineEventFuchsiaRecorder(intptr_t capacity = kDefaultCapacity); |
| 756 virtual ~TimelineEventFuchsiaRecorder() {} | 743 virtual ~TimelineEventFuchsiaRecorder() {} |
| 757 | 744 |
| 758 const char* name() const { return "Fuchsia"; } | 745 const char* name() const { return "Fuchsia"; } |
| 759 | 746 |
| 760 protected: | 747 protected: |
| 761 TimelineEventBlock* GetNewBlockLocked(); | 748 TimelineEventBlock* GetNewBlockLocked(); |
| 762 void CompleteEvent(TimelineEvent* event); | 749 void CompleteEvent(TimelineEvent* event); |
| 763 }; | 750 }; |
| 764 #endif // defined(HOST_OS_FUCHSIA) | 751 #endif // defined(HOST_OS_FUCHSIA) |
| 765 | 752 |
| 766 | |
| 767 // A recorder that stores events in a buffer of fixed capacity. When the buffer | 753 // A recorder that stores events in a buffer of fixed capacity. When the buffer |
| 768 // is full, new events are dropped. | 754 // is full, new events are dropped. |
| 769 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { | 755 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { |
| 770 public: | 756 public: |
| 771 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) | 757 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) |
| 772 : TimelineEventFixedBufferRecorder(capacity) {} | 758 : TimelineEventFixedBufferRecorder(capacity) {} |
| 773 virtual ~TimelineEventStartupRecorder() {} | 759 virtual ~TimelineEventStartupRecorder() {} |
| 774 | 760 |
| 775 const char* name() const { return "Startup"; } | 761 const char* name() const { return "Startup"; } |
| 776 | 762 |
| 777 protected: | 763 protected: |
| 778 TimelineEventBlock* GetNewBlockLocked(); | 764 TimelineEventBlock* GetNewBlockLocked(); |
| 779 }; | 765 }; |
| 780 | 766 |
| 781 | |
| 782 // An abstract recorder that calls |OnEvent| whenever an event is complete. | 767 // An abstract recorder that calls |OnEvent| whenever an event is complete. |
| 783 // This should only be used for testing. | 768 // This should only be used for testing. |
| 784 class TimelineEventCallbackRecorder : public TimelineEventRecorder { | 769 class TimelineEventCallbackRecorder : public TimelineEventRecorder { |
| 785 public: | 770 public: |
| 786 TimelineEventCallbackRecorder(); | 771 TimelineEventCallbackRecorder(); |
| 787 virtual ~TimelineEventCallbackRecorder(); | 772 virtual ~TimelineEventCallbackRecorder(); |
| 788 | 773 |
| 789 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 774 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 790 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); | 775 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
| 791 | 776 |
| 792 // Called when |event| is completed. It is unsafe to keep a reference to | 777 // Called when |event| is completed. It is unsafe to keep a reference to |
| 793 // |event| as it may be freed as soon as this function returns. | 778 // |event| as it may be freed as soon as this function returns. |
| 794 virtual void OnEvent(TimelineEvent* event) = 0; | 779 virtual void OnEvent(TimelineEvent* event) = 0; |
| 795 | 780 |
| 796 const char* name() const { return "Callback"; } | 781 const char* name() const { return "Callback"; } |
| 797 | 782 |
| 798 protected: | 783 protected: |
| 799 TimelineEventBlock* GetNewBlockLocked() { return NULL; } | 784 TimelineEventBlock* GetNewBlockLocked() { return NULL; } |
| 800 TimelineEventBlock* GetHeadBlockLocked() { return NULL; } | 785 TimelineEventBlock* GetHeadBlockLocked() { return NULL; } |
| 801 void Clear() {} | 786 void Clear() {} |
| 802 TimelineEvent* StartEvent(); | 787 TimelineEvent* StartEvent(); |
| 803 void CompleteEvent(TimelineEvent* event); | 788 void CompleteEvent(TimelineEvent* event); |
| 804 }; | 789 }; |
| 805 | 790 |
| 806 | |
| 807 // A recorder that stores events in chains of blocks of events. | 791 // A recorder that stores events in chains of blocks of events. |
| 808 // NOTE: This recorder will continue to allocate blocks until it exhausts | 792 // NOTE: This recorder will continue to allocate blocks until it exhausts |
| 809 // memory. | 793 // memory. |
| 810 class TimelineEventEndlessRecorder : public TimelineEventRecorder { | 794 class TimelineEventEndlessRecorder : public TimelineEventRecorder { |
| 811 public: | 795 public: |
| 812 TimelineEventEndlessRecorder(); | 796 TimelineEventEndlessRecorder(); |
| 813 virtual ~TimelineEventEndlessRecorder(); | 797 virtual ~TimelineEventEndlessRecorder(); |
| 814 | 798 |
| 815 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 799 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 816 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); | 800 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
| 817 | 801 |
| 818 const char* name() const { return "Endless"; } | 802 const char* name() const { return "Endless"; } |
| 819 | 803 |
| 820 protected: | 804 protected: |
| 821 TimelineEvent* StartEvent(); | 805 TimelineEvent* StartEvent(); |
| 822 void CompleteEvent(TimelineEvent* event); | 806 void CompleteEvent(TimelineEvent* event); |
| 823 TimelineEventBlock* GetNewBlockLocked(); | 807 TimelineEventBlock* GetNewBlockLocked(); |
| 824 TimelineEventBlock* GetHeadBlockLocked(); | 808 TimelineEventBlock* GetHeadBlockLocked(); |
| 825 void Clear(); | 809 void Clear(); |
| 826 | 810 |
| 827 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); | 811 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); |
| 828 | 812 |
| 829 TimelineEventBlock* head_; | 813 TimelineEventBlock* head_; |
| 830 intptr_t block_index_; | 814 intptr_t block_index_; |
| 831 | 815 |
| 832 friend class TimelineTestHelper; | 816 friend class TimelineTestHelper; |
| 833 }; | 817 }; |
| 834 | 818 |
| 835 | |
| 836 // An iterator for blocks. | 819 // An iterator for blocks. |
| 837 class TimelineEventBlockIterator { | 820 class TimelineEventBlockIterator { |
| 838 public: | 821 public: |
| 839 explicit TimelineEventBlockIterator(TimelineEventRecorder* recorder); | 822 explicit TimelineEventBlockIterator(TimelineEventRecorder* recorder); |
| 840 ~TimelineEventBlockIterator(); | 823 ~TimelineEventBlockIterator(); |
| 841 | 824 |
| 842 void Reset(TimelineEventRecorder* recorder); | 825 void Reset(TimelineEventRecorder* recorder); |
| 843 | 826 |
| 844 // Returns false when there are no more blocks. | 827 // Returns false when there are no more blocks. |
| 845 bool HasNext() const; | 828 bool HasNext() const; |
| 846 | 829 |
| 847 // Returns the next block and moves forward. | 830 // Returns the next block and moves forward. |
| 848 TimelineEventBlock* Next(); | 831 TimelineEventBlock* Next(); |
| 849 | 832 |
| 850 private: | 833 private: |
| 851 TimelineEventBlock* current_; | 834 TimelineEventBlock* current_; |
| 852 TimelineEventRecorder* recorder_; | 835 TimelineEventRecorder* recorder_; |
| 853 }; | 836 }; |
| 854 | 837 |
| 855 | |
| 856 } // namespace dart | 838 } // namespace dart |
| 857 | 839 |
| 858 #endif // RUNTIME_VM_TIMELINE_H_ | 840 #endif // RUNTIME_VM_TIMELINE_H_ |
| OLD | NEW |