< prev index next >

src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.hpp

Print this page

 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
 26 #define SHARE_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
 27 
 28 #include "jfr/recorder/storage/jfrBuffer.hpp"
 29 #include "jfr/recorder/storage/jfrEpochStorage.hpp"
 30 #include "jfr/recorder/storage/jfrMemorySpace.hpp"
 31 #include "jfr/recorder/storage/jfrMemorySpaceRetrieval.hpp"

 32 #include "jfr/utilities/jfrLinkedList.hpp"


 33 
 34 class JfrCheckpointManager;
 35 class JfrChunkWriter;
 36 class Thread;
 37 
 38 struct JfrCheckpointEntry {
 39   jlong size;
 40   jlong start_time;
 41   jlong duration;
 42   juint flushpoint;
 43   juint nof_segments;
 44 };
 45 
 46 typedef JfrMemorySpace<JfrCheckpointManager, JfrMspaceRetrieval, JfrLinkedList<JfrBuffer>, JfrLinkedList<JfrBuffer>, true > JfrCheckpointMspace;
 47 typedef JfrEpochStorageHost<JfrBuffer, JfrMspaceRemoveRetrieval, true /* reclaim buffers eagerly*/ > JfrThreadLocalCheckpointMspace;
 48 
 49 //
 50 // Responsible for maintaining checkpoints and by implication types.
 51 // A checkpoint is an event that has a payload consisting of constant types.
 52 // A constant type is a binary relation, a set of key-value pairs.
 53 //
 54 class JfrCheckpointManager : public JfrCHeapObj {
 55  public:
 56   typedef JfrCheckpointMspace::Node Buffer;
 57   typedef JfrCheckpointMspace::NodePtr BufferPtr;
 58  private:
 59   JfrCheckpointMspace* _global_mspace;
 60   JfrThreadLocalCheckpointMspace* _thread_local_mspace;
 61   JfrChunkWriter& _chunkwriter;
 62 
 63   JfrCheckpointManager(JfrChunkWriter& cw);
 64   ~JfrCheckpointManager();
 65   static JfrCheckpointManager& instance();
 66   static JfrCheckpointManager* create(JfrChunkWriter& cw);
 67   bool initialize();
 68   static void destroy();
 69 




 70   static BufferPtr lease(Thread* thread, bool previous_epoch = false, size_t size = 0);
 71   static BufferPtr lease(BufferPtr old, Thread* thread, size_t size);
 72 
 73   static BufferPtr acquire_thread_local(size_t size, Thread* thread);
 74   static BufferPtr lease_thread_local(Thread* thread, size_t size = 0);
 75 
 76   static BufferPtr flush(BufferPtr old, size_t used, size_t requested, Thread* thread);
 77 
 78   size_t clear();
 79   size_t write();
 80   void notify_threads();
 81 
 82   size_t write_static_type_set(Thread* thread);
 83   size_t write_threads(JavaThread* thread);
 84   size_t write_static_type_set_and_threads();
 85   void clear_type_set();
 86   void write_type_set();
 87 
 88   void begin_epoch_shift();
 89   void end_epoch_shift();
 90 
 91   static void on_unloading_classes();
 92   void on_rotation();
 93 
 94   // mspace callback
 95   void register_full(BufferPtr buffer, Thread* thread);
 96 
 97  public:


 98   size_t flush_type_set();
 99   static void create_thread_blob(Thread* thread);
100   static void write_thread_checkpoint(Thread* thread);
101 
102   friend class Jfr;
103   friend class JfrRecorder;
104   friend class JfrRecorderService;
105   friend class JfrCheckpointFlush;
106   friend class JfrCheckpointWriter;
107   friend class JfrSerializer;
108   template <typename, template <typename> class, typename, typename, bool>
109   friend class JfrMemorySpace;
110 };
111 
112 #endif // SHARE_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP

 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
 26 #define SHARE_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
 27 
 28 #include "jfr/recorder/storage/jfrBuffer.hpp"
 29 #include "jfr/recorder/storage/jfrEpochStorage.hpp"
 30 #include "jfr/recorder/storage/jfrMemorySpace.hpp"
 31 #include "jfr/recorder/storage/jfrMemorySpaceRetrieval.hpp"
 32 #include "jfr/utilities/jfrBlob.hpp"
 33 #include "jfr/utilities/jfrLinkedList.hpp"
 34 #include "jfr/utilities/jfrTypes.hpp"
 35 #include "runtime/thread.hpp"
 36 
 37 class JfrCheckpointManager;
 38 class JfrChunkWriter;
 39 class Thread;
 40 
 41 struct JfrCheckpointEntry {
 42   jlong size;
 43   jlong start_time;
 44   jlong duration;
 45   juint flushpoint;
 46   juint nof_segments;
 47 };
 48 
 49 typedef JfrMemorySpace<JfrCheckpointManager, JfrMspaceRetrieval, JfrLinkedList<JfrBuffer>, JfrLinkedList<JfrBuffer>, true > JfrCheckpointMspace;
 50 typedef JfrEpochStorageHost<JfrBuffer, JfrMspaceRemoveRetrieval, true /* reclaim buffers eagerly*/ > JfrThreadLocalCheckpointMspace;
 51 
 52 //
 53 // Responsible for maintaining checkpoints and by implication types.
 54 // A checkpoint is an event that has a payload consisting of constant types.
 55 // A constant type is a binary relation, a set of key-value pairs.
 56 //
 57 class JfrCheckpointManager : public JfrCHeapObj {
 58  public:
 59   typedef JfrCheckpointMspace::Node Buffer;
 60   typedef JfrCheckpointMspace::NodePtr BufferPtr;
 61  private:
 62   JfrCheckpointMspace* _global_mspace;
 63   JfrThreadLocalCheckpointMspace* _java_thread_local_mspace;
 64   JfrChunkWriter& _chunkwriter;
 65 
 66   JfrCheckpointManager(JfrChunkWriter& cw);
 67   ~JfrCheckpointManager();
 68   static JfrCheckpointManager& instance();
 69   static JfrCheckpointManager* create(JfrChunkWriter& cw);
 70   bool initialize();
 71   static void destroy();
 72 
 73   static BufferPtr get_thread_local(Thread* thread);
 74   static void set_thread_local(Thread* thread, BufferPtr buffer);
 75   static BufferPtr acquire_thread_local(size_t size, Thread* thread);
 76 
 77   static BufferPtr lease(Thread* thread, bool previous_epoch = false, size_t size = 0);
 78   static BufferPtr lease(BufferPtr old, Thread* thread, size_t size);


 79   static BufferPtr lease_thread_local(Thread* thread, size_t size = 0);
 80 
 81   static BufferPtr flush(BufferPtr old, size_t used, size_t requested, Thread* thread);
 82 
 83   size_t clear();
 84   size_t write();
 85   void notify_threads();
 86 
 87   size_t write_static_type_set(Thread* thread);
 88   size_t write_threads(JavaThread* thread);
 89   size_t write_static_type_set_and_threads();
 90   void clear_type_set();
 91   void write_type_set();
 92 
 93   void begin_epoch_shift();
 94   void end_epoch_shift();
 95 
 96   static void on_unloading_classes();
 97   void on_rotation();
 98 
 99   // mspace callback
100   void register_full(BufferPtr buffer, Thread* thread);
101 
102  public:
103   static JfrBlobHandle create_thread_blob(JavaThread* jt, traceid tid = 0, oop vthread = NULL);
104   static void write_checkpoint(Thread* t, traceid tid = 0, oop vthread = NULL);
105   size_t flush_type_set();


106 
107   friend class Jfr;
108   friend class JfrRecorder;
109   friend class JfrRecorderService;
110   friend class JfrCheckpointFlush;
111   friend class JfrCheckpointWriter;
112   friend class JfrSerializer;
113   template <typename, template <typename> class, typename, typename, bool>
114   friend class JfrMemorySpace;
115 };
116 
117 #endif // SHARE_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
< prev index next >