1 /* 2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 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 #ifndef SHARE_VM_GC_SHARED_GCTRACE_HPP 26 #define SHARE_VM_GC_SHARED_GCTRACE_HPP 27 28 #include "gc/shared/copyFailedInfo.hpp" 29 #include "gc/shared/gcCause.hpp" 30 #include "gc/shared/gcId.hpp" 31 #include "gc/shared/gcName.hpp" 32 #include "gc/shared/gcWhen.hpp" 33 #include "memory/allocation.hpp" 34 #include "memory/metaspace.hpp" 35 #include "memory/referenceType.hpp" 36 #include "utilities/macros.hpp" 37 #include "utilities/ticks.hpp" 38 #if INCLUDE_ALL_GCS 39 #include "gc/g1/g1YCTypes.hpp" 40 #endif 41 42 class EvacuationInfo; 43 class GCHeapSummary; 44 class MetaspaceChunkFreeListSummary; 45 class MetaspaceSummary; 46 class PSHeapSummary; 47 class G1HeapSummary; 48 class G1EvacSummary; 49 class ReferenceProcessorStats; 50 class TimePartitions; 51 class BoolObjectClosure; 52 53 class SharedGCInfo VALUE_OBJ_CLASS_SPEC { 54 private: 55 GCName _name; 56 GCCause::Cause _cause; 57 Ticks _start_timestamp; 58 Ticks _end_timestamp; 59 Tickspan _sum_of_pauses; 60 Tickspan _longest_pause; 61 62 public: 63 SharedGCInfo(GCName name) : 64 _name(name), 65 _cause(GCCause::_last_gc_cause), 66 _start_timestamp(), 67 _end_timestamp(), 68 _sum_of_pauses(), 69 _longest_pause() { 70 } 71 72 void set_start_timestamp(const Ticks& timestamp) { _start_timestamp = timestamp; } 73 const Ticks start_timestamp() const { return _start_timestamp; } 74 75 void set_end_timestamp(const Ticks& timestamp) { _end_timestamp = timestamp; } 76 const Ticks end_timestamp() const { return _end_timestamp; } 77 78 void set_name(GCName name) { _name = name; } 79 GCName name() const { return _name; } 80 81 void set_cause(GCCause::Cause cause) { _cause = cause; } 82 GCCause::Cause cause() const { return _cause; } 83 84 void set_sum_of_pauses(const Tickspan& duration) { _sum_of_pauses = duration; } 85 const Tickspan sum_of_pauses() const { return _sum_of_pauses; } 86 87 void set_longest_pause(const Tickspan& duration) { _longest_pause = duration; } 88 const Tickspan longest_pause() const { return _longest_pause; } 89 }; 90 91 class ParallelOldGCInfo VALUE_OBJ_CLASS_SPEC { 92 void* _dense_prefix; 93 public: 94 ParallelOldGCInfo() : _dense_prefix(NULL) {} 95 void report_dense_prefix(void* addr) { 96 _dense_prefix = addr; 97 } 98 void* dense_prefix() const { return _dense_prefix; } 99 }; 100 101 #if INCLUDE_ALL_GCS 102 103 class G1YoungGCInfo VALUE_OBJ_CLASS_SPEC { 104 G1YCType _type; 105 public: 106 G1YoungGCInfo() : _type(G1YCTypeEndSentinel) {} 107 void set_type(G1YCType type) { 108 _type = type; 109 } 110 G1YCType type() const { return _type; } 111 }; 112 113 #endif // INCLUDE_ALL_GCS 114 115 class GCTracer : public ResourceObj { 116 protected: 117 SharedGCInfo _shared_gc_info; 118 119 public: 120 void report_gc_start(GCCause::Cause cause, const Ticks& timestamp); 121 void report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions); 122 void report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const; 123 void report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& metaspace_summary) const; 124 void report_gc_reference_stats(const ReferenceProcessorStats& rp) const; 125 void report_object_count_after_gc(BoolObjectClosure* object_filter) NOT_SERVICES_RETURN; 126 127 protected: 128 GCTracer(GCName name) : _shared_gc_info(name) {} 129 void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp); 130 virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 131 132 private: 133 void send_garbage_collection_event() const; 134 void send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const; 135 void send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const; 136 void send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspace::MetadataType mdtype, const MetaspaceChunkFreeListSummary& summary) const; 137 void send_reference_stats_event(ReferenceType type, size_t count) const; 138 void send_phase_events(TimePartitions* time_partitions) const; 139 }; 140 141 class YoungGCTracer : public GCTracer { 142 static const uint UNSET_TENURING_THRESHOLD = (uint) -1; 143 144 uint _tenuring_threshold; 145 146 protected: 147 YoungGCTracer(GCName name) : GCTracer(name), _tenuring_threshold(UNSET_TENURING_THRESHOLD) {} 148 virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 149 150 public: 151 void report_promotion_failed(const PromotionFailedInfo& pf_info) const; 152 void report_tenuring_threshold(const uint tenuring_threshold); 153 154 /* 155 * Methods for reporting Promotion in new or outside PLAB Events. 156 * 157 * The object age is always required as it is not certain that the mark word 158 * of the oop can be trusted at this stage. 159 * 160 * obj_size is the size of the promoted object in bytes. 161 * 162 * tenured should be true if the object has been promoted to the old 163 * space during this GC, if the object is copied to survivor space 164 * from young space or survivor space (aging) tenured should be false. 165 * 166 * plab_size is the size of the newly allocated PLAB in bytes. 167 */ 168 bool should_report_promotion_events() const; 169 bool should_report_promotion_in_new_plab_event() const; 170 bool should_report_promotion_outside_plab_event() const; 171 void report_promotion_in_new_plab_event(Klass* klass, size_t obj_size, 172 uint age, bool tenured, 173 size_t plab_size) const; 174 void report_promotion_outside_plab_event(Klass* klass, size_t obj_size, 175 uint age, bool tenured) const; 176 177 private: 178 void send_young_gc_event() const; 179 void send_promotion_failed_event(const PromotionFailedInfo& pf_info) const; 180 bool should_send_promotion_in_new_plab_event() const; 181 bool should_send_promotion_outside_plab_event() const; 182 void send_promotion_in_new_plab_event(Klass* klass, size_t obj_size, 183 uint age, bool tenured, 184 size_t plab_size) const; 185 void send_promotion_outside_plab_event(Klass* klass, size_t obj_size, 186 uint age, bool tenured) const; 187 }; 188 189 class OldGCTracer : public GCTracer { 190 protected: 191 OldGCTracer(GCName name) : GCTracer(name) {} 192 virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 193 194 public: 195 void report_concurrent_mode_failure(); 196 197 private: 198 void send_old_gc_event() const; 199 void send_concurrent_mode_failure_event(); 200 }; 201 202 class ParallelOldTracer : public OldGCTracer { 203 ParallelOldGCInfo _parallel_old_gc_info; 204 205 public: 206 ParallelOldTracer() : OldGCTracer(ParallelOld) {} 207 void report_dense_prefix(void* dense_prefix); 208 209 protected: 210 void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 211 212 private: 213 void send_parallel_old_event() const; 214 }; 215 216 class SerialOldTracer : public OldGCTracer { 217 public: 218 SerialOldTracer() : OldGCTracer(SerialOld) {} 219 }; 220 221 class ParallelScavengeTracer : public YoungGCTracer { 222 public: 223 ParallelScavengeTracer() : YoungGCTracer(ParallelScavenge) {} 224 }; 225 226 class DefNewTracer : public YoungGCTracer { 227 public: 228 DefNewTracer() : YoungGCTracer(DefNew) {} 229 }; 230 231 class ParNewTracer : public YoungGCTracer { 232 public: 233 ParNewTracer() : YoungGCTracer(ParNew) {} 234 }; 235 236 #if INCLUDE_ALL_GCS 237 class G1MMUTracer : public AllStatic { 238 static void send_g1_mmu_event(double timeSlice, double gcTime, double maxTime); 239 240 public: 241 static void report_mmu(double timeSlice, double gcTime, double maxTime); 242 }; 243 244 class G1NewTracer : public YoungGCTracer { 245 G1YoungGCInfo _g1_young_gc_info; 246 247 public: 248 G1NewTracer() : YoungGCTracer(G1New) {} 249 250 void report_yc_type(G1YCType type); 251 void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 252 void report_evacuation_info(EvacuationInfo* info); 253 void report_evacuation_failed(EvacuationFailedInfo& ef_info); 254 255 void report_evacuation_statistics(const G1EvacSummary& young_summary, const G1EvacSummary& old_summary) const; 256 private: 257 void send_g1_young_gc_event(); 258 void send_evacuation_info_event(EvacuationInfo* info); 259 void send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const; 260 261 void send_young_evacuation_statistics(const G1EvacSummary& summary) const; 262 void send_old_evacuation_statistics(const G1EvacSummary& summary) const; 263 }; 264 #endif 265 266 class CMSTracer : public OldGCTracer { 267 public: 268 CMSTracer() : OldGCTracer(ConcurrentMarkSweep) {} 269 }; 270 271 class G1OldTracer : public OldGCTracer { 272 public: 273 G1OldTracer() : OldGCTracer(G1Old) {} 274 }; 275 276 #endif // SHARE_VM_GC_SHARED_GCTRACE_HPP