10405
|
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 #include "precompiled.hpp"
|
|
26 #include "gc_implementation/shared/gcHeapSummary.hpp"
|
|
27 #include "gc_implementation/shared/gcTimer.hpp"
|
|
28 #include "gc_implementation/shared/gcTrace.hpp"
|
|
29 #include "gc_implementation/shared/copyFailedInfo.hpp"
|
|
30 #include "memory/heapInspection.hpp"
|
|
31 #include "memory/referenceProcessorStats.hpp"
|
|
32 #include "utilities/globalDefinitions.hpp"
|
|
33
|
|
34 #if INCLUDE_ALL_GCS
|
|
35 #include "gc_implementation/g1/evacuationInfo.hpp"
|
|
36 #endif
|
|
37
|
|
38 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
|
|
39 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
|
|
40
|
|
41 static jlong GCTracer_next_gc_id = 0;
|
|
42 static GCId create_new_gc_id() {
|
|
43 return GCTracer_next_gc_id++;
|
|
44 }
|
|
45
|
|
46 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {
|
|
47 assert_unset_gc_id();
|
|
48
|
|
49 GCId gc_id = create_new_gc_id();
|
|
50 _shared_gc_info.set_id(gc_id);
|
|
51 _shared_gc_info.set_cause(cause);
|
|
52 _shared_gc_info.set_start_timestamp(timestamp);
|
|
53 }
|
|
54
|
|
55 void GCTracer::report_gc_start(GCCause::Cause cause, jlong timestamp) {
|
|
56 assert_unset_gc_id();
|
|
57
|
|
58 report_gc_start_impl(cause, timestamp);
|
|
59 }
|
|
60
|
|
61 bool GCTracer::has_reported_gc_start() const {
|
|
62 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
|
|
63 }
|
|
64
|
|
65 void GCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
|
66 assert_set_gc_id();
|
|
67
|
|
68 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
|
|
69 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
|
|
70 _shared_gc_info.set_end_timestamp(timestamp);
|
|
71
|
|
72 send_phase_events(time_partitions);
|
|
73 send_garbage_collection_event();
|
|
74 }
|
|
75
|
|
76 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
|
|
77 assert_set_gc_id();
|
|
78
|
|
79 report_gc_end_impl(timestamp, time_partitions);
|
|
80
|
|
81 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
|
|
82 }
|
|
83
|
|
84 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
|
|
85 assert_set_gc_id();
|
|
86
|
|
87 send_reference_stats_event(REF_SOFT, rps.soft_count());
|
|
88 send_reference_stats_event(REF_WEAK, rps.weak_count());
|
|
89 send_reference_stats_event(REF_FINAL, rps.final_count());
|
|
90 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
|
|
91 }
|
|
92
|
|
93 #if INCLUDE_SERVICES
|
|
94 void ObjectCountEventSenderClosure::do_cinfo(KlassInfoEntry* entry) {
|
|
95 if (should_send_event(entry)) {
|
|
96 send_event(entry);
|
|
97 }
|
|
98 }
|
|
99
|
|
100 void ObjectCountEventSenderClosure::send_event(KlassInfoEntry* entry) {
|
|
101 _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
|
|
102 entry->words() * BytesPerWord);
|
|
103 }
|
|
104
|
|
105 bool ObjectCountEventSenderClosure::should_send_event(KlassInfoEntry* entry) const {
|
|
106 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
|
|
107 return percentage_of_heap > _size_threshold_percentage;
|
|
108 }
|
|
109
|
|
110 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
|
|
111 assert_set_gc_id();
|
|
112
|
|
113 if (should_send_object_count_after_gc_event()) {
|
|
114 ResourceMark rm;
|
|
115
|
|
116 KlassInfoTable cit(false);
|
|
117 if (!cit.allocation_failed()) {
|
|
118 HeapInspection hi(false, false, false, NULL);
|
|
119 hi.populate_table(&cit, is_alive_cl);
|
|
120
|
|
121 ObjectCountEventSenderClosure event_sender(this, cit.size_of_instances_in_words());
|
|
122 cit.iterate(&event_sender);
|
|
123 }
|
|
124 }
|
|
125 }
|
|
126 #endif
|
|
127
|
|
128 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_summary) const {
|
|
129 assert_set_gc_id();
|
|
130
|
|
131 send_gc_heap_summary_event(when, heap_summary);
|
|
132 send_meta_space_summary_event(when, meta_space_summary);
|
|
133 }
|
|
134
|
|
135 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
|
136 assert_set_gc_id();
|
|
137 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
|
|
138
|
|
139 GCTracer::report_gc_end_impl(timestamp, time_partitions);
|
|
140 send_young_gc_event();
|
|
141
|
|
142 _tenuring_threshold = UNSET_TENURING_THRESHOLD;
|
|
143 }
|
|
144
|
|
145 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
|
|
146 assert_set_gc_id();
|
|
147
|
|
148 send_promotion_failed_event(pf_info);
|
|
149 }
|
|
150
|
|
151 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
|
|
152 _tenuring_threshold = tenuring_threshold;
|
|
153 }
|
|
154
|
|
155 void OldGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
|
156 assert_set_gc_id();
|
|
157
|
|
158 GCTracer::report_gc_end_impl(timestamp, time_partitions);
|
|
159 send_old_gc_event();
|
|
160 }
|
|
161
|
|
162 void ParallelOldTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
|
163 assert_set_gc_id();
|
|
164
|
|
165 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
|
|
166 send_parallel_old_event();
|
|
167 }
|
|
168
|
|
169 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
|
|
170 assert_set_gc_id();
|
|
171
|
|
172 _parallel_old_gc_info.report_dense_prefix(dense_prefix);
|
|
173 }
|
|
174
|
|
175 void OldGCTracer::report_concurrent_mode_failure() {
|
|
176 assert_set_gc_id();
|
|
177
|
|
178 send_concurrent_mode_failure_event();
|
|
179 }
|
|
180
|
|
181 #if INCLUDE_ALL_GCS
|
|
182 void G1NewTracer::report_yc_type(G1YCType type) {
|
|
183 assert_set_gc_id();
|
|
184
|
|
185 _g1_young_gc_info.set_type(type);
|
|
186 }
|
|
187
|
|
188 void G1NewTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
|
189 assert_set_gc_id();
|
|
190
|
|
191 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
|
|
192 send_g1_young_gc_event();
|
|
193 }
|
|
194
|
|
195 void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {
|
|
196 assert_set_gc_id();
|
|
197
|
|
198 send_evacuation_info_event(info);
|
|
199 }
|
|
200
|
|
201 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {
|
|
202 assert_set_gc_id();
|
|
203
|
|
204 send_evacuation_failed_event(ef_info);
|
|
205 ef_info.reset();
|
|
206 }
|
|
207 #endif
|