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

Sat, 23 Nov 2013 12:25:13 +0100

author
mgronlun
date
Sat, 23 Nov 2013 12:25:13 +0100
changeset 6131
86e6d691f2e1
parent 5647
f175e3678be2
child 6416
537c8e21b118
permissions
-rw-r--r--

8028128: Add a type safe alternative for working with counter based data
Reviewed-by: dholmes, egahlin

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"
ehelin@5647 31 #include "runtime/os.hpp"
sla@5237 32 #include "trace/tracing.hpp"
sla@5237 33 #include "trace/traceBackend.hpp"
sla@5237 34 #if INCLUDE_ALL_GCS
sla@5237 35 #include "gc_implementation/g1/evacuationInfo.hpp"
sla@5237 36 #include "gc_implementation/g1/g1YCTypes.hpp"
sla@5237 37 #endif
sla@5237 38
sla@5237 39 // All GC dependencies against the trace framework is contained within this file.
sla@5237 40
sla@5237 41 typedef uintptr_t TraceAddress;
sla@5237 42
sla@5237 43 void GCTracer::send_garbage_collection_event() const {
sla@5237 44 EventGCGarbageCollection event(UNTIMED);
sla@5237 45 if (event.should_commit()) {
sla@5237 46 event.set_gcId(_shared_gc_info.id());
sla@5237 47 event.set_name(_shared_gc_info.name());
sla@5237 48 event.set_cause((u2) _shared_gc_info.cause());
sla@5237 49 event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
sla@5237 50 event.set_longestPause(_shared_gc_info.longest_pause());
sla@5237 51 event.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 52 event.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 53 event.commit();
sla@5237 54 }
sla@5237 55 }
sla@5237 56
sla@5237 57 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
mgronlun@6131 58 EventGCReferenceStatistics e;
sla@5237 59 if (e.should_commit()) {
sla@5237 60 e.set_gcId(_shared_gc_info.id());
sla@5237 61 e.set_type((u1)type);
sla@5237 62 e.set_count(count);
sla@5237 63 e.commit();
sla@5237 64 }
sla@5237 65 }
sla@5237 66
sla@5237 67 void ParallelOldTracer::send_parallel_old_event() const {
sla@5237 68 EventGCParallelOld e(UNTIMED);
sla@5237 69 if (e.should_commit()) {
sla@5237 70 e.set_gcId(_shared_gc_info.id());
sla@5237 71 e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
sla@5237 72 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 73 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 74 e.commit();
sla@5237 75 }
sla@5237 76 }
sla@5237 77
sla@5237 78 void YoungGCTracer::send_young_gc_event() const {
sla@5237 79 EventGCYoungGarbageCollection e(UNTIMED);
sla@5237 80 if (e.should_commit()) {
sla@5237 81 e.set_gcId(_shared_gc_info.id());
sla@5237 82 e.set_tenuringThreshold(_tenuring_threshold);
sla@5237 83 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 84 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 85 e.commit();
sla@5237 86 }
sla@5237 87 }
sla@5237 88
sla@5237 89 void OldGCTracer::send_old_gc_event() const {
sla@5237 90 EventGCOldGarbageCollection e(UNTIMED);
sla@5237 91 if (e.should_commit()) {
sla@5237 92 e.set_gcId(_shared_gc_info.id());
sla@5237 93 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 94 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 95 e.commit();
sla@5237 96 }
sla@5237 97 }
sla@5237 98
sla@5237 99 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
sla@5237 100 TraceStructCopyFailed failed_info;
sla@5237 101 failed_info.set_objectCount(cf_info.failed_count());
sla@5237 102 failed_info.set_firstSize(cf_info.first_size());
sla@5237 103 failed_info.set_smallestSize(cf_info.smallest_size());
sla@5237 104 failed_info.set_totalSize(cf_info.total_size());
sla@5237 105 return failed_info;
sla@5237 106 }
sla@5237 107
sla@5237 108 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
mgronlun@6131 109 EventPromotionFailed e;
sla@5237 110 if (e.should_commit()) {
sla@5237 111 e.set_gcId(_shared_gc_info.id());
sla@5237 112 e.set_data(to_trace_struct(pf_info));
sla@5237 113 e.set_thread(pf_info.thread()->thread_id());
sla@5237 114 e.commit();
sla@5237 115 }
sla@5237 116 }
sla@5237 117
sla@5237 118 // Common to CMS and G1
sla@5237 119 void OldGCTracer::send_concurrent_mode_failure_event() {
mgronlun@6131 120 EventConcurrentModeFailure e;
sla@5237 121 if (e.should_commit()) {
sla@5237 122 e.set_gcId(_shared_gc_info.id());
sla@5237 123 e.commit();
sla@5237 124 }
sla@5237 125 }
sla@5237 126
sla@5237 127 #if INCLUDE_ALL_GCS
sla@5237 128 void G1NewTracer::send_g1_young_gc_event() {
sla@5237 129 EventGCG1GarbageCollection e(UNTIMED);
sla@5237 130 if (e.should_commit()) {
sla@5237 131 e.set_gcId(_shared_gc_info.id());
sla@5237 132 e.set_type(_g1_young_gc_info.type());
sla@5237 133 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 134 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 135 e.commit();
sla@5237 136 }
sla@5237 137 }
sla@5237 138
sla@5237 139 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
mgronlun@6131 140 EventEvacuationInfo e;
sla@5237 141 if (e.should_commit()) {
sla@5237 142 e.set_gcId(_shared_gc_info.id());
sla@5237 143 e.set_cSetRegions(info->collectionset_regions());
sla@5237 144 e.set_cSetUsedBefore(info->collectionset_used_before());
sla@5237 145 e.set_cSetUsedAfter(info->collectionset_used_after());
sla@5237 146 e.set_allocationRegions(info->allocation_regions());
sla@5237 147 e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
sla@5237 148 e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
sla@5237 149 e.set_bytesCopied(info->bytes_copied());
sla@5237 150 e.set_regionsFreed(info->regions_freed());
sla@5237 151 e.commit();
sla@5237 152 }
sla@5237 153 }
sla@5237 154
sla@5237 155 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
mgronlun@6131 156 EventEvacuationFailed e;
sla@5237 157 if (e.should_commit()) {
sla@5237 158 e.set_gcId(_shared_gc_info.id());
sla@5237 159 e.set_data(to_trace_struct(ef_info));
sla@5237 160 e.commit();
sla@5237 161 }
sla@5237 162 }
sla@5237 163 #endif
sla@5237 164
sla@5237 165 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
sla@5237 166 TraceStructVirtualSpace space;
sla@5237 167 space.set_start((TraceAddress)summary.start());
sla@5237 168 space.set_committedEnd((TraceAddress)summary.committed_end());
sla@5237 169 space.set_committedSize(summary.committed_size());
sla@5237 170 space.set_reservedEnd((TraceAddress)summary.reserved_end());
sla@5237 171 space.set_reservedSize(summary.reserved_size());
sla@5237 172 return space;
sla@5237 173 }
sla@5237 174
sla@5237 175 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
sla@5237 176 TraceStructObjectSpace space;
sla@5237 177 space.set_start((TraceAddress)summary.start());
sla@5237 178 space.set_end((TraceAddress)summary.end());
sla@5237 179 space.set_used(summary.used());
sla@5237 180 space.set_size(summary.size());
sla@5237 181 return space;
sla@5237 182 }
sla@5237 183
sla@5237 184 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
sla@5237 185 GCId _id;
sla@5237 186 GCWhen::Type _when;
sla@5237 187 public:
sla@5237 188 GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {}
sla@5237 189
sla@5237 190 void visit(const GCHeapSummary* heap_summary) const {
sla@5237 191 const VirtualSpaceSummary& heap_space = heap_summary->heap();
sla@5237 192
mgronlun@6131 193 EventGCHeapSummary e;
sla@5237 194 if (e.should_commit()) {
sla@5237 195 e.set_gcId(_id);
sla@5237 196 e.set_when((u1)_when);
sla@5237 197 e.set_heapSpace(to_trace_struct(heap_space));
sla@5237 198 e.set_heapUsed(heap_summary->used());
sla@5237 199 e.commit();
sla@5237 200 }
sla@5237 201 }
sla@5237 202
sla@5237 203 void visit(const PSHeapSummary* ps_heap_summary) const {
sla@5237 204 visit((GCHeapSummary*)ps_heap_summary);
sla@5237 205
sla@5237 206 const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
sla@5237 207 const SpaceSummary& old_space = ps_heap_summary->old_space();
sla@5237 208 const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
sla@5237 209 const SpaceSummary& eden_space = ps_heap_summary->eden();
sla@5237 210 const SpaceSummary& from_space = ps_heap_summary->from();
sla@5237 211 const SpaceSummary& to_space = ps_heap_summary->to();
sla@5237 212
mgronlun@6131 213 EventPSHeapSummary e;
sla@5237 214 if (e.should_commit()) {
sla@5237 215 e.set_gcId(_id);
sla@5237 216 e.set_when((u1)_when);
sla@5237 217
sla@5237 218 e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
sla@5237 219 e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
sla@5237 220 e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
sla@5237 221 e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
sla@5237 222 e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
sla@5237 223 e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
sla@5237 224 e.commit();
sla@5237 225 }
sla@5237 226 }
sla@5237 227 };
sla@5237 228
sla@5237 229 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
sla@5237 230 GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when);
sla@5237 231 heap_summary.accept(&visitor);
sla@5237 232 }
sla@5237 233
sla@5237 234 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
sla@5237 235 TraceStructMetaspaceSizes meta_sizes;
sla@5237 236
sla@5237 237 meta_sizes.set_capacity(sizes.capacity());
sla@5237 238 meta_sizes.set_used(sizes.used());
sla@5237 239 meta_sizes.set_reserved(sizes.reserved());
sla@5237 240
sla@5237 241 return meta_sizes;
sla@5237 242 }
sla@5237 243
sla@5237 244 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
mgronlun@6131 245 EventMetaspaceSummary e;
sla@5237 246 if (e.should_commit()) {
sla@5237 247 e.set_gcId(_shared_gc_info.id());
sla@5237 248 e.set_when((u1) when);
sla@5237 249 e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
sla@5237 250 e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
sla@5237 251 e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
sla@5237 252 e.commit();
sla@5237 253 }
sla@5237 254 }
sla@5237 255
sla@5237 256 class PhaseSender : public PhaseVisitor {
sla@5237 257 GCId _gc_id;
sla@5237 258 public:
sla@5237 259 PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
sla@5237 260
sla@5237 261 template<typename T>
sla@5237 262 void send_phase(PausePhase* pause) {
sla@5237 263 T event(UNTIMED);
sla@5237 264 if (event.should_commit()) {
sla@5237 265 event.set_gcId(_gc_id);
sla@5237 266 event.set_name(pause->name());
sla@5237 267 event.set_starttime(pause->start());
sla@5237 268 event.set_endtime(pause->end());
sla@5237 269 event.commit();
sla@5237 270 }
sla@5237 271 }
sla@5237 272
sla@5237 273 void visit(GCPhase* pause) { ShouldNotReachHere(); }
sla@5237 274 void visit(ConcurrentPhase* pause) { Unimplemented(); }
sla@5237 275 void visit(PausePhase* pause) {
sla@5237 276 assert(PhasesStack::PHASE_LEVELS == 5, "Need more event types");
sla@5237 277
sla@5237 278 switch (pause->level()) {
sla@5237 279 case 0: send_phase<EventGCPhasePause>(pause); break;
sla@5237 280 case 1: send_phase<EventGCPhasePauseLevel1>(pause); break;
sla@5237 281 case 2: send_phase<EventGCPhasePauseLevel2>(pause); break;
sla@5237 282 case 3: send_phase<EventGCPhasePauseLevel3>(pause); break;
sla@5237 283 default: /* Ignore sending this phase */ break;
sla@5237 284 }
sla@5237 285 }
sla@5237 286 };
sla@5237 287
sla@5237 288 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
sla@5237 289 PhaseSender phase_reporter(_shared_gc_info.id());
sla@5237 290
sla@5237 291 TimePartitionPhasesIterator iter(time_partitions);
sla@5237 292 while (iter.has_next()) {
sla@5237 293 GCPhase* phase = iter.next();
sla@5237 294 phase->accept(&phase_reporter);
sla@5237 295 }
sla@5237 296 }

mercurial