rev 60538 : imported patch jep387-all.patch
1 /*
2 * Copyright (c) 2012, 2020, 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/shared/copyFailedInfo.hpp"
27 #include "gc/shared/gcHeapSummary.hpp"
28 #include "gc/shared/gcId.hpp"
29 #include "gc/shared/gcTimer.hpp"
30 #include "gc/shared/gcTrace.hpp"
31 #include "gc/shared/objectCountEventSender.hpp"
32 #include "gc/shared/referenceProcessorStats.hpp"
33 #include "memory/metaspace.hpp"
34 #include "memory/heapInspection.hpp"
35 #include "memory/resourceArea.hpp"
36 #include "runtime/os.hpp"
37 #include "utilities/globalDefinitions.hpp"
38 #include "utilities/macros.hpp"
39 #include "utilities/ticks.hpp"
40
41 void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) {
42 _shared_gc_info.set_cause(cause);
43 _shared_gc_info.set_start_timestamp(timestamp);
44 }
45
46 void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) {
47 report_gc_start_impl(cause, timestamp);
48 }
49
50 void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
51 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
52 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
53 _shared_gc_info.set_end_timestamp(timestamp);
54
55 send_phase_events(time_partitions);
56 send_garbage_collection_event();
57 }
58
59 void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) {
60 report_gc_end_impl(timestamp, time_partitions);
61 }
62
63 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
64 send_reference_stats_event(REF_SOFT, rps.soft_count());
65 send_reference_stats_event(REF_WEAK, rps.weak_count());
66 send_reference_stats_event(REF_FINAL, rps.final_count());
67 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
68 }
69
70 #if INCLUDE_SERVICES
71 class ObjectCountEventSenderClosure : public KlassInfoClosure {
72 const double _size_threshold_percentage;
73 const size_t _total_size_in_words;
74 const Ticks _timestamp;
75
76 public:
77 ObjectCountEventSenderClosure(size_t total_size_in_words, const Ticks& timestamp) :
78 _size_threshold_percentage(ObjectCountCutOffPercent / 100),
79 _total_size_in_words(total_size_in_words),
80 _timestamp(timestamp)
81 {}
82
83 virtual void do_cinfo(KlassInfoEntry* entry) {
84 if (should_send_event(entry)) {
85 ObjectCountEventSender::send(entry, _timestamp);
86 }
87 }
88
89 private:
90 bool should_send_event(const KlassInfoEntry* entry) const {
91 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
92 return percentage_of_heap >= _size_threshold_percentage;
93 }
94 };
95
96 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
97 assert(is_alive_cl != NULL, "Must supply function to check liveness");
98
99 if (ObjectCountEventSender::should_send_event()) {
100 ResourceMark rm;
101
102 KlassInfoTable cit(false);
103 if (!cit.allocation_failed()) {
104 HeapInspection hi;
105 hi.populate_table(&cit, is_alive_cl);
106 ObjectCountEventSenderClosure event_sender(cit.size_of_instances_in_words(), Ticks::now());
107 cit.iterate(&event_sender);
108 }
109 }
110 }
111 #endif // INCLUDE_SERVICES
112
113 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
114 send_gc_heap_summary_event(when, heap_summary);
115 }
116
117 void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const {
118 send_meta_space_summary_event(when, summary);
119
120 send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary());
121 if (UseCompressedClassPointers) {
122 send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary());
123 }
124 }
125
126 void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
127 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
128
129 GCTracer::report_gc_end_impl(timestamp, time_partitions);
130 send_young_gc_event();
131
132 _tenuring_threshold = UNSET_TENURING_THRESHOLD;
133 }
134
135 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) const {
136 send_promotion_failed_event(pf_info);
137 }
138
139 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
140 _tenuring_threshold = tenuring_threshold;
141 }
142
143 bool YoungGCTracer::should_report_promotion_events() const {
144 return should_report_promotion_in_new_plab_event() ||
145 should_report_promotion_outside_plab_event();
146 }
147
148 bool YoungGCTracer::should_report_promotion_in_new_plab_event() const {
149 return should_send_promotion_in_new_plab_event();
150 }
151
152 bool YoungGCTracer::should_report_promotion_outside_plab_event() const {
153 return should_send_promotion_outside_plab_event();
154 }
155
156 void YoungGCTracer::report_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
157 uint age, bool tenured,
158 size_t plab_size) const {
159 send_promotion_in_new_plab_event(klass, obj_size, age, tenured, plab_size);
160 }
161
162 void YoungGCTracer::report_promotion_outside_plab_event(Klass* klass, size_t obj_size,
163 uint age, bool tenured) const {
164 send_promotion_outside_plab_event(klass, obj_size, age, tenured);
165 }
166
167 void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
168 GCTracer::report_gc_end_impl(timestamp, time_partitions);
169 send_old_gc_event();
170 }
171
172 void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
173 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
174 send_parallel_old_event();
175 }
176
177 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
178 _parallel_old_gc_info.report_dense_prefix(dense_prefix);
179 }
180
181 void OldGCTracer::report_concurrent_mode_failure() {
182 send_concurrent_mode_failure_event();
183 }
--- EOF ---