Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/shared/gcTrace.cpp @ 20460:df66e3a3c4c2
8041946: CMM Testing: 8u40 an allocated humongous object at the end of the heap should not prevents shrinking the heap
Summary: New test added
Reviewed-by: jwilhelm, tschatzl
Contributed-by: andrey.x.zakharov@oracle.com
author | jwilhelm |
---|---|
date | Thu, 11 Sep 2014 14:21:13 +0200 |
parents | 0982ec23da03 |
children |
rev | line source |
---|---|
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" | |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
26 #include "gc_implementation/shared/copyFailedInfo.hpp" |
10405 | 27 #include "gc_implementation/shared/gcHeapSummary.hpp" |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
28 #include "gc_implementation/shared/gcId.hpp" |
10405 | 29 #include "gc_implementation/shared/gcTimer.hpp" |
30 #include "gc_implementation/shared/gcTrace.hpp" | |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
31 #include "gc_implementation/shared/objectCountEventSender.hpp" |
10405 | 32 #include "memory/heapInspection.hpp" |
33 #include "memory/referenceProcessorStats.hpp" | |
11115
6aa440bc1125
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
11114
diff
changeset
|
34 #include "runtime/os.hpp" |
10405 | 35 #include "utilities/globalDefinitions.hpp" |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
36 #include "utilities/ticks.inline.hpp" |
10405 | 37 |
38 #if INCLUDE_ALL_GCS | |
39 #include "gc_implementation/g1/evacuationInfo.hpp" | |
40 #endif | |
41 | |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
42 #define assert_unset_gc_id() assert(_shared_gc_info.gc_id().is_undefined(), "GC already started?") |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
43 #define assert_set_gc_id() assert(!_shared_gc_info.gc_id().is_undefined(), "GC not started?") |
10405 | 44 |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
45 void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) { |
10405 | 46 assert_unset_gc_id(); |
47 | |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
48 GCId gc_id = GCId::create(); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
49 _shared_gc_info.set_gc_id(gc_id); |
10405 | 50 _shared_gc_info.set_cause(cause); |
51 _shared_gc_info.set_start_timestamp(timestamp); | |
52 } | |
53 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
54 void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) { |
10405 | 55 assert_unset_gc_id(); |
56 | |
57 report_gc_start_impl(cause, timestamp); | |
58 } | |
59 | |
60 bool GCTracer::has_reported_gc_start() const { | |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
61 return !_shared_gc_info.gc_id().is_undefined(); |
10405 | 62 } |
63 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
64 void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
10405 | 65 assert_set_gc_id(); |
66 | |
67 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses()); | |
68 _shared_gc_info.set_longest_pause(time_partitions->longest_pause()); | |
69 _shared_gc_info.set_end_timestamp(timestamp); | |
70 | |
71 send_phase_events(time_partitions); | |
72 send_garbage_collection_event(); | |
73 } | |
74 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
75 void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) { |
10405 | 76 assert_set_gc_id(); |
77 | |
78 report_gc_end_impl(timestamp, time_partitions); | |
79 | |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
80 _shared_gc_info.set_gc_id(GCId::undefined()); |
10405 | 81 } |
82 | |
83 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const { | |
84 assert_set_gc_id(); | |
85 | |
86 send_reference_stats_event(REF_SOFT, rps.soft_count()); | |
87 send_reference_stats_event(REF_WEAK, rps.weak_count()); | |
88 send_reference_stats_event(REF_FINAL, rps.final_count()); | |
89 send_reference_stats_event(REF_PHANTOM, rps.phantom_count()); | |
90 } | |
91 | |
92 #if INCLUDE_SERVICES | |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
93 class ObjectCountEventSenderClosure : public KlassInfoClosure { |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
94 const GCId _gc_id; |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
95 const double _size_threshold_percentage; |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
96 const size_t _total_size_in_words; |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
97 const Ticks _timestamp; |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
98 |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
99 public: |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
100 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, const Ticks& timestamp) : |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
101 _gc_id(gc_id), |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
102 _size_threshold_percentage(ObjectCountCutOffPercent / 100), |
11115
6aa440bc1125
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
11114
diff
changeset
|
103 _total_size_in_words(total_size_in_words), |
6aa440bc1125
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
11114
diff
changeset
|
104 _timestamp(timestamp) |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
105 {} |
10405 | 106 |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
107 virtual void do_cinfo(KlassInfoEntry* entry) { |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
108 if (should_send_event(entry)) { |
11115
6aa440bc1125
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
11114
diff
changeset
|
109 ObjectCountEventSender::send(entry, _gc_id, _timestamp); |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
110 } |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
111 } |
10405 | 112 |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
113 private: |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
114 bool should_send_event(const KlassInfoEntry* entry) const { |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
115 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words; |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
116 return percentage_of_heap >= _size_threshold_percentage; |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
117 } |
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
118 }; |
10405 | 119 |
120 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) { | |
121 assert_set_gc_id(); | |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
122 assert(is_alive_cl != NULL, "Must supply function to check liveness"); |
10405 | 123 |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
124 if (ObjectCountEventSender::should_send_event()) { |
10405 | 125 ResourceMark rm; |
126 | |
127 KlassInfoTable cit(false); | |
128 if (!cit.allocation_failed()) { | |
129 HeapInspection hi(false, false, false, NULL); | |
130 hi.populate_table(&cit, is_alive_cl); | |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
17771
diff
changeset
|
131 ObjectCountEventSenderClosure event_sender(_shared_gc_info.gc_id(), cit.size_of_instances_in_words(), Ticks::now()); |
10405 | 132 cit.iterate(&event_sender); |
133 } | |
134 } | |
135 } | |
11113
2cbc8f3011a0
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
10405
diff
changeset
|
136 #endif // INCLUDE_SERVICES |
10405 | 137 |
17771
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
138 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const { |
10405 | 139 assert_set_gc_id(); |
140 | |
141 send_gc_heap_summary_event(when, heap_summary); | |
17771
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
142 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
143 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
144 void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
145 assert_set_gc_id(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
146 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
147 send_meta_space_summary_event(when, summary); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
148 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
149 send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary()); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
150 if (UseCompressedClassPointers) { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
151 send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary()); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
13400
diff
changeset
|
152 } |
10405 | 153 } |
154 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
155 void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
10405 | 156 assert_set_gc_id(); |
157 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported"); | |
158 | |
159 GCTracer::report_gc_end_impl(timestamp, time_partitions); | |
160 send_young_gc_event(); | |
161 | |
162 _tenuring_threshold = UNSET_TENURING_THRESHOLD; | |
163 } | |
164 | |
165 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) { | |
166 assert_set_gc_id(); | |
167 | |
168 send_promotion_failed_event(pf_info); | |
169 } | |
170 | |
171 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) { | |
172 _tenuring_threshold = tenuring_threshold; | |
173 } | |
174 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
175 void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
10405 | 176 assert_set_gc_id(); |
177 | |
178 GCTracer::report_gc_end_impl(timestamp, time_partitions); | |
179 send_old_gc_event(); | |
180 } | |
181 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
182 void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
10405 | 183 assert_set_gc_id(); |
184 | |
185 OldGCTracer::report_gc_end_impl(timestamp, time_partitions); | |
186 send_parallel_old_event(); | |
187 } | |
188 | |
189 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) { | |
190 assert_set_gc_id(); | |
191 | |
192 _parallel_old_gc_info.report_dense_prefix(dense_prefix); | |
193 } | |
194 | |
195 void OldGCTracer::report_concurrent_mode_failure() { | |
196 assert_set_gc_id(); | |
197 | |
198 send_concurrent_mode_failure_event(); | |
199 } | |
200 | |
201 #if INCLUDE_ALL_GCS | |
202 void G1NewTracer::report_yc_type(G1YCType type) { | |
203 assert_set_gc_id(); | |
204 | |
205 _g1_young_gc_info.set_type(type); | |
206 } | |
207 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
11115
diff
changeset
|
208 void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
10405 | 209 assert_set_gc_id(); |
210 | |
211 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions); | |
212 send_g1_young_gc_event(); | |
213 } | |
214 | |
215 void G1NewTracer::report_evacuation_info(EvacuationInfo* info) { | |
216 assert_set_gc_id(); | |
217 | |
218 send_evacuation_info_event(info); | |
219 } | |
220 | |
221 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) { | |
222 assert_set_gc_id(); | |
223 | |
224 send_evacuation_failed_event(ef_info); | |
225 ef_info.reset(); | |
226 } | |
227 #endif |