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

Print this page




  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.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(UNTIMED);
  59   if (e.should_commit()) {
  60       e.set_gcId(_shared_gc_info.id());
  61       e.set_type((u1)type);
  62       e.set_count(count);
  63       e.set_endtime(os::elapsed_counter());
  64       e.commit();
  65   }
  66 }
  67 
  68 void ParallelOldTracer::send_parallel_old_event() const {
  69   EventGCParallelOld e(UNTIMED);
  70   if (e.should_commit()) {
  71     e.set_gcId(_shared_gc_info.id());
  72     e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
  73     e.set_starttime(_shared_gc_info.start_timestamp());
  74     e.set_endtime(_shared_gc_info.end_timestamp());
  75     e.commit();
  76   }
  77 }
  78 
  79 void YoungGCTracer::send_young_gc_event() const {
  80   EventGCYoungGarbageCollection e(UNTIMED);
  81   if (e.should_commit()) {
  82     e.set_gcId(_shared_gc_info.id());
  83     e.set_tenuringThreshold(_tenuring_threshold);


  90 void OldGCTracer::send_old_gc_event() const {
  91   EventGCOldGarbageCollection e(UNTIMED);
  92   if (e.should_commit()) {
  93     e.set_gcId(_shared_gc_info.id());
  94     e.set_starttime(_shared_gc_info.start_timestamp());
  95     e.set_endtime(_shared_gc_info.end_timestamp());
  96     e.commit();
  97   }
  98 }
  99 
 100 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
 101   TraceStructCopyFailed failed_info;
 102   failed_info.set_objectCount(cf_info.failed_count());
 103   failed_info.set_firstSize(cf_info.first_size());
 104   failed_info.set_smallestSize(cf_info.smallest_size());
 105   failed_info.set_totalSize(cf_info.total_size());
 106   return failed_info;
 107 }
 108 
 109 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
 110   EventPromotionFailed e(UNTIMED);
 111   if (e.should_commit()) {
 112     e.set_gcId(_shared_gc_info.id());
 113     e.set_data(to_trace_struct(pf_info));
 114     e.set_thread(pf_info.thread()->thread_id());
 115     e.set_endtime(os::elapsed_counter());
 116     e.commit();
 117   }
 118 }
 119 
 120 // Common to CMS and G1
 121 void OldGCTracer::send_concurrent_mode_failure_event() {
 122   EventConcurrentModeFailure e(UNTIMED);
 123   if (e.should_commit()) {
 124     e.set_gcId(_shared_gc_info.id());
 125     e.set_endtime(os::elapsed_counter());
 126     e.commit();
 127   }
 128 }
 129 
 130 #if INCLUDE_ALL_GCS
 131 void G1NewTracer::send_g1_young_gc_event() {
 132   EventGCG1GarbageCollection e(UNTIMED);
 133   if (e.should_commit()) {
 134     e.set_gcId(_shared_gc_info.id());
 135     e.set_type(_g1_young_gc_info.type());
 136     e.set_starttime(_shared_gc_info.start_timestamp());
 137     e.set_endtime(_shared_gc_info.end_timestamp());
 138     e.commit();
 139   }
 140 }
 141 
 142 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
 143   EventEvacuationInfo e(UNTIMED);
 144   if (e.should_commit()) {
 145     e.set_gcId(_shared_gc_info.id());
 146     e.set_cSetRegions(info->collectionset_regions());
 147     e.set_cSetUsedBefore(info->collectionset_used_before());
 148     e.set_cSetUsedAfter(info->collectionset_used_after());
 149     e.set_allocationRegions(info->allocation_regions());
 150     e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
 151     e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
 152     e.set_bytesCopied(info->bytes_copied());
 153     e.set_regionsFreed(info->regions_freed());
 154     e.set_endtime(os::elapsed_counter());
 155     e.commit();
 156   }
 157 }
 158 
 159 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
 160   EventEvacuationFailed e(UNTIMED);
 161   if (e.should_commit()) {
 162     e.set_gcId(_shared_gc_info.id());
 163     e.set_data(to_trace_struct(ef_info));
 164     e.set_endtime(os::elapsed_counter());
 165     e.commit();
 166   }
 167 }
 168 #endif
 169 
 170 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
 171   TraceStructVirtualSpace space;
 172   space.set_start((TraceAddress)summary.start());
 173   space.set_committedEnd((TraceAddress)summary.committed_end());
 174   space.set_committedSize(summary.committed_size());
 175   space.set_reservedEnd((TraceAddress)summary.reserved_end());
 176   space.set_reservedSize(summary.reserved_size());
 177   return space;
 178 }
 179 
 180 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
 181   TraceStructObjectSpace space;
 182   space.set_start((TraceAddress)summary.start());
 183   space.set_end((TraceAddress)summary.end());
 184   space.set_used(summary.used());
 185   space.set_size(summary.size());
 186   return space;
 187 }
 188 
 189 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
 190   GCId _id;
 191   GCWhen::Type _when;
 192  public:
 193   GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {}
 194 
 195   void visit(const GCHeapSummary* heap_summary) const {
 196     const VirtualSpaceSummary& heap_space = heap_summary->heap();
 197 
 198     EventGCHeapSummary e(UNTIMED);
 199     if (e.should_commit()) {
 200       e.set_gcId(_id);
 201       e.set_when((u1)_when);
 202       e.set_heapSpace(to_trace_struct(heap_space));
 203       e.set_heapUsed(heap_summary->used());
 204       e.set_endtime(os::elapsed_counter());
 205       e.commit();
 206     }
 207   }
 208 
 209   void visit(const PSHeapSummary* ps_heap_summary) const {
 210     visit((GCHeapSummary*)ps_heap_summary);
 211 
 212     const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
 213     const SpaceSummary& old_space = ps_heap_summary->old_space();
 214     const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
 215     const SpaceSummary& eden_space = ps_heap_summary->eden();
 216     const SpaceSummary& from_space = ps_heap_summary->from();
 217     const SpaceSummary& to_space = ps_heap_summary->to();
 218 
 219     EventPSHeapSummary e(UNTIMED);
 220     if (e.should_commit()) {
 221       e.set_gcId(_id);
 222       e.set_when((u1)_when);
 223 
 224       e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
 225       e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
 226       e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
 227       e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
 228       e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
 229       e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
 230       e.set_endtime(os::elapsed_counter());
 231       e.commit();
 232     }
 233   }
 234 };
 235 
 236 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
 237   GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when);
 238   heap_summary.accept(&visitor);
 239 }
 240 
 241 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
 242   TraceStructMetaspaceSizes meta_sizes;
 243 
 244   meta_sizes.set_capacity(sizes.capacity());
 245   meta_sizes.set_used(sizes.used());
 246   meta_sizes.set_reserved(sizes.reserved());
 247 
 248   return meta_sizes;
 249 }
 250 
 251 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
 252   EventMetaspaceSummary e(UNTIMED);
 253   if (e.should_commit()) {
 254     e.set_gcId(_shared_gc_info.id());
 255     e.set_when((u1) when);
 256     e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
 257     e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
 258     e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
 259     e.set_endtime(os::elapsed_counter());
 260     e.commit();
 261   }
 262 }
 263 
 264 class PhaseSender : public PhaseVisitor {
 265   GCId _gc_id;
 266  public:
 267   PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
 268 
 269   template<typename T>
 270   void send_phase(PausePhase* pause) {
 271     T event(UNTIMED);
 272     if (event.should_commit()) {
 273       event.set_gcId(_gc_id);
 274       event.set_name(pause->name());
 275       event.set_starttime(pause->start());
 276       event.set_endtime(pause->end());
 277       event.commit();
 278     }
 279   }




  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.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.id());
  61       e.set_type((u1)type);
  62       e.set_count(count);

  63       e.commit();
  64   }
  65 }
  66 
  67 void ParallelOldTracer::send_parallel_old_event() const {
  68   EventGCParallelOld e(UNTIMED);
  69   if (e.should_commit()) {
  70     e.set_gcId(_shared_gc_info.id());
  71     e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
  72     e.set_starttime(_shared_gc_info.start_timestamp());
  73     e.set_endtime(_shared_gc_info.end_timestamp());
  74     e.commit();
  75   }
  76 }
  77 
  78 void YoungGCTracer::send_young_gc_event() const {
  79   EventGCYoungGarbageCollection e(UNTIMED);
  80   if (e.should_commit()) {
  81     e.set_gcId(_shared_gc_info.id());
  82     e.set_tenuringThreshold(_tenuring_threshold);


  89 void OldGCTracer::send_old_gc_event() const {
  90   EventGCOldGarbageCollection e(UNTIMED);
  91   if (e.should_commit()) {
  92     e.set_gcId(_shared_gc_info.id());
  93     e.set_starttime(_shared_gc_info.start_timestamp());
  94     e.set_endtime(_shared_gc_info.end_timestamp());
  95     e.commit();
  96   }
  97 }
  98 
  99 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
 100   TraceStructCopyFailed failed_info;
 101   failed_info.set_objectCount(cf_info.failed_count());
 102   failed_info.set_firstSize(cf_info.first_size());
 103   failed_info.set_smallestSize(cf_info.smallest_size());
 104   failed_info.set_totalSize(cf_info.total_size());
 105   return failed_info;
 106 }
 107 
 108 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
 109   EventPromotionFailed e;
 110   if (e.should_commit()) {
 111     e.set_gcId(_shared_gc_info.id());
 112     e.set_data(to_trace_struct(pf_info));
 113     e.set_thread(pf_info.thread()->thread_id());

 114     e.commit();
 115   }
 116 }
 117 
 118 // Common to CMS and G1
 119 void OldGCTracer::send_concurrent_mode_failure_event() {
 120   EventConcurrentModeFailure e;
 121   if (e.should_commit()) {
 122     e.set_gcId(_shared_gc_info.id());

 123     e.commit();
 124   }
 125 }
 126 
 127 #if INCLUDE_ALL_GCS
 128 void G1NewTracer::send_g1_young_gc_event() {
 129   EventGCG1GarbageCollection e(UNTIMED);
 130   if (e.should_commit()) {
 131     e.set_gcId(_shared_gc_info.id());
 132     e.set_type(_g1_young_gc_info.type());
 133     e.set_starttime(_shared_gc_info.start_timestamp());
 134     e.set_endtime(_shared_gc_info.end_timestamp());
 135     e.commit();
 136   }
 137 }
 138 
 139 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
 140   EventEvacuationInfo e;
 141   if (e.should_commit()) {
 142     e.set_gcId(_shared_gc_info.id());
 143     e.set_cSetRegions(info->collectionset_regions());
 144     e.set_cSetUsedBefore(info->collectionset_used_before());
 145     e.set_cSetUsedAfter(info->collectionset_used_after());
 146     e.set_allocationRegions(info->allocation_regions());
 147     e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
 148     e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
 149     e.set_bytesCopied(info->bytes_copied());
 150     e.set_regionsFreed(info->regions_freed());

 151     e.commit();
 152   }
 153 }
 154 
 155 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
 156   EventEvacuationFailed e;
 157   if (e.should_commit()) {
 158     e.set_gcId(_shared_gc_info.id());
 159     e.set_data(to_trace_struct(ef_info));

 160     e.commit();
 161   }
 162 }
 163 #endif
 164 
 165 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
 166   TraceStructVirtualSpace space;
 167   space.set_start((TraceAddress)summary.start());
 168   space.set_committedEnd((TraceAddress)summary.committed_end());
 169   space.set_committedSize(summary.committed_size());
 170   space.set_reservedEnd((TraceAddress)summary.reserved_end());
 171   space.set_reservedSize(summary.reserved_size());
 172   return space;
 173 }
 174 
 175 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
 176   TraceStructObjectSpace space;
 177   space.set_start((TraceAddress)summary.start());
 178   space.set_end((TraceAddress)summary.end());
 179   space.set_used(summary.used());
 180   space.set_size(summary.size());
 181   return space;
 182 }
 183 
 184 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
 185   GCId _id;
 186   GCWhen::Type _when;
 187  public:
 188   GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {}
 189 
 190   void visit(const GCHeapSummary* heap_summary) const {
 191     const VirtualSpaceSummary& heap_space = heap_summary->heap();
 192 
 193     EventGCHeapSummary e;
 194     if (e.should_commit()) {
 195       e.set_gcId(_id);
 196       e.set_when((u1)_when);
 197       e.set_heapSpace(to_trace_struct(heap_space));
 198       e.set_heapUsed(heap_summary->used());

 199       e.commit();
 200     }
 201   }
 202 
 203   void visit(const PSHeapSummary* ps_heap_summary) const {
 204     visit((GCHeapSummary*)ps_heap_summary);
 205 
 206     const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
 207     const SpaceSummary& old_space = ps_heap_summary->old_space();
 208     const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
 209     const SpaceSummary& eden_space = ps_heap_summary->eden();
 210     const SpaceSummary& from_space = ps_heap_summary->from();
 211     const SpaceSummary& to_space = ps_heap_summary->to();
 212 
 213     EventPSHeapSummary e;
 214     if (e.should_commit()) {
 215       e.set_gcId(_id);
 216       e.set_when((u1)_when);
 217 
 218       e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
 219       e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
 220       e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
 221       e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
 222       e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
 223       e.set_toSpace(to_trace_struct(ps_heap_summary->to()));

 224       e.commit();
 225     }
 226   }
 227 };
 228 
 229 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
 230   GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when);
 231   heap_summary.accept(&visitor);
 232 }
 233 
 234 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
 235   TraceStructMetaspaceSizes meta_sizes;
 236 
 237   meta_sizes.set_capacity(sizes.capacity());
 238   meta_sizes.set_used(sizes.used());
 239   meta_sizes.set_reserved(sizes.reserved());
 240 
 241   return meta_sizes;
 242 }
 243 
 244 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
 245   EventMetaspaceSummary e;
 246   if (e.should_commit()) {
 247     e.set_gcId(_shared_gc_info.id());
 248     e.set_when((u1) when);
 249     e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
 250     e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
 251     e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));

 252     e.commit();
 253   }
 254 }
 255 
 256 class PhaseSender : public PhaseVisitor {
 257   GCId _gc_id;
 258  public:
 259   PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
 260 
 261   template<typename T>
 262   void send_phase(PausePhase* pause) {
 263     T event(UNTIMED);
 264     if (event.should_commit()) {
 265       event.set_gcId(_gc_id);
 266       event.set_name(pause->name());
 267       event.set_starttime(pause->start());
 268       event.set_endtime(pause->end());
 269       event.commit();
 270     }
 271   }