< prev index next >

src/share/vm/gc_implementation/shared/gcTraceSend.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 #include "precompiled.hpp"

  26 #include "gc_implementation/shared/gcHeapSummary.hpp"
  27 #include "gc_implementation/shared/gcTimer.hpp"
  28 #include "gc_implementation/shared/gcTrace.hpp"
  29 #include "gc_implementation/shared/gcWhen.hpp"
  30 #include "gc_implementation/shared/copyFailedInfo.hpp"
  31 #include "runtime/os.hpp"
  32 #include "trace/tracing.hpp"
  33 #include "trace/traceBackend.hpp"
  34 #if INCLUDE_ALL_GCS
  35 #include "gc_implementation/g1/evacuationInfo.hpp"
  36 #include "gc_implementation/g1/g1YCTypes.hpp"
  37 #endif
  38 
  39 // All GC dependencies against the trace framework is contained within this file.
  40 
  41 typedef uintptr_t TraceAddress;
  42 
  43 void GCTracer::send_garbage_collection_event() const {
  44   EventGCGarbageCollection event(UNTIMED);
  45   if (event.should_commit()) {
  46     event.set_gcId(_shared_gc_info.gc_id().id());
  47     event.set_name(_shared_gc_info.name());
  48     event.set_cause((u2) _shared_gc_info.cause());
  49     event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
  50     event.set_longestPause(_shared_gc_info.longest_pause());
  51     event.set_starttime(_shared_gc_info.start_timestamp());
  52     event.set_endtime(_shared_gc_info.end_timestamp());
  53     event.commit();
  54   }
  55 }
  56 
  57 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
  58   EventGCReferenceStatistics e;
  59   if (e.should_commit()) {
  60       e.set_gcId(_shared_gc_info.gc_id().id());
  61       e.set_type((u1)type);
  62       e.set_count(count);
  63       e.commit();
  64   }


  72     e.set_when(when);
  73     e.set_metadataType(mdtype);
  74 
  75     e.set_specializedChunks(summary.num_specialized_chunks());
  76     e.set_specializedChunksTotalSize(summary.specialized_chunks_size_in_bytes());
  77 
  78     e.set_smallChunks(summary.num_small_chunks());
  79     e.set_smallChunksTotalSize(summary.small_chunks_size_in_bytes());
  80 
  81     e.set_mediumChunks(summary.num_medium_chunks());
  82     e.set_mediumChunksTotalSize(summary.medium_chunks_size_in_bytes());
  83 
  84     e.set_humongousChunks(summary.num_humongous_chunks());
  85     e.set_humongousChunksTotalSize(summary.humongous_chunks_size_in_bytes());
  86 
  87     e.commit();
  88   }
  89 }
  90 
  91 void ParallelOldTracer::send_parallel_old_event() const {
  92   EventGCParallelOld e(UNTIMED);
  93   if (e.should_commit()) {
  94     e.set_gcId(_shared_gc_info.gc_id().id());
  95     e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
  96     e.set_starttime(_shared_gc_info.start_timestamp());
  97     e.set_endtime(_shared_gc_info.end_timestamp());
  98     e.commit();
  99   }
 100 }
 101 
 102 void YoungGCTracer::send_young_gc_event() const {
 103   EventGCYoungGarbageCollection e(UNTIMED);
 104   if (e.should_commit()) {
 105     e.set_gcId(_shared_gc_info.gc_id().id());
 106     e.set_tenuringThreshold(_tenuring_threshold);
 107     e.set_starttime(_shared_gc_info.start_timestamp());
 108     e.set_endtime(_shared_gc_info.end_timestamp());
 109     e.commit();
 110   }
 111 }
 112 






































 113 void OldGCTracer::send_old_gc_event() const {
 114   EventGCOldGarbageCollection e(UNTIMED);
 115   if (e.should_commit()) {
 116     e.set_gcId(_shared_gc_info.gc_id().id());
 117     e.set_starttime(_shared_gc_info.start_timestamp());
 118     e.set_endtime(_shared_gc_info.end_timestamp());
 119     e.commit();
 120   }
 121 }
 122 
 123 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
 124   TraceStructCopyFailed failed_info;
 125   failed_info.set_objectCount(cf_info.failed_count());
 126   failed_info.set_firstSize(cf_info.first_size());
 127   failed_info.set_smallestSize(cf_info.smallest_size());
 128   failed_info.set_totalSize(cf_info.total_size());
 129   return failed_info;
 130 }
 131 
 132 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
 133   EventPromotionFailed e;
 134   if (e.should_commit()) {
 135     e.set_gcId(_shared_gc_info.gc_id().id());
 136     e.set_data(to_trace_struct(pf_info));
 137     e.set_thread(pf_info.thread()->thread_id());
 138     e.commit();
 139   }
 140 }
 141 
 142 // Common to CMS and G1
 143 void OldGCTracer::send_concurrent_mode_failure_event() {
 144   EventConcurrentModeFailure e;
 145   if (e.should_commit()) {
 146     e.set_gcId(_shared_gc_info.gc_id().id());
 147     e.commit();
 148   }
 149 }
 150 
 151 #if INCLUDE_ALL_GCS
 152 void G1NewTracer::send_g1_young_gc_event() {
 153   EventGCG1GarbageCollection e(UNTIMED);
 154   if (e.should_commit()) {
 155     e.set_gcId(_shared_gc_info.gc_id().id());
 156     e.set_type(_g1_young_gc_info.type());
 157     e.set_starttime(_shared_gc_info.start_timestamp());
 158     e.set_endtime(_shared_gc_info.end_timestamp());
 159     e.commit();
 160   }
 161 }
 162 











 163 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
 164   EventEvacuationInfo e;
 165   if (e.should_commit()) {
 166     e.set_gcId(_shared_gc_info.gc_id().id());
 167     e.set_cSetRegions(info->collectionset_regions());
 168     e.set_cSetUsedBefore(info->collectionset_used_before());
 169     e.set_cSetUsedAfter(info->collectionset_used_after());
 170     e.set_allocationRegions(info->allocation_regions());
 171     e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
 172     e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
 173     e.set_bytesCopied(info->bytes_copied());
 174     e.set_regionsFreed(info->regions_freed());
 175     e.commit();
 176   }
 177 }
 178 
 179 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
 180   EventEvacuationFailed e;
 181   if (e.should_commit()) {
 182     e.set_gcId(_shared_gc_info.gc_id().id());
 183     e.set_data(to_trace_struct(ef_info));
 184     e.commit();
 185   }
 186 }
 187 #endif
 188 
 189 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
 190   TraceStructVirtualSpace space;


 191   space.set_start((TraceAddress)summary.start());
 192   space.set_committedEnd((TraceAddress)summary.committed_end());
 193   space.set_committedSize(summary.committed_size());
 194   space.set_reservedEnd((TraceAddress)summary.reserved_end());
 195   space.set_reservedSize(summary.reserved_size());
 196   return space;
 197 }
 198 
 199 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
 200   TraceStructObjectSpace space;
 201   space.set_start((TraceAddress)summary.start());
 202   space.set_end((TraceAddress)summary.end());
 203   space.set_used(summary.used());
 204   space.set_size(summary.size());
 205   return space;
 206 }
 207 
 208 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
 209   GCId _gc_id;
 210   GCWhen::Type _when;
 211  public:
 212   GCHeapSummaryEventSender(GCId gc_id, GCWhen::Type when) : _gc_id(gc_id), _when(when) {}
 213 
 214   void visit(const GCHeapSummary* heap_summary) const {
 215     const VirtualSpaceSummary& heap_space = heap_summary->heap();
 216 
 217     EventGCHeapSummary e;
 218     if (e.should_commit()) {
 219       e.set_gcId(_gc_id.id());
 220       e.set_when((u1)_when);
 221       e.set_heapSpace(to_trace_struct(heap_space));
 222       e.set_heapUsed(heap_summary->used());
 223       e.commit();
 224     }
 225   }
 226 















 227   void visit(const PSHeapSummary* ps_heap_summary) const {
 228     visit((GCHeapSummary*)ps_heap_summary);
 229 
 230     const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
 231     const SpaceSummary& old_space = ps_heap_summary->old_space();
 232     const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
 233     const SpaceSummary& eden_space = ps_heap_summary->eden();
 234     const SpaceSummary& from_space = ps_heap_summary->from();
 235     const SpaceSummary& to_space = ps_heap_summary->to();
 236 
 237     EventPSHeapSummary e;
 238     if (e.should_commit()) {
 239       e.set_gcId(_gc_id.id());
 240       e.set_when((u1)_when);
 241 
 242       e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
 243       e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
 244       e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
 245       e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
 246       e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
 247       e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
 248       e.commit();
 249     }
 250   }
 251 };
 252 
 253 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
 254   GCHeapSummaryEventSender visitor(_shared_gc_info.gc_id(), when);
 255   heap_summary.accept(&visitor);
 256 }
 257 
 258 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
 259   TraceStructMetaspaceSizes meta_sizes;
 260 
 261   meta_sizes.set_committed(sizes.committed());
 262   meta_sizes.set_used(sizes.used());
 263   meta_sizes.set_reserved(sizes.reserved());
 264 
 265   return meta_sizes;
 266 }
 267 
 268 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
 269   EventMetaspaceSummary e;
 270   if (e.should_commit()) {
 271     e.set_gcId(_shared_gc_info.gc_id().id());
 272     e.set_when((u1) when);
 273     e.set_gcThreshold(meta_space_summary.capacity_until_GC());
 274     e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
 275     e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
 276     e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
 277     e.commit();
 278   }
 279 }
 280 
 281 class PhaseSender : public PhaseVisitor {
 282   GCId _gc_id;
 283  public:
 284   PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
 285 
 286   template<typename T>
 287   void send_phase(PausePhase* pause) {
 288     T event(UNTIMED);
 289     if (event.should_commit()) {
 290       event.set_gcId(_gc_id.id());
 291       event.set_name(pause->name());
 292       event.set_starttime(pause->start());
 293       event.set_endtime(pause->end());
 294       event.commit();
 295     }
 296   }
 297 
 298   void visit(GCPhase* pause) { ShouldNotReachHere(); }
 299   void visit(ConcurrentPhase* pause) { Unimplemented(); }
 300   void visit(PausePhase* pause) {
 301     assert(PhasesStack::PHASE_LEVELS == 5, "Need more event types");
 302 
 303     switch (pause->level()) {
 304       case 0: send_phase<EventGCPhasePause>(pause); break;
 305       case 1: send_phase<EventGCPhasePauseLevel1>(pause); break;
 306       case 2: send_phase<EventGCPhasePauseLevel2>(pause); break;
 307       case 3: send_phase<EventGCPhasePauseLevel3>(pause); break;
 308       default: /* Ignore sending this phase */ break;
 309     }
 310   }
 311 };
 312 
 313 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 #include "precompiled.hpp"
  26 #include "jfr/jfrEvents.hpp"
  27 #include "gc_implementation/shared/gcHeapSummary.hpp"
  28 #include "gc_implementation/shared/gcTimer.hpp"
  29 #include "gc_implementation/shared/gcTrace.hpp"
  30 #include "gc_implementation/shared/gcWhen.hpp"
  31 #include "gc_implementation/shared/copyFailedInfo.hpp"
  32 #include "runtime/os.hpp"


  33 #if INCLUDE_ALL_GCS
  34 #include "gc_implementation/g1/evacuationInfo.hpp"
  35 #include "gc_implementation/g1/g1YCTypes.hpp"
  36 #endif
  37 
  38 // All GC dependencies against the trace framework is contained within this file.
  39 
  40 typedef uintptr_t TraceAddress;
  41 
  42 void GCTracer::send_garbage_collection_event() const {
  43   EventGarbageCollection event(UNTIMED);
  44   if (event.should_commit()) {
  45     event.set_gcId(_shared_gc_info.gc_id().id());
  46     event.set_name(_shared_gc_info.name());
  47     event.set_cause((u2) _shared_gc_info.cause());
  48     event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
  49     event.set_longestPause(_shared_gc_info.longest_pause());
  50     event.set_starttime(_shared_gc_info.start_timestamp());
  51     event.set_endtime(_shared_gc_info.end_timestamp());
  52     event.commit();
  53   }
  54 }
  55 
  56 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
  57   EventGCReferenceStatistics e;
  58   if (e.should_commit()) {
  59       e.set_gcId(_shared_gc_info.gc_id().id());
  60       e.set_type((u1)type);
  61       e.set_count(count);
  62       e.commit();
  63   }


  71     e.set_when(when);
  72     e.set_metadataType(mdtype);
  73 
  74     e.set_specializedChunks(summary.num_specialized_chunks());
  75     e.set_specializedChunksTotalSize(summary.specialized_chunks_size_in_bytes());
  76 
  77     e.set_smallChunks(summary.num_small_chunks());
  78     e.set_smallChunksTotalSize(summary.small_chunks_size_in_bytes());
  79 
  80     e.set_mediumChunks(summary.num_medium_chunks());
  81     e.set_mediumChunksTotalSize(summary.medium_chunks_size_in_bytes());
  82 
  83     e.set_humongousChunks(summary.num_humongous_chunks());
  84     e.set_humongousChunksTotalSize(summary.humongous_chunks_size_in_bytes());
  85 
  86     e.commit();
  87   }
  88 }
  89 
  90 void ParallelOldTracer::send_parallel_old_event() const {
  91   EventParallelOldGarbageCollection e(UNTIMED);
  92   if (e.should_commit()) {
  93     e.set_gcId(_shared_gc_info.gc_id().id());
  94     e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
  95     e.set_starttime(_shared_gc_info.start_timestamp());
  96     e.set_endtime(_shared_gc_info.end_timestamp());
  97     e.commit();
  98   }
  99 }
 100 
 101 void YoungGCTracer::send_young_gc_event() const {
 102   EventYoungGarbageCollection e(UNTIMED);
 103   if (e.should_commit()) {
 104     e.set_gcId(_shared_gc_info.gc_id().id());
 105     e.set_tenuringThreshold(_tenuring_threshold);
 106     e.set_starttime(_shared_gc_info.start_timestamp());
 107     e.set_endtime(_shared_gc_info.end_timestamp());
 108     e.commit();
 109   }
 110 }
 111 
 112 bool YoungGCTracer::should_send_promotion_in_new_plab_event() const {
 113   return EventPromoteObjectInNewPLAB::is_enabled();
 114 }
 115 
 116 bool YoungGCTracer::should_send_promotion_outside_plab_event() const {
 117   return EventPromoteObjectOutsidePLAB::is_enabled();
 118 }
 119 
 120 void YoungGCTracer::send_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
 121                                                      uint age, bool tenured,
 122                                                      size_t plab_size) const {
 123 
 124   EventPromoteObjectInNewPLAB event;
 125   if (event.should_commit()) {
 126     event.set_gcId(_shared_gc_info.gc_id().id());
 127     event.set_objectClass(klass);
 128     event.set_objectSize(obj_size);
 129     event.set_tenured(tenured);
 130     event.set_tenuringAge(age);
 131     event.set_plabSize(plab_size);
 132     event.commit();
 133   }
 134 }
 135 
 136 void YoungGCTracer::send_promotion_outside_plab_event(Klass* klass, size_t obj_size,
 137                                                       uint age, bool tenured) const {
 138 
 139   EventPromoteObjectOutsidePLAB event;
 140   if (event.should_commit()) {
 141     event.set_gcId(_shared_gc_info.gc_id().id());
 142     event.set_objectClass(klass);
 143     event.set_objectSize(obj_size);
 144     event.set_tenured(tenured);
 145     event.set_tenuringAge(age);
 146     event.commit();
 147   }
 148 }
 149 
 150 void OldGCTracer::send_old_gc_event() const {
 151   EventOldGarbageCollection e(UNTIMED);
 152   if (e.should_commit()) {
 153     e.set_gcId(_shared_gc_info.gc_id().id());
 154     e.set_starttime(_shared_gc_info.start_timestamp());
 155     e.set_endtime(_shared_gc_info.end_timestamp());
 156     e.commit();
 157   }
 158 }
 159 
 160 static JfrStructCopyFailed to_struct(const CopyFailedInfo& cf_info) {
 161   JfrStructCopyFailed failed_info;
 162   failed_info.set_objectCount(cf_info.failed_count());
 163   failed_info.set_firstSize(cf_info.first_size());
 164   failed_info.set_smallestSize(cf_info.smallest_size());
 165   failed_info.set_totalSize(cf_info.total_size());
 166   return failed_info;
 167 }
 168 
 169 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
 170   EventPromotionFailed e;
 171   if (e.should_commit()) {
 172     e.set_gcId(_shared_gc_info.gc_id().id());
 173     e.set_promotionFailed(to_struct(pf_info));
 174     e.set_thread(pf_info.thread()->thread_id());
 175     e.commit();
 176   }
 177 }
 178 
 179 // Common to CMS and G1
 180 void OldGCTracer::send_concurrent_mode_failure_event() {
 181   EventConcurrentModeFailure e;
 182   if (e.should_commit()) {
 183     e.set_gcId(_shared_gc_info.gc_id().id());
 184     e.commit();
 185   }
 186 }
 187 
 188 #if INCLUDE_ALL_GCS
 189 void G1NewTracer::send_g1_young_gc_event() {
 190   EventG1GarbageCollection e(UNTIMED);
 191   if (e.should_commit()) {
 192     e.set_gcId(_shared_gc_info.gc_id().id());
 193     e.set_type(_g1_young_gc_info.type());
 194     e.set_starttime(_shared_gc_info.start_timestamp());
 195     e.set_endtime(_shared_gc_info.end_timestamp());
 196     e.commit();
 197   }
 198 }
 199 
 200 void G1MMUTracer::send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms) {
 201   EventG1MMU e;
 202   if (e.should_commit()) {
 203     e.set_gcId(GCId::peek().id());
 204     e.set_timeSlice((s8)time_slice_ms);
 205     e.set_gcTime((s8)gc_time_ms);
 206     e.set_pauseTarget((s8)max_time_ms);
 207     e.commit();
 208   }
 209 }
 210 
 211 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
 212   EventEvacuationInformation e;
 213   if (e.should_commit()) {
 214     e.set_gcId(_shared_gc_info.gc_id().id());
 215     e.set_cSetRegions(info->collectionset_regions());
 216     e.set_cSetUsedBefore(info->collectionset_used_before());
 217     e.set_cSetUsedAfter(info->collectionset_used_after());
 218     e.set_allocationRegions(info->allocation_regions());
 219     e.set_allocationRegionsUsedBefore(info->alloc_regions_used_before());
 220     e.set_allocationRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
 221     e.set_bytesCopied(info->bytes_copied());
 222     e.set_regionsFreed(info->regions_freed());
 223     e.commit();
 224   }
 225 }
 226 
 227 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
 228   EventEvacuationFailed e;
 229   if (e.should_commit()) {
 230     e.set_gcId(_shared_gc_info.gc_id().id());
 231     e.set_evacuationFailed(to_struct(ef_info));
 232     e.commit();
 233   }
 234 }

 235 
 236 #endif // INCLUDE_ALL_GCS
 237 
 238 static JfrStructVirtualSpace to_struct(const VirtualSpaceSummary& summary) {
 239   JfrStructVirtualSpace space;
 240   space.set_start((TraceAddress)summary.start());
 241   space.set_committedEnd((TraceAddress)summary.committed_end());
 242   space.set_committedSize(summary.committed_size());
 243   space.set_reservedEnd((TraceAddress)summary.reserved_end());
 244   space.set_reservedSize(summary.reserved_size());
 245   return space;
 246 }
 247 
 248 static JfrStructObjectSpace to_struct(const SpaceSummary& summary) {
 249   JfrStructObjectSpace space;
 250   space.set_start((TraceAddress)summary.start());
 251   space.set_end((TraceAddress)summary.end());
 252   space.set_used(summary.used());
 253   space.set_size(summary.size());
 254   return space;
 255 }
 256 
 257 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
 258   GCId _gc_id;
 259   GCWhen::Type _when;
 260  public:
 261   GCHeapSummaryEventSender(GCId gc_id, GCWhen::Type when) : _gc_id(gc_id), _when(when) {}
 262 
 263   void visit(const GCHeapSummary* heap_summary) const {
 264     const VirtualSpaceSummary& heap_space = heap_summary->heap();
 265 
 266     EventGCHeapSummary e;
 267     if (e.should_commit()) {
 268       e.set_gcId(_gc_id.id());
 269       e.set_when((u1)_when);
 270       e.set_heapSpace(to_struct(heap_space));
 271       e.set_heapUsed(heap_summary->used());
 272       e.commit();
 273     }
 274   }
 275 
 276   void visit(const G1HeapSummary* g1_heap_summary) const {
 277     visit((GCHeapSummary*)g1_heap_summary);
 278 
 279     EventG1HeapSummary e;
 280     if (e.should_commit()) {
 281       e.set_gcId(_gc_id.id());
 282       e.set_when((u1)_when);
 283       e.set_edenUsedSize(g1_heap_summary->edenUsed());
 284       e.set_edenTotalSize(g1_heap_summary->edenCapacity());
 285       e.set_survivorUsedSize(g1_heap_summary->survivorUsed());
 286       e.set_numberOfRegions(g1_heap_summary->numberOfRegions());
 287       e.commit();
 288     }
 289   }
 290 
 291   void visit(const PSHeapSummary* ps_heap_summary) const {
 292     visit((GCHeapSummary*)ps_heap_summary);
 293 
 294     const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
 295     const SpaceSummary& old_space = ps_heap_summary->old_space();
 296     const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
 297     const SpaceSummary& eden_space = ps_heap_summary->eden();
 298     const SpaceSummary& from_space = ps_heap_summary->from();
 299     const SpaceSummary& to_space = ps_heap_summary->to();
 300 
 301     EventPSHeapSummary e;
 302     if (e.should_commit()) {
 303       e.set_gcId(_gc_id.id());
 304       e.set_when((u1)_when);
 305 
 306       e.set_oldSpace(to_struct(ps_heap_summary->old()));
 307       e.set_oldObjectSpace(to_struct(ps_heap_summary->old_space()));
 308       e.set_youngSpace(to_struct(ps_heap_summary->young()));
 309       e.set_edenSpace(to_struct(ps_heap_summary->eden()));
 310       e.set_fromSpace(to_struct(ps_heap_summary->from()));
 311       e.set_toSpace(to_struct(ps_heap_summary->to()));
 312       e.commit();
 313     }
 314   }
 315 };
 316 
 317 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
 318   GCHeapSummaryEventSender visitor(_shared_gc_info.gc_id(), when);
 319   heap_summary.accept(&visitor);
 320 }
 321 
 322 static JfrStructMetaspaceSizes to_struct(const MetaspaceSizes& sizes) {
 323   JfrStructMetaspaceSizes meta_sizes;
 324 
 325   meta_sizes.set_committed(sizes.committed());
 326   meta_sizes.set_used(sizes.used());
 327   meta_sizes.set_reserved(sizes.reserved());
 328 
 329   return meta_sizes;
 330 }
 331 
 332 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
 333   EventMetaspaceSummary e;
 334   if (e.should_commit()) {
 335     e.set_gcId(_shared_gc_info.gc_id().id());
 336     e.set_when((u1) when);
 337     e.set_gcThreshold(meta_space_summary.capacity_until_GC());
 338     e.set_metaspace(to_struct(meta_space_summary.meta_space()));
 339     e.set_dataSpace(to_struct(meta_space_summary.data_space()));
 340     e.set_classSpace(to_struct(meta_space_summary.class_space()));
 341     e.commit();
 342   }
 343 }
 344 
 345 class PhaseSender : public PhaseVisitor {
 346   GCId _gc_id;
 347  public:
 348   PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
 349 
 350    template<typename T>
 351   void send_phase(GCPhase* phase) {
 352     T event(UNTIMED);
 353     if (event.should_commit()) {
 354       event.set_gcId(_gc_id.id());
 355       event.set_name(phase->name());
 356       event.set_starttime(phase->start());
 357       event.set_endtime(phase->end());
 358       event.commit();
 359     }
 360   }
 361 
 362   void visit(GCPhase* pause) { ShouldNotReachHere(); }
 363   void visit(ConcurrentPhase* pause) { Unimplemented(); }
 364   void visit(PausePhase* pause) {
 365     assert(PhasesStack::PHASE_LEVELS == 5, "Need more event types");
 366 
 367     switch (pause->level()) {
 368       case 0: send_phase<EventGCPhasePause>(pause); break;
 369       case 1: send_phase<EventGCPhasePauseLevel1>(pause); break;
 370       case 2: send_phase<EventGCPhasePauseLevel2>(pause); break;
 371       case 3: send_phase<EventGCPhasePauseLevel3>(pause); break;
 372       default: /* Ignore sending this phase */ break;
 373     }
 374   }
 375 };
 376 
 377 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
< prev index next >