| 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 "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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 774 |
| 775 // A recorder that stores events in a buffer of fixed capacity. When the buffer | 775 // A recorder that stores events in a buffer of fixed capacity. When the buffer |
| 776 // is full, new events overwrite old events. | 776 // is full, new events overwrite old events. |
| 777 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder { | 777 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder { |
| 778 public: | 778 public: |
| 779 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity) | 779 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity) |
| 780 : TimelineEventFixedBufferRecorder(capacity) {} | 780 : TimelineEventFixedBufferRecorder(capacity) {} |
| 781 ~TimelineEventRingRecorder() {} | 781 ~TimelineEventRingRecorder() {} |
| 782 | 782 |
| 783 const char* name() const { | 783 const char* name() const { |
| 784 return "ring"; | 784 return "Ring"; |
| 785 } | 785 } |
| 786 | 786 |
| 787 protected: | 787 protected: |
| 788 TimelineEventBlock* GetNewBlockLocked(); | 788 TimelineEventBlock* GetNewBlockLocked(); |
| 789 }; | 789 }; |
| 790 | 790 |
| 791 | 791 |
| 792 // A recorder that stores events in a buffer of fixed capacity. When the buffer | 792 // A recorder that stores events in a buffer of fixed capacity. When the buffer |
| 793 // is full, new events are dropped. | 793 // is full, new events are dropped. |
| 794 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { | 794 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { |
| 795 public: | 795 public: |
| 796 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) | 796 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) |
| 797 : TimelineEventFixedBufferRecorder(capacity) {} | 797 : TimelineEventFixedBufferRecorder(capacity) {} |
| 798 ~TimelineEventStartupRecorder() {} | 798 ~TimelineEventStartupRecorder() {} |
| 799 | 799 |
| 800 const char* name() const { | 800 const char* name() const { |
| 801 return "startup"; | 801 return "Startup"; |
| 802 } | 802 } |
| 803 | 803 |
| 804 protected: | 804 protected: |
| 805 TimelineEventBlock* GetNewBlockLocked(); | 805 TimelineEventBlock* GetNewBlockLocked(); |
| 806 }; | 806 }; |
| 807 | 807 |
| 808 | 808 |
| 809 // An abstract recorder that calls |OnEvent| whenever an event is complete. | 809 // An abstract recorder that calls |OnEvent| whenever an event is complete. |
| 810 // This should only be used for testing. | 810 // This should only be used for testing. |
| 811 class TimelineEventCallbackRecorder : public TimelineEventRecorder { | 811 class TimelineEventCallbackRecorder : public TimelineEventRecorder { |
| 812 public: | 812 public: |
| 813 TimelineEventCallbackRecorder(); | 813 TimelineEventCallbackRecorder(); |
| 814 ~TimelineEventCallbackRecorder(); | 814 ~TimelineEventCallbackRecorder(); |
| 815 | 815 |
| 816 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 816 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 817 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); | 817 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
| 818 | 818 |
| 819 // Called when |event| is completed. It is unsafe to keep a reference to | 819 // Called when |event| is completed. It is unsafe to keep a reference to |
| 820 // |event| as it may be freed as soon as this function returns. | 820 // |event| as it may be freed as soon as this function returns. |
| 821 virtual void OnEvent(TimelineEvent* event) = 0; | 821 virtual void OnEvent(TimelineEvent* event) = 0; |
| 822 | 822 |
| 823 const char* name() const { | 823 const char* name() const { |
| 824 return "callback"; | 824 return "Callback"; |
| 825 } | 825 } |
| 826 | 826 |
| 827 protected: | 827 protected: |
| 828 TimelineEventBlock* GetNewBlockLocked() { | 828 TimelineEventBlock* GetNewBlockLocked() { |
| 829 return NULL; | 829 return NULL; |
| 830 } | 830 } |
| 831 TimelineEventBlock* GetHeadBlockLocked() { | 831 TimelineEventBlock* GetHeadBlockLocked() { |
| 832 return NULL; | 832 return NULL; |
| 833 } | 833 } |
| 834 void Clear() { | 834 void Clear() { |
| 835 } | 835 } |
| 836 TimelineEvent* StartEvent(); | 836 TimelineEvent* StartEvent(); |
| 837 void CompleteEvent(TimelineEvent* event); | 837 void CompleteEvent(TimelineEvent* event); |
| 838 }; | 838 }; |
| 839 | 839 |
| 840 | 840 |
| 841 // A recorder that stores events in chains of blocks of events. | 841 // A recorder that stores events in chains of blocks of events. |
| 842 // NOTE: This recorder will continue to allocate blocks until it exhausts | 842 // NOTE: This recorder will continue to allocate blocks until it exhausts |
| 843 // memory. | 843 // memory. |
| 844 class TimelineEventEndlessRecorder : public TimelineEventRecorder { | 844 class TimelineEventEndlessRecorder : public TimelineEventRecorder { |
| 845 public: | 845 public: |
| 846 TimelineEventEndlessRecorder(); | 846 TimelineEventEndlessRecorder(); |
| 847 | 847 |
| 848 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 848 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 849 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); | 849 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
| 850 | 850 |
| 851 const char* name() const { | 851 const char* name() const { |
| 852 return "endless"; | 852 return "Endless"; |
| 853 } | 853 } |
| 854 | 854 |
| 855 protected: | 855 protected: |
| 856 TimelineEvent* StartEvent(); | 856 TimelineEvent* StartEvent(); |
| 857 void CompleteEvent(TimelineEvent* event); | 857 void CompleteEvent(TimelineEvent* event); |
| 858 TimelineEventBlock* GetNewBlockLocked(); | 858 TimelineEventBlock* GetNewBlockLocked(); |
| 859 TimelineEventBlock* GetHeadBlockLocked(); | 859 TimelineEventBlock* GetHeadBlockLocked(); |
| 860 void Clear(); | 860 void Clear(); |
| 861 | 861 |
| 862 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); | 862 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 884 | 884 |
| 885 private: | 885 private: |
| 886 TimelineEventBlock* current_; | 886 TimelineEventBlock* current_; |
| 887 TimelineEventRecorder* recorder_; | 887 TimelineEventRecorder* recorder_; |
| 888 }; | 888 }; |
| 889 | 889 |
| 890 | 890 |
| 891 } // namespace dart | 891 } // namespace dart |
| 892 | 892 |
| 893 #endif // VM_TIMELINE_H_ | 893 #endif // VM_TIMELINE_H_ |
| OLD | NEW |