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

Wed, 12 Jun 2013 15:21:41 +0200

author
ehelin
date
Wed, 12 Jun 2013 15:21:41 +0200
changeset 5388
6aa440bc1125
parent 5386
2cbc8f3011a0
child 5647
f175e3678be2
permissions
-rw-r--r--

8015683: object_count_after_gc should have the same timestamp for all events
Reviewed-by: mgerdin, stefank

sla@5237 1 /*
sla@5237 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
sla@5237 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sla@5237 4 *
sla@5237 5 * This code is free software; you can redistribute it and/or modify it
sla@5237 6 * under the terms of the GNU General Public License version 2 only, as
sla@5237 7 * published by the Free Software Foundation.
sla@5237 8 *
sla@5237 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sla@5237 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sla@5237 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sla@5237 12 * version 2 for more details (a copy is included in the LICENSE file that
sla@5237 13 * accompanied this code).
sla@5237 14 *
sla@5237 15 * You should have received a copy of the GNU General Public License version
sla@5237 16 * 2 along with this work; if not, write to the Free Software Foundation,
sla@5237 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sla@5237 18 *
sla@5237 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sla@5237 20 * or visit www.oracle.com if you need additional information or have any
sla@5237 21 * questions.
sla@5237 22 *
sla@5237 23 */
sla@5237 24
sla@5237 25 #include "precompiled.hpp"
sla@5237 26 #include "gc_implementation/shared/gcHeapSummary.hpp"
sla@5237 27 #include "gc_implementation/shared/gcTimer.hpp"
sla@5237 28 #include "gc_implementation/shared/gcTrace.hpp"
sla@5237 29 #include "gc_implementation/shared/gcWhen.hpp"
sla@5237 30 #include "gc_implementation/shared/copyFailedInfo.hpp"
sla@5237 31 #include "trace/tracing.hpp"
sla@5237 32 #include "trace/traceBackend.hpp"
sla@5237 33 #if INCLUDE_ALL_GCS
sla@5237 34 #include "gc_implementation/g1/evacuationInfo.hpp"
sla@5237 35 #include "gc_implementation/g1/g1YCTypes.hpp"
sla@5237 36 #endif
sla@5237 37
sla@5237 38 // All GC dependencies against the trace framework is contained within this file.
sla@5237 39
sla@5237 40 typedef uintptr_t TraceAddress;
sla@5237 41
sla@5237 42 void GCTracer::send_garbage_collection_event() const {
sla@5237 43 EventGCGarbageCollection event(UNTIMED);
sla@5237 44 if (event.should_commit()) {
sla@5237 45 event.set_gcId(_shared_gc_info.id());
sla@5237 46 event.set_name(_shared_gc_info.name());
sla@5237 47 event.set_cause((u2) _shared_gc_info.cause());
sla@5237 48 event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
sla@5237 49 event.set_longestPause(_shared_gc_info.longest_pause());
sla@5237 50 event.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 51 event.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 52 event.commit();
sla@5237 53 }
sla@5237 54 }
sla@5237 55
sla@5237 56 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
sla@5237 57 EventGCReferenceStatistics e;
sla@5237 58 if (e.should_commit()) {
sla@5237 59 e.set_gcId(_shared_gc_info.id());
sla@5237 60 e.set_type((u1)type);
sla@5237 61 e.set_count(count);
sla@5237 62 e.commit();
sla@5237 63 }
sla@5237 64 }
sla@5237 65
sla@5237 66 void ParallelOldTracer::send_parallel_old_event() const {
sla@5237 67 EventGCParallelOld e(UNTIMED);
sla@5237 68 if (e.should_commit()) {
sla@5237 69 e.set_gcId(_shared_gc_info.id());
sla@5237 70 e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
sla@5237 71 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 72 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 73 e.commit();
sla@5237 74 }
sla@5237 75 }
sla@5237 76
sla@5237 77 void YoungGCTracer::send_young_gc_event() const {
sla@5237 78 EventGCYoungGarbageCollection e(UNTIMED);
sla@5237 79 if (e.should_commit()) {
sla@5237 80 e.set_gcId(_shared_gc_info.id());
sla@5237 81 e.set_tenuringThreshold(_tenuring_threshold);
sla@5237 82 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 83 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 84 e.commit();
sla@5237 85 }
sla@5237 86 }
sla@5237 87
sla@5237 88 void OldGCTracer::send_old_gc_event() const {
sla@5237 89 EventGCOldGarbageCollection e(UNTIMED);
sla@5237 90 if (e.should_commit()) {
sla@5237 91 e.set_gcId(_shared_gc_info.id());
sla@5237 92 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 93 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 94 e.commit();
sla@5237 95 }
sla@5237 96 }
sla@5237 97
sla@5237 98 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
sla@5237 99 TraceStructCopyFailed failed_info;
sla@5237 100 failed_info.set_objectCount(cf_info.failed_count());
sla@5237 101 failed_info.set_firstSize(cf_info.first_size());
sla@5237 102 failed_info.set_smallestSize(cf_info.smallest_size());
sla@5237 103 failed_info.set_totalSize(cf_info.total_size());
sla@5237 104 return failed_info;
sla@5237 105 }
sla@5237 106
sla@5237 107 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
sla@5237 108 EventPromotionFailed e;
sla@5237 109 if (e.should_commit()) {
sla@5237 110 e.set_gcId(_shared_gc_info.id());
sla@5237 111 e.set_data(to_trace_struct(pf_info));
sla@5237 112 e.set_thread(pf_info.thread()->thread_id());
sla@5237 113 e.commit();
sla@5237 114 }
sla@5237 115 }
sla@5237 116
sla@5237 117 // Common to CMS and G1
sla@5237 118 void OldGCTracer::send_concurrent_mode_failure_event() {
sla@5237 119 EventConcurrentModeFailure e;
sla@5237 120 if (e.should_commit()) {
sla@5237 121 e.set_gcId(_shared_gc_info.id());
sla@5237 122 e.commit();
sla@5237 123 }
sla@5237 124 }
sla@5237 125
sla@5237 126 #if INCLUDE_ALL_GCS
sla@5237 127 void G1NewTracer::send_g1_young_gc_event() {
sla@5237 128 EventGCG1GarbageCollection e(UNTIMED);
sla@5237 129 if (e.should_commit()) {
sla@5237 130 e.set_gcId(_shared_gc_info.id());
sla@5237 131 e.set_type(_g1_young_gc_info.type());
sla@5237 132 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 133 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 134 e.commit();
sla@5237 135 }
sla@5237 136 }
sla@5237 137
sla@5237 138 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
sla@5237 139 EventEvacuationInfo e;
sla@5237 140 if (e.should_commit()) {
sla@5237 141 e.set_gcId(_shared_gc_info.id());
sla@5237 142 e.set_cSetRegions(info->collectionset_regions());
sla@5237 143 e.set_cSetUsedBefore(info->collectionset_used_before());
sla@5237 144 e.set_cSetUsedAfter(info->collectionset_used_after());
sla@5237 145 e.set_allocationRegions(info->allocation_regions());
sla@5237 146 e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
sla@5237 147 e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
sla@5237 148 e.set_bytesCopied(info->bytes_copied());
sla@5237 149 e.set_regionsFreed(info->regions_freed());
sla@5237 150 e.commit();
sla@5237 151 }
sla@5237 152 }
sla@5237 153
sla@5237 154 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
sla@5237 155 EventEvacuationFailed e;
sla@5237 156 if (e.should_commit()) {
sla@5237 157 e.set_gcId(_shared_gc_info.id());
sla@5237 158 e.set_data(to_trace_struct(ef_info));
sla@5237 159 e.commit();
sla@5237 160 }
sla@5237 161 }
sla@5237 162 #endif
sla@5237 163
sla@5237 164 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
sla@5237 165 TraceStructVirtualSpace space;
sla@5237 166 space.set_start((TraceAddress)summary.start());
sla@5237 167 space.set_committedEnd((TraceAddress)summary.committed_end());
sla@5237 168 space.set_committedSize(summary.committed_size());
sla@5237 169 space.set_reservedEnd((TraceAddress)summary.reserved_end());
sla@5237 170 space.set_reservedSize(summary.reserved_size());
sla@5237 171 return space;
sla@5237 172 }
sla@5237 173
sla@5237 174 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
sla@5237 175 TraceStructObjectSpace space;
sla@5237 176 space.set_start((TraceAddress)summary.start());
sla@5237 177 space.set_end((TraceAddress)summary.end());
sla@5237 178 space.set_used(summary.used());
sla@5237 179 space.set_size(summary.size());
sla@5237 180 return space;
sla@5237 181 }
sla@5237 182
sla@5237 183 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
sla@5237 184 GCId _id;
sla@5237 185 GCWhen::Type _when;
sla@5237 186 public:
sla@5237 187 GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {}
sla@5237 188
sla@5237 189 void visit(const GCHeapSummary* heap_summary) const {
sla@5237 190 const VirtualSpaceSummary& heap_space = heap_summary->heap();
sla@5237 191
sla@5237 192 EventGCHeapSummary e;
sla@5237 193 if (e.should_commit()) {
sla@5237 194 e.set_gcId(_id);
sla@5237 195 e.set_when((u1)_when);
sla@5237 196 e.set_heapSpace(to_trace_struct(heap_space));
sla@5237 197 e.set_heapUsed(heap_summary->used());
sla@5237 198 e.commit();
sla@5237 199 }
sla@5237 200 }
sla@5237 201
sla@5237 202 void visit(const PSHeapSummary* ps_heap_summary) const {
sla@5237 203 visit((GCHeapSummary*)ps_heap_summary);
sla@5237 204
sla@5237 205 const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
sla@5237 206 const SpaceSummary& old_space = ps_heap_summary->old_space();
sla@5237 207 const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
sla@5237 208 const SpaceSummary& eden_space = ps_heap_summary->eden();
sla@5237 209 const SpaceSummary& from_space = ps_heap_summary->from();
sla@5237 210 const SpaceSummary& to_space = ps_heap_summary->to();
sla@5237 211
sla@5237 212 EventPSHeapSummary e;
sla@5237 213 if (e.should_commit()) {
sla@5237 214 e.set_gcId(_id);
sla@5237 215 e.set_when((u1)_when);
sla@5237 216
sla@5237 217 e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
sla@5237 218 e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
sla@5237 219 e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
sla@5237 220 e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
sla@5237 221 e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
sla@5237 222 e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
sla@5237 223 e.commit();
sla@5237 224 }
sla@5237 225 }
sla@5237 226 };
sla@5237 227
sla@5237 228 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
sla@5237 229 GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when);
sla@5237 230 heap_summary.accept(&visitor);
sla@5237 231 }
sla@5237 232
sla@5237 233 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
sla@5237 234 TraceStructMetaspaceSizes meta_sizes;
sla@5237 235
sla@5237 236 meta_sizes.set_capacity(sizes.capacity());
sla@5237 237 meta_sizes.set_used(sizes.used());
sla@5237 238 meta_sizes.set_reserved(sizes.reserved());
sla@5237 239
sla@5237 240 return meta_sizes;
sla@5237 241 }
sla@5237 242
sla@5237 243 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
sla@5237 244 EventMetaspaceSummary e;
sla@5237 245 if (e.should_commit()) {
sla@5237 246 e.set_gcId(_shared_gc_info.id());
sla@5237 247 e.set_when((u1) when);
sla@5237 248 e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
sla@5237 249 e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
sla@5237 250 e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
sla@5237 251 e.commit();
sla@5237 252 }
sla@5237 253 }
sla@5237 254
sla@5237 255 class PhaseSender : public PhaseVisitor {
sla@5237 256 GCId _gc_id;
sla@5237 257 public:
sla@5237 258 PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
sla@5237 259
sla@5237 260 template<typename T>
sla@5237 261 void send_phase(PausePhase* pause) {
sla@5237 262 T event(UNTIMED);
sla@5237 263 if (event.should_commit()) {
sla@5237 264 event.set_gcId(_gc_id);
sla@5237 265 event.set_name(pause->name());
sla@5237 266 event.set_starttime(pause->start());
sla@5237 267 event.set_endtime(pause->end());
sla@5237 268 event.commit();
sla@5237 269 }
sla@5237 270 }
sla@5237 271
sla@5237 272 void visit(GCPhase* pause) { ShouldNotReachHere(); }
sla@5237 273 void visit(ConcurrentPhase* pause) { Unimplemented(); }
sla@5237 274 void visit(PausePhase* pause) {
sla@5237 275 assert(PhasesStack::PHASE_LEVELS == 5, "Need more event types");
sla@5237 276
sla@5237 277 switch (pause->level()) {
sla@5237 278 case 0: send_phase<EventGCPhasePause>(pause); break;
sla@5237 279 case 1: send_phase<EventGCPhasePauseLevel1>(pause); break;
sla@5237 280 case 2: send_phase<EventGCPhasePauseLevel2>(pause); break;
sla@5237 281 case 3: send_phase<EventGCPhasePauseLevel3>(pause); break;
sla@5237 282 default: /* Ignore sending this phase */ break;
sla@5237 283 }
sla@5237 284 }
sla@5237 285
sla@5237 286 #undef send_phase
sla@5237 287 };
sla@5237 288
sla@5237 289 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
sla@5237 290 PhaseSender phase_reporter(_shared_gc_info.id());
sla@5237 291
sla@5237 292 TimePartitionPhasesIterator iter(time_partitions);
sla@5237 293 while (iter.has_next()) {
sla@5237 294 GCPhase* phase = iter.next();
sla@5237 295 phase->accept(&phase_reporter);
sla@5237 296 }
sla@5237 297 }

mercurial