src/share/vm/gc_implementation/shared/gcTrace.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6420
9fdaa79b0c27
parent 0
f90c822e73f8
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "gc_implementation/shared/copyFailedInfo.hpp"
aoqi@0 27 #include "gc_implementation/shared/gcHeapSummary.hpp"
aoqi@0 28 #include "gc_implementation/shared/gcTimer.hpp"
aoqi@0 29 #include "gc_implementation/shared/gcTrace.hpp"
aoqi@0 30 #include "gc_implementation/shared/objectCountEventSender.hpp"
aoqi@0 31 #include "memory/heapInspection.hpp"
aoqi@0 32 #include "memory/referenceProcessorStats.hpp"
aoqi@0 33 #include "runtime/os.hpp"
aoqi@0 34 #include "utilities/globalDefinitions.hpp"
aoqi@0 35 #include "utilities/ticks.inline.hpp"
aoqi@0 36
aoqi@0 37 #if INCLUDE_ALL_GCS
aoqi@0 38 #include "gc_implementation/g1/evacuationInfo.hpp"
aoqi@0 39 #endif
aoqi@0 40
aoqi@0 41 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
aoqi@0 42 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
aoqi@0 43
aoqi@0 44 static GCId GCTracer_next_gc_id = 0;
aoqi@0 45 static GCId create_new_gc_id() {
aoqi@0 46 return GCTracer_next_gc_id++;
aoqi@0 47 }
aoqi@0 48
aoqi@0 49 void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) {
aoqi@0 50 assert_unset_gc_id();
aoqi@0 51
aoqi@0 52 GCId gc_id = create_new_gc_id();
aoqi@0 53 _shared_gc_info.set_id(gc_id);
aoqi@0 54 _shared_gc_info.set_cause(cause);
aoqi@0 55 _shared_gc_info.set_start_timestamp(timestamp);
aoqi@0 56 }
aoqi@0 57
aoqi@0 58 void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) {
aoqi@0 59 assert_unset_gc_id();
aoqi@0 60
aoqi@0 61 report_gc_start_impl(cause, timestamp);
aoqi@0 62 }
aoqi@0 63
aoqi@0 64 bool GCTracer::has_reported_gc_start() const {
aoqi@0 65 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
aoqi@0 66 }
aoqi@0 67
aoqi@0 68 void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
aoqi@0 69 assert_set_gc_id();
aoqi@0 70
aoqi@0 71 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
aoqi@0 72 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
aoqi@0 73 _shared_gc_info.set_end_timestamp(timestamp);
aoqi@0 74
aoqi@0 75 send_phase_events(time_partitions);
aoqi@0 76 send_garbage_collection_event();
aoqi@0 77 }
aoqi@0 78
aoqi@0 79 void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) {
aoqi@0 80 assert_set_gc_id();
aoqi@0 81
aoqi@0 82 report_gc_end_impl(timestamp, time_partitions);
aoqi@0 83
aoqi@0 84 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
aoqi@0 88 assert_set_gc_id();
aoqi@0 89
aoqi@0 90 send_reference_stats_event(REF_SOFT, rps.soft_count());
aoqi@0 91 send_reference_stats_event(REF_WEAK, rps.weak_count());
aoqi@0 92 send_reference_stats_event(REF_FINAL, rps.final_count());
aoqi@0 93 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
aoqi@0 94 }
aoqi@0 95
aoqi@0 96 #if INCLUDE_SERVICES
aoqi@0 97 class ObjectCountEventSenderClosure : public KlassInfoClosure {
aoqi@0 98 const GCId _gc_id;
aoqi@0 99 const double _size_threshold_percentage;
aoqi@0 100 const size_t _total_size_in_words;
aoqi@0 101 const Ticks _timestamp;
aoqi@0 102
aoqi@0 103 public:
aoqi@0 104 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, const Ticks& timestamp) :
aoqi@0 105 _gc_id(gc_id),
aoqi@0 106 _size_threshold_percentage(ObjectCountCutOffPercent / 100),
aoqi@0 107 _total_size_in_words(total_size_in_words),
aoqi@0 108 _timestamp(timestamp)
aoqi@0 109 {}
aoqi@0 110
aoqi@0 111 virtual void do_cinfo(KlassInfoEntry* entry) {
aoqi@0 112 if (should_send_event(entry)) {
aoqi@0 113 ObjectCountEventSender::send(entry, _gc_id, _timestamp);
aoqi@0 114 }
aoqi@0 115 }
aoqi@0 116
aoqi@0 117 private:
aoqi@0 118 bool should_send_event(const KlassInfoEntry* entry) const {
aoqi@0 119 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
aoqi@0 120 return percentage_of_heap >= _size_threshold_percentage;
aoqi@0 121 }
aoqi@0 122 };
aoqi@0 123
aoqi@0 124 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
aoqi@0 125 assert_set_gc_id();
aoqi@0 126 assert(is_alive_cl != NULL, "Must supply function to check liveness");
aoqi@0 127
aoqi@0 128 if (ObjectCountEventSender::should_send_event()) {
aoqi@0 129 ResourceMark rm;
aoqi@0 130
aoqi@0 131 KlassInfoTable cit(false);
aoqi@0 132 if (!cit.allocation_failed()) {
aoqi@0 133 HeapInspection hi(false, false, false, NULL);
aoqi@0 134 hi.populate_table(&cit, is_alive_cl);
aoqi@0 135 ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), Ticks::now());
aoqi@0 136 cit.iterate(&event_sender);
aoqi@0 137 }
aoqi@0 138 }
aoqi@0 139 }
aoqi@0 140 #endif // INCLUDE_SERVICES
aoqi@0 141
aoqi@0 142 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
aoqi@0 143 assert_set_gc_id();
aoqi@0 144
aoqi@0 145 send_gc_heap_summary_event(when, heap_summary);
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const {
aoqi@0 149 assert_set_gc_id();
aoqi@0 150
aoqi@0 151 send_meta_space_summary_event(when, summary);
aoqi@0 152
aoqi@0 153 send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary());
aoqi@0 154 if (UseCompressedClassPointers) {
aoqi@0 155 send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary());
aoqi@0 156 }
aoqi@0 157 }
aoqi@0 158
aoqi@0 159 void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
aoqi@0 160 assert_set_gc_id();
aoqi@0 161 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
aoqi@0 162
aoqi@0 163 GCTracer::report_gc_end_impl(timestamp, time_partitions);
aoqi@0 164 send_young_gc_event();
aoqi@0 165
aoqi@0 166 _tenuring_threshold = UNSET_TENURING_THRESHOLD;
aoqi@0 167 }
aoqi@0 168
aoqi@0 169 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
aoqi@0 170 assert_set_gc_id();
aoqi@0 171
aoqi@0 172 send_promotion_failed_event(pf_info);
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
aoqi@0 176 _tenuring_threshold = tenuring_threshold;
aoqi@0 177 }
aoqi@0 178
aoqi@0 179 void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
aoqi@0 180 assert_set_gc_id();
aoqi@0 181
aoqi@0 182 GCTracer::report_gc_end_impl(timestamp, time_partitions);
aoqi@0 183 send_old_gc_event();
aoqi@0 184 }
aoqi@0 185
aoqi@0 186 void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
aoqi@0 187 assert_set_gc_id();
aoqi@0 188
aoqi@0 189 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
aoqi@0 190 send_parallel_old_event();
aoqi@0 191 }
aoqi@0 192
aoqi@0 193 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
aoqi@0 194 assert_set_gc_id();
aoqi@0 195
aoqi@0 196 _parallel_old_gc_info.report_dense_prefix(dense_prefix);
aoqi@0 197 }
aoqi@0 198
aoqi@0 199 void OldGCTracer::report_concurrent_mode_failure() {
aoqi@0 200 assert_set_gc_id();
aoqi@0 201
aoqi@0 202 send_concurrent_mode_failure_event();
aoqi@0 203 }
aoqi@0 204
aoqi@0 205 #if INCLUDE_ALL_GCS
aoqi@0 206 void G1NewTracer::report_yc_type(G1YCType type) {
aoqi@0 207 assert_set_gc_id();
aoqi@0 208
aoqi@0 209 _g1_young_gc_info.set_type(type);
aoqi@0 210 }
aoqi@0 211
aoqi@0 212 void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
aoqi@0 213 assert_set_gc_id();
aoqi@0 214
aoqi@0 215 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
aoqi@0 216 send_g1_young_gc_event();
aoqi@0 217 }
aoqi@0 218
aoqi@0 219 void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {
aoqi@0 220 assert_set_gc_id();
aoqi@0 221
aoqi@0 222 send_evacuation_info_event(info);
aoqi@0 223 }
aoqi@0 224
aoqi@0 225 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {
aoqi@0 226 assert_set_gc_id();
aoqi@0 227
aoqi@0 228 send_evacuation_failed_event(ef_info);
aoqi@0 229 ef_info.reset();
aoqi@0 230 }
aoqi@0 231 #endif

mercurial