src/hotspot/share/gc/z/zTracer.cpp
changeset 58704 8b16701b4636
parent 57603 f9d9bed12d1a
child 58823 6a21dba79b81
child 58863 c16ac7a2eba4
equal deleted inserted replaced
58703:c203d10291e1 58704:8b16701b4636
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 #include "precompiled.hpp"
    24 #include "precompiled.hpp"
       
    25 #include "gc/shared/gcId.hpp"
    25 #include "gc/z/zStat.hpp"
    26 #include "gc/z/zStat.hpp"
    26 #include "gc/z/zTracer.hpp"
    27 #include "gc/z/zTracer.hpp"
    27 #include "gc/shared/gcId.hpp"
       
    28 #include "gc/shared/gcLocker.hpp"
       
    29 #include "jfr/jfrEvents.hpp"
    28 #include "jfr/jfrEvents.hpp"
    30 #include "runtime/safepoint.hpp"
       
    31 #include "runtime/safepointVerifiers.hpp"
    29 #include "runtime/safepointVerifiers.hpp"
       
    30 #include "utilities/debug.hpp"
       
    31 #include "utilities/macros.hpp"
    32 #if INCLUDE_JFR
    32 #if INCLUDE_JFR
    33 #include "jfr/metadata/jfrSerializer.hpp"
    33 #include "jfr/metadata/jfrSerializer.hpp"
    34 #endif
    34 #endif
    35 
    35 
    36 #if INCLUDE_JFR
    36 #if INCLUDE_JFR
       
    37 
    37 class ZStatisticsCounterTypeConstant : public JfrSerializer {
    38 class ZStatisticsCounterTypeConstant : public JfrSerializer {
    38 public:
    39 public:
    39   virtual void serialize(JfrCheckpointWriter& writer) {
    40   virtual void serialize(JfrCheckpointWriter& writer) {
    40     writer.write_count(ZStatCounter::count());
    41     writer.write_count(ZStatCounter::count());
    41     for (ZStatCounter* counter = ZStatCounter::first(); counter != NULL; counter = counter->next()) {
    42     for (ZStatCounter* counter = ZStatCounter::first(); counter != NULL; counter = counter->next()) {
    64   JfrSerializer::register_serializer(TYPE_ZSTATISTICSSAMPLERTYPE,
    65   JfrSerializer::register_serializer(TYPE_ZSTATISTICSSAMPLERTYPE,
    65                                      false /* require_safepoint */,
    66                                      false /* require_safepoint */,
    66                                      true /* permit_cache */,
    67                                      true /* permit_cache */,
    67                                      new ZStatisticsSamplerTypeConstant());
    68                                      new ZStatisticsSamplerTypeConstant());
    68 }
    69 }
    69 #endif
    70 
       
    71 #endif // INCLUDE_JFR
    70 
    72 
    71 ZTracer* ZTracer::_tracer = NULL;
    73 ZTracer* ZTracer::_tracer = NULL;
    72 
    74 
    73 ZTracer::ZTracer() :
    75 ZTracer::ZTracer() :
    74     GCTracer(Z) {}
    76     GCTracer(Z) {}
    77   assert(_tracer == NULL, "Already initialized");
    79   assert(_tracer == NULL, "Already initialized");
    78   _tracer = new (ResourceObj::C_HEAP, mtGC) ZTracer();
    80   _tracer = new (ResourceObj::C_HEAP, mtGC) ZTracer();
    79   JFR_ONLY(register_jfr_type_serializers());
    81   JFR_ONLY(register_jfr_type_serializers());
    80 }
    82 }
    81 
    83 
    82 void ZTracer::send_stat_counter(uint32_t counter_id, uint64_t increment, uint64_t value) {
    84 void ZTracer::send_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) {
    83   NoSafepointVerifier nsv;
    85   NoSafepointVerifier nsv;
    84 
    86 
    85   EventZStatisticsCounter e;
    87   EventZStatisticsCounter e;
    86   if (e.should_commit()) {
    88   if (e.should_commit()) {
    87     e.set_id(counter_id);
    89     e.set_id(counter.id());
    88     e.set_increment(increment);
    90     e.set_increment(increment);
    89     e.set_value(value);
    91     e.set_value(value);
    90     e.commit();
    92     e.commit();
    91   }
    93   }
    92 }
    94 }
    93 
    95 
    94 void ZTracer::send_stat_sampler(uint32_t sampler_id, uint64_t value) {
    96 void ZTracer::send_stat_sampler(const ZStatSampler& sampler, uint64_t value) {
    95   NoSafepointVerifier nsv;
    97   NoSafepointVerifier nsv;
    96 
    98 
    97   EventZStatisticsSampler e;
    99   EventZStatisticsSampler e;
    98   if (e.should_commit()) {
   100   if (e.should_commit()) {
    99     e.set_id(sampler_id);
   101     e.set_id(sampler.id());
   100     e.set_value(value);
   102     e.set_value(value);
   101     e.commit();
   103     e.commit();
   102   }
   104   }
   103 }
   105 }
   104 
   106 
   113     e.set_endtime(end);
   115     e.set_endtime(end);
   114     e.commit();
   116     e.commit();
   115   }
   117   }
   116 }
   118 }
   117 
   119 
   118 void ZTracer::send_page_alloc(size_t size, size_t used, size_t free, size_t cache, bool nonblocking, bool noreserve) {
   120 void ZTracer::send_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) {
   119   NoSafepointVerifier nsv;
   121   NoSafepointVerifier nsv;
   120 
   122 
   121   EventZPageAllocation e;
   123   EventZPageAllocation e;
   122   if (e.should_commit()) {
   124   if (e.should_commit()) {
   123     e.set_pageSize(size);
   125     e.set_pageSize(size);
   124     e.set_usedAfter(used);
   126     e.set_usedAfter(used);
   125     e.set_freeAfter(free);
   127     e.set_freeAfter(free);
   126     e.set_inCacheAfter(cache);
   128     e.set_inCacheAfter(cache);
   127     e.set_nonBlocking(nonblocking);
   129     e.set_nonBlocking(flags.non_blocking());
   128     e.set_noReserve(noreserve);
   130     e.set_noReserve(flags.no_reserve());
   129     e.commit();
   131     e.commit();
   130   }
   132   }
   131 }
   133 }
   132 
       
   133 void ZTracer::report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) {
       
   134   send_stat_counter(counter.id(), increment, value);
       
   135 }
       
   136 
       
   137 void ZTracer::report_stat_sampler(const ZStatSampler& sampler, uint64_t value) {
       
   138   send_stat_sampler(sampler.id(), value);
       
   139 }
       
   140 
       
   141 void ZTracer::report_thread_phase(const ZStatPhase& phase, const Ticks& start, const Ticks& end) {
       
   142   send_thread_phase(phase.name(), start, end);
       
   143 }
       
   144 
       
   145 void ZTracer::report_thread_phase(const char* name, const Ticks& start, const Ticks& end) {
       
   146   send_thread_phase(name, start, end);
       
   147 }
       
   148 
       
   149 void ZTracer::report_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) {
       
   150   send_page_alloc(size, used, free, cache, flags.non_blocking(), flags.no_reserve());
       
   151 }