src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
branchJEP-349-branch
changeset 57983 a57907813a83
parent 57878 bffba8d6611a
child 58049 10ecdb5d3574
equal deleted inserted replaced
57971:aa7b1ea52413 57983:a57907813a83
    28 #include "code/codeCache.hpp"
    28 #include "code/codeCache.hpp"
    29 #include "gc/shared/gcCause.hpp"
    29 #include "gc/shared/gcCause.hpp"
    30 #include "gc/shared/gcName.hpp"
    30 #include "gc/shared/gcName.hpp"
    31 #include "gc/shared/gcTrace.hpp"
    31 #include "gc/shared/gcTrace.hpp"
    32 #include "gc/shared/gcWhen.hpp"
    32 #include "gc/shared/gcWhen.hpp"
    33 #include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp"
       
    34 #include "jfr/leakprofiler/leakProfiler.hpp"
    33 #include "jfr/leakprofiler/leakProfiler.hpp"
    35 #include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp"
    34 #include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp"
    36 #include "jfr/recorder/checkpoint/types/jfrType.hpp"
    35 #include "jfr/recorder/checkpoint/types/jfrType.hpp"
    37 #include "jfr/recorder/jfrRecorder.hpp"
    36 #include "jfr/recorder/jfrRecorder.hpp"
    38 #include "jfr/recorder/checkpoint/types/jfrThreadGroup.hpp"
    37 #include "jfr/recorder/checkpoint/types/jfrThreadGroup.hpp"
   291   }
   290   }
   292 }
   291 }
   293 
   292 
   294 class TypeSetSerialization {
   293 class TypeSetSerialization {
   295  private:
   294  private:
       
   295   JfrCheckpointWriter* _leakp_writer;
   296   size_t _elements;
   296   size_t _elements;
   297   bool _class_unload;
   297   bool _class_unload;
   298   bool _flushpoint;
   298   bool _flushpoint;
   299  public:
   299  public:
   300   explicit TypeSetSerialization(bool class_unload, bool flushpoint) : _elements(0), _class_unload(class_unload), _flushpoint(flushpoint) {}
   300   TypeSetSerialization(bool class_unload, bool flushpoint, JfrCheckpointWriter* leakp_writer = NULL) :
       
   301     _leakp_writer(leakp_writer), _elements(0), _class_unload(class_unload), _flushpoint(flushpoint) {}
   301   void write(JfrCheckpointWriter& writer) {
   302   void write(JfrCheckpointWriter& writer) {
   302     MutexLocker cld_lock(SafepointSynchronize::is_at_safepoint() ? NULL : ClassLoaderDataGraph_lock);
   303     MutexLocker cld_lock(SafepointSynchronize::is_at_safepoint() ? NULL : ClassLoaderDataGraph_lock);
   303     MutexLocker lock(SafepointSynchronize::is_at_safepoint() ? NULL : Module_lock);
   304     MutexLocker lock(SafepointSynchronize::is_at_safepoint() ? NULL : Module_lock);
   304     _elements = JfrTypeSet::serialize(&writer, _class_unload, _flushpoint);
   305    _elements = JfrTypeSet::serialize(&writer, _leakp_writer, _class_unload, _flushpoint);
   305   }
   306   }
   306   size_t elements() const {
   307   size_t elements() const {
   307     return _elements;
   308     return _elements;
   308   }
   309   }
   309 };
   310 };
   310 
   311 
   311 void ClassUnloadTypeSet::serialize(JfrCheckpointWriter& writer) {
   312 void ClassUnloadTypeSet::serialize(JfrCheckpointWriter& writer) {
   312   TypeSetSerialization type_set(true, false);
   313   TypeSetSerialization type_set(true, false);
   313   type_set.write(writer);
   314   type_set.write(writer);
   314   if (LeakProfiler::is_running()) {
       
   315     ObjectSampleCheckpoint::on_type_set_unload(writer);
       
   316     return;
       
   317   }
       
   318 };
   315 };
   319 
   316 
   320 void FlushTypeSet::serialize(JfrCheckpointWriter& writer) {
   317 void FlushTypeSet::serialize(JfrCheckpointWriter& writer) {
   321   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   318   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   322   TypeSetSerialization type_set(false, true);
   319   TypeSetSerialization type_set(false, true);
   326 
   323 
   327 size_t FlushTypeSet::elements() const {
   324 size_t FlushTypeSet::elements() const {
   328   return _elements;
   325   return _elements;
   329 }
   326 }
   330 
   327 
       
   328 TypeSet::TypeSet(JfrCheckpointWriter* leakp_writer) : _leakp_writer(leakp_writer) {}
       
   329 
   331 void TypeSet::serialize(JfrCheckpointWriter& writer) {
   330 void TypeSet::serialize(JfrCheckpointWriter& writer) {
   332   TypeSetSerialization type_set(false, false);
   331   TypeSetSerialization type_set(false, false, _leakp_writer);
   333   type_set.write(writer);
   332   type_set.write(writer);
   334 };
   333 };
   335 
   334 
   336 void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) {
   335 void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) {
   337   JfrThreadState::serialize(writer);
   336   JfrThreadState::serialize(writer);