1 /* 2 * Copyright (c) 2012, 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_IMPLEMENTATION_SHARED_GCTRACE_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACE_HPP 27 28 #include "gc_interface/gcCause.hpp" 29 #include "gc_interface/gcName.hpp" 30 #include "gc_implementation/shared/gcWhen.hpp" 31 #include "gc_implementation/shared/promotionFailedInfo.hpp" 32 #include "memory/allocation.hpp" 33 #include "memory/referenceType.hpp" 34 #ifndef SERIALGC 35 #include "gc_implementation/g1/g1YCTypes.hpp" 36 #endif 37 38 typedef uint GCId; 39 40 class GCHeapSummary; 41 class PermGenSummary; 42 class PSHeapSummary; 43 class ReferenceProcessorStats; 44 class TimePartitions; 45 46 class SharedGCInfo VALUE_OBJ_CLASS_SPEC { 47 static const jlong UNSET_TIMESTAMP = -1; 48 49 public: 50 static const GCId UNSET_GCID = (GCId)-1; 51 52 private: 53 GCId _id; 54 GCName _name; 55 GCCause::Cause _cause; 56 jlong _start_timestamp; 57 jlong _end_timestamp; 58 jlong _sum_of_pauses; 59 jlong _longest_pause; 60 61 public: 62 SharedGCInfo(GCName name) : _id(UNSET_GCID), _name(name), _cause(GCCause::_last_gc_cause), 63 _start_timestamp(UNSET_TIMESTAMP), _end_timestamp(UNSET_TIMESTAMP), _sum_of_pauses(0), _longest_pause(0) {} 64 65 void set_id(GCId id) { _id = id; } 66 GCId id() const { return _id; } 67 68 void set_start_timestamp(jlong timestamp) { _start_timestamp = timestamp; } 69 jlong start_timestamp() const { return _start_timestamp; } 70 71 void set_end_timestamp(jlong timestamp) { _end_timestamp = timestamp; } 72 jlong end_timestamp() const { return _end_timestamp; } 73 74 void set_name(GCName name) { _name = name; } 75 GCName name() const { return _name; } 76 77 void set_cause(GCCause::Cause cause) { _cause = cause; } 78 GCCause::Cause cause() const { return _cause; } 79 80 void set_sum_of_pauses(jlong duration) { _sum_of_pauses = duration; } 81 jlong sum_of_pauses() const { return _sum_of_pauses; } 82 83 void set_longest_pause(jlong duration) { _longest_pause = duration; } 84 jlong longest_pause() const { return _longest_pause; } 85 }; 86 87 class ParallelOldGCInfo VALUE_OBJ_CLASS_SPEC { 88 void* _dense_prefix; 89 public: 90 ParallelOldGCInfo() : _dense_prefix(NULL) {} 91 void report_dense_prefix(void* addr) { 92 _dense_prefix = addr; 93 } 94 void* dense_prefix() const { return _dense_prefix; } 95 }; 96 97 #ifndef SERIALGC 98 99 class G1YoungGCInfo VALUE_OBJ_CLASS_SPEC { 100 G1YCType _type; 101 public: 102 G1YoungGCInfo() : _type(G1YCTypeEndSentinel) {} 103 void set_type(G1YCType type) { 104 _type = type; 105 } 106 G1YCType type() const { return _type; } 107 }; 108 109 #endif // SERIALGC 110 111 class GCTracer : public ResourceObj { 112 protected: 113 SharedGCInfo _shared_gc_info; 114 115 public: 116 void report_gc_start(GCCause::Cause cause, jlong timestamp); 117 void report_gc_end(jlong timestamp, TimePartitions* time_partitions); 118 void report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const; 119 void report_gc_reference_stats(const ReferenceProcessorStats& rp) const; 120 121 bool has_reported_gc_start() const; 122 123 protected: 124 GCTracer(GCName name) : _shared_gc_info(name) {} 125 virtual void report_gc_start_impl(GCCause::Cause cause, jlong timestamp); 126 virtual void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); 127 128 private: 129 void send_garbage_collection_event() const; 130 void send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const; 131 void send_perm_gen_summary_event(GCWhen::Type when, const PermGenSummary& perm_gen_summary) const; 132 void send_reference_stats_event(ReferenceType type, size_t count) const; 133 void send_phase_events(TimePartitions* time_partitions) const; 134 }; 135 136 class YoungGCTracer : public GCTracer { 137 protected: 138 YoungGCTracer(GCName name) : GCTracer(name) {} 139 140 public: 141 virtual void report_promotion_failed(const PromotionFailedInfo& pf_info); 142 143 protected: 144 virtual void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); 145 146 private: 147 void send_young_gc_event() const; 148 void send_promotion_failed_event(const PromotionFailedInfo& pf_info) const; 149 }; 150 151 class OldGCTracer : public GCTracer { 152 protected: 153 OldGCTracer(GCName name) : GCTracer(name) {} 154 155 protected: 156 virtual void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); 157 158 private: 159 void send_old_gc_event() const; 160 }; 161 162 class ParallelOldTracer : public OldGCTracer { 163 ParallelOldGCInfo _parallel_old_gc_info; 164 165 public: 166 ParallelOldTracer() : OldGCTracer(ParallelOld) {} 167 void report_dense_prefix(void* dense_prefix); 168 169 protected: 170 void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); 171 172 private: 173 void send_parallel_old_event() const; 174 }; 175 176 class SerialOldTracer : public OldGCTracer { 177 public: 178 SerialOldTracer() : OldGCTracer(SerialOld) {} 179 }; 180 181 class ParallelScavengeTracer : public YoungGCTracer { 182 public: 183 ParallelScavengeTracer() : YoungGCTracer(ParallelScavenge) {} 184 }; 185 186 class DefNewTracer : public YoungGCTracer { 187 public: 188 DefNewTracer() : YoungGCTracer(DefNew) {} 189 }; 190 191 class ParNewTracer : public YoungGCTracer { 192 public: 193 ParNewTracer() : YoungGCTracer(ParNew) {} 194 }; 195 196 #ifndef SERIALGC 197 class G1NewTracer : public YoungGCTracer { 198 G1YoungGCInfo _g1_young_gc_info; 199 200 public: 201 G1NewTracer() : YoungGCTracer(G1New) {} 202 203 void report_yc_type(G1YCType type); 204 void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); 205 206 private: 207 void send_g1_young_gc_event(); 208 }; 209 #endif 210 211 class CMSTracer : public OldGCTracer { 212 public: 213 CMSTracer() : OldGCTracer(ConcurrentMarkSweep) {} 214 }; 215 216 class G1OldTracer : public OldGCTracer { 217 public: 218 G1OldTracer() : OldGCTracer(G1Old) {} 219 }; 220 221 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACE_HPP