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

Side by Side Diff: runtime/vm/timeline.h

Issue 2621163008: VM: Free [TimelineEventBlock]s before shutting down (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder); 674 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder);
675 }; 675 };
676 676
677 677
678 // 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.
679 class TimelineEventFixedBufferRecorder : public TimelineEventRecorder { 679 class TimelineEventFixedBufferRecorder : public TimelineEventRecorder {
680 public: 680 public:
681 static const intptr_t kDefaultCapacity = 8192; 681 static const intptr_t kDefaultCapacity = 8192;
682 682
683 explicit TimelineEventFixedBufferRecorder(intptr_t capacity); 683 explicit TimelineEventFixedBufferRecorder(intptr_t capacity);
684 ~TimelineEventFixedBufferRecorder(); 684 virtual ~TimelineEventFixedBufferRecorder();
685 685
686 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); 686 void PrintJSON(JSONStream* js, TimelineEventFilter* filter);
687 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); 687 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter);
688 688
689 protected: 689 protected:
690 TimelineEvent* StartEvent(); 690 TimelineEvent* StartEvent();
691 void CompleteEvent(TimelineEvent* event); 691 void CompleteEvent(TimelineEvent* event);
692 TimelineEventBlock* GetHeadBlockLocked(); 692 TimelineEventBlock* GetHeadBlockLocked();
693 intptr_t FindOldestBlockIndex() const; 693 intptr_t FindOldestBlockIndex() const;
694 void Clear(); 694 void Clear();
695 695
696 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); 696 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter);
697 697
698 TimelineEventBlock** blocks_; 698 TimelineEventBlock** blocks_;
699 intptr_t capacity_; 699 intptr_t capacity_;
700 intptr_t num_blocks_; 700 intptr_t num_blocks_;
701 intptr_t block_cursor_; 701 intptr_t block_cursor_;
702 }; 702 };
703 703
704 704
705 // A recorder that stores events in a buffer of fixed capacity. When the buffer 705 // A recorder that stores events in a buffer of fixed capacity. When the buffer
706 // is full, new events overwrite old events. 706 // is full, new events overwrite old events.
707 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder { 707 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder {
708 public: 708 public:
709 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity) 709 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity)
710 : TimelineEventFixedBufferRecorder(capacity) {} 710 : TimelineEventFixedBufferRecorder(capacity) {}
711 ~TimelineEventRingRecorder() {} 711 virtual ~TimelineEventRingRecorder() {}
712 712
713 const char* name() const { return "Ring"; } 713 const char* name() const { return "Ring"; }
714 714
715 protected: 715 protected:
716 TimelineEventBlock* GetNewBlockLocked(); 716 TimelineEventBlock* GetNewBlockLocked();
717 }; 717 };
718 718
719 719
720 // A recorder that writes events to Android Systrace. Events are also stored in 720 // A recorder that writes events to Android Systrace. Events are also stored in
721 // a buffer of fixed capacity. When the buffer is full, new events overwrite 721 // a buffer of fixed capacity. When the buffer is full, new events overwrite
722 // old events. 722 // old events.
723 class TimelineEventSystraceRecorder : public TimelineEventFixedBufferRecorder { 723 class TimelineEventSystraceRecorder : public TimelineEventFixedBufferRecorder {
724 public: 724 public:
725 explicit TimelineEventSystraceRecorder(intptr_t capacity = kDefaultCapacity); 725 explicit TimelineEventSystraceRecorder(intptr_t capacity = kDefaultCapacity);
726 726 virtual ~TimelineEventSystraceRecorder();
727 ~TimelineEventSystraceRecorder();
728 727
729 const char* name() const { return "Systrace"; } 728 const char* name() const { return "Systrace"; }
730 729
731 protected: 730 protected:
732 TimelineEventBlock* GetNewBlockLocked(); 731 TimelineEventBlock* GetNewBlockLocked();
733 void CompleteEvent(TimelineEvent* event); 732 void CompleteEvent(TimelineEvent* event);
734 733
735 int systrace_fd_; 734 int systrace_fd_;
736 }; 735 };
737 736
738 737
739 // A recorder that stores events in a buffer of fixed capacity. When the buffer 738 // A recorder that stores events in a buffer of fixed capacity. When the buffer
740 // is full, new events are dropped. 739 // is full, new events are dropped.
741 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { 740 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder {
742 public: 741 public:
743 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) 742 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity)
744 : TimelineEventFixedBufferRecorder(capacity) {} 743 : TimelineEventFixedBufferRecorder(capacity) {}
745 ~TimelineEventStartupRecorder() {} 744 virtual ~TimelineEventStartupRecorder() {}
746 745
747 const char* name() const { return "Startup"; } 746 const char* name() const { return "Startup"; }
748 747
749 protected: 748 protected:
750 TimelineEventBlock* GetNewBlockLocked(); 749 TimelineEventBlock* GetNewBlockLocked();
751 }; 750 };
752 751
753 752
754 // An abstract recorder that calls |OnEvent| whenever an event is complete. 753 // An abstract recorder that calls |OnEvent| whenever an event is complete.
755 // This should only be used for testing. 754 // This should only be used for testing.
756 class TimelineEventCallbackRecorder : public TimelineEventRecorder { 755 class TimelineEventCallbackRecorder : public TimelineEventRecorder {
757 public: 756 public:
758 TimelineEventCallbackRecorder(); 757 TimelineEventCallbackRecorder();
759 ~TimelineEventCallbackRecorder(); 758 virtual ~TimelineEventCallbackRecorder();
760 759
761 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); 760 void PrintJSON(JSONStream* js, TimelineEventFilter* filter);
762 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); 761 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter);
763 762
764 // Called when |event| is completed. It is unsafe to keep a reference to 763 // Called when |event| is completed. It is unsafe to keep a reference to
765 // |event| as it may be freed as soon as this function returns. 764 // |event| as it may be freed as soon as this function returns.
766 virtual void OnEvent(TimelineEvent* event) = 0; 765 virtual void OnEvent(TimelineEvent* event) = 0;
767 766
768 const char* name() const { return "Callback"; } 767 const char* name() const { return "Callback"; }
769 768
770 protected: 769 protected:
771 TimelineEventBlock* GetNewBlockLocked() { return NULL; } 770 TimelineEventBlock* GetNewBlockLocked() { return NULL; }
772 TimelineEventBlock* GetHeadBlockLocked() { return NULL; } 771 TimelineEventBlock* GetHeadBlockLocked() { return NULL; }
773 void Clear() {} 772 void Clear() {}
774 TimelineEvent* StartEvent(); 773 TimelineEvent* StartEvent();
775 void CompleteEvent(TimelineEvent* event); 774 void CompleteEvent(TimelineEvent* event);
776 }; 775 };
777 776
778 777
779 // A recorder that stores events in chains of blocks of events. 778 // A recorder that stores events in chains of blocks of events.
780 // NOTE: This recorder will continue to allocate blocks until it exhausts 779 // NOTE: This recorder will continue to allocate blocks until it exhausts
781 // memory. 780 // memory.
782 class TimelineEventEndlessRecorder : public TimelineEventRecorder { 781 class TimelineEventEndlessRecorder : public TimelineEventRecorder {
783 public: 782 public:
784 TimelineEventEndlessRecorder(); 783 TimelineEventEndlessRecorder();
784 virtual ~TimelineEventEndlessRecorder();
785 785
786 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); 786 void PrintJSON(JSONStream* js, TimelineEventFilter* filter);
787 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); 787 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter);
788 788
789 const char* name() const { return "Endless"; } 789 const char* name() const { return "Endless"; }
790 790
791 protected: 791 protected:
792 TimelineEvent* StartEvent(); 792 TimelineEvent* StartEvent();
793 void CompleteEvent(TimelineEvent* event); 793 void CompleteEvent(TimelineEvent* event);
794 TimelineEventBlock* GetNewBlockLocked(); 794 TimelineEventBlock* GetNewBlockLocked();
(...skipping 25 matching lines...) Expand all
820 820
821 private: 821 private:
822 TimelineEventBlock* current_; 822 TimelineEventBlock* current_;
823 TimelineEventRecorder* recorder_; 823 TimelineEventRecorder* recorder_;
824 }; 824 };
825 825
826 826
827 } // namespace dart 827 } // namespace dart
828 828
829 #endif // RUNTIME_VM_TIMELINE_H_ 829 #endif // RUNTIME_VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698