|
1 /* |
|
2 * Copyright (c) 2012, 2013, 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/copyFailedInfo.hpp" |
|
32 #include "memory/allocation.hpp" |
|
33 #include "memory/klassInfoClosure.hpp" |
|
34 #include "memory/referenceType.hpp" |
|
35 #if INCLUDE_ALL_GCS |
|
36 #include "gc_implementation/g1/g1YCTypes.hpp" |
|
37 #endif |
|
38 #include "utilities/macros.hpp" |
|
39 |
|
40 typedef uint GCId; |
|
41 |
|
42 class EvacuationInfo; |
|
43 class GCHeapSummary; |
|
44 class MetaspaceSummary; |
|
45 class PSHeapSummary; |
|
46 class ReferenceProcessorStats; |
|
47 class TimePartitions; |
|
48 class BoolObjectClosure; |
|
49 |
|
50 class SharedGCInfo VALUE_OBJ_CLASS_SPEC { |
|
51 static const jlong UNSET_TIMESTAMP = -1; |
|
52 |
|
53 public: |
|
54 static const GCId UNSET_GCID = (GCId)-1; |
|
55 |
|
56 private: |
|
57 GCId _id; |
|
58 GCName _name; |
|
59 GCCause::Cause _cause; |
|
60 jlong _start_timestamp; |
|
61 jlong _end_timestamp; |
|
62 jlong _sum_of_pauses; |
|
63 jlong _longest_pause; |
|
64 |
|
65 public: |
|
66 SharedGCInfo(GCName name) : _id(UNSET_GCID), _name(name), _cause(GCCause::_last_gc_cause), |
|
67 _start_timestamp(UNSET_TIMESTAMP), _end_timestamp(UNSET_TIMESTAMP), _sum_of_pauses(0), _longest_pause(0) {} |
|
68 |
|
69 void set_id(GCId id) { _id = id; } |
|
70 GCId id() const { return _id; } |
|
71 |
|
72 void set_start_timestamp(jlong timestamp) { _start_timestamp = timestamp; } |
|
73 jlong start_timestamp() const { return _start_timestamp; } |
|
74 |
|
75 void set_end_timestamp(jlong timestamp) { _end_timestamp = timestamp; } |
|
76 jlong 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(jlong duration) { _sum_of_pauses = duration; } |
|
85 jlong sum_of_pauses() const { return _sum_of_pauses; } |
|
86 |
|
87 void set_longest_pause(jlong duration) { _longest_pause = duration; } |
|
88 jlong 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 friend class ObjectCountEventSenderClosure; |
|
117 protected: |
|
118 SharedGCInfo _shared_gc_info; |
|
119 |
|
120 public: |
|
121 void report_gc_start(GCCause::Cause cause, jlong timestamp); |
|
122 void report_gc_end(jlong timestamp, TimePartitions* time_partitions); |
|
123 void report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_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 bool has_reported_gc_start() const; |
|
128 |
|
129 protected: |
|
130 GCTracer(GCName name) : _shared_gc_info(name) {} |
|
131 virtual void report_gc_start_impl(GCCause::Cause cause, jlong timestamp); |
|
132 virtual void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); |
|
133 |
|
134 private: |
|
135 void send_garbage_collection_event() const; |
|
136 void send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const; |
|
137 void send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const; |
|
138 void send_reference_stats_event(ReferenceType type, size_t count) const; |
|
139 void send_phase_events(TimePartitions* time_partitions) const; |
|
140 void send_object_count_after_gc_event(Klass* klass, jlong count, julong total_size) const NOT_SERVICES_RETURN; |
|
141 bool should_send_object_count_after_gc_event() const; |
|
142 }; |
|
143 |
|
144 class ObjectCountEventSenderClosure : public KlassInfoClosure { |
|
145 GCTracer* _gc_tracer; |
|
146 const double _size_threshold_percentage; |
|
147 const size_t _total_size_in_words; |
|
148 public: |
|
149 ObjectCountEventSenderClosure(GCTracer* gc_tracer, size_t total_size_in_words) : |
|
150 _gc_tracer(gc_tracer), |
|
151 _size_threshold_percentage(ObjectCountCutOffPercent / 100), |
|
152 _total_size_in_words(total_size_in_words) |
|
153 {} |
|
154 virtual void do_cinfo(KlassInfoEntry* entry); |
|
155 protected: |
|
156 virtual void send_event(KlassInfoEntry* entry); |
|
157 private: |
|
158 bool should_send_event(KlassInfoEntry* entry) const; |
|
159 }; |
|
160 |
|
161 class YoungGCTracer : public GCTracer { |
|
162 static const uint UNSET_TENURING_THRESHOLD = (uint) -1; |
|
163 |
|
164 uint _tenuring_threshold; |
|
165 |
|
166 protected: |
|
167 YoungGCTracer(GCName name) : GCTracer(name), _tenuring_threshold(UNSET_TENURING_THRESHOLD) {} |
|
168 virtual void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); |
|
169 |
|
170 public: |
|
171 void report_promotion_failed(const PromotionFailedInfo& pf_info); |
|
172 void report_tenuring_threshold(const uint tenuring_threshold); |
|
173 |
|
174 private: |
|
175 void send_young_gc_event() const; |
|
176 void send_promotion_failed_event(const PromotionFailedInfo& pf_info) const; |
|
177 }; |
|
178 |
|
179 class OldGCTracer : public GCTracer { |
|
180 protected: |
|
181 OldGCTracer(GCName name) : GCTracer(name) {} |
|
182 virtual void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); |
|
183 |
|
184 public: |
|
185 void report_concurrent_mode_failure(); |
|
186 |
|
187 private: |
|
188 void send_old_gc_event() const; |
|
189 void send_concurrent_mode_failure_event(); |
|
190 }; |
|
191 |
|
192 class ParallelOldTracer : public OldGCTracer { |
|
193 ParallelOldGCInfo _parallel_old_gc_info; |
|
194 |
|
195 public: |
|
196 ParallelOldTracer() : OldGCTracer(ParallelOld) {} |
|
197 void report_dense_prefix(void* dense_prefix); |
|
198 |
|
199 protected: |
|
200 void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); |
|
201 |
|
202 private: |
|
203 void send_parallel_old_event() const; |
|
204 }; |
|
205 |
|
206 class SerialOldTracer : public OldGCTracer { |
|
207 public: |
|
208 SerialOldTracer() : OldGCTracer(SerialOld) {} |
|
209 }; |
|
210 |
|
211 class ParallelScavengeTracer : public YoungGCTracer { |
|
212 public: |
|
213 ParallelScavengeTracer() : YoungGCTracer(ParallelScavenge) {} |
|
214 }; |
|
215 |
|
216 class DefNewTracer : public YoungGCTracer { |
|
217 public: |
|
218 DefNewTracer() : YoungGCTracer(DefNew) {} |
|
219 }; |
|
220 |
|
221 class ParNewTracer : public YoungGCTracer { |
|
222 public: |
|
223 ParNewTracer() : YoungGCTracer(ParNew) {} |
|
224 }; |
|
225 |
|
226 #if INCLUDE_ALL_GCS |
|
227 class G1NewTracer : public YoungGCTracer { |
|
228 G1YoungGCInfo _g1_young_gc_info; |
|
229 |
|
230 public: |
|
231 G1NewTracer() : YoungGCTracer(G1New) {} |
|
232 |
|
233 void report_yc_type(G1YCType type); |
|
234 void report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions); |
|
235 void report_evacuation_info(EvacuationInfo* info); |
|
236 void report_evacuation_failed(EvacuationFailedInfo& ef_info); |
|
237 |
|
238 private: |
|
239 void send_g1_young_gc_event(); |
|
240 void send_evacuation_info_event(EvacuationInfo* info); |
|
241 void send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const; |
|
242 }; |
|
243 #endif |
|
244 |
|
245 class CMSTracer : public OldGCTracer { |
|
246 public: |
|
247 CMSTracer() : OldGCTracer(ConcurrentMarkSweep) {} |
|
248 }; |
|
249 |
|
250 class G1OldTracer : public OldGCTracer { |
|
251 public: |
|
252 G1OldTracer() : OldGCTracer(G1Old) {} |
|
253 }; |
|
254 |
|
255 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACE_HPP |