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