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

Wed, 12 Jun 2013 15:50:14 +0200

author
ehelin
date
Wed, 12 Jun 2013 15:50:14 +0200
changeset 5387
63cffb381adc
parent 5386
2cbc8f3011a0
child 5388
6aa440bc1125
permissions
-rw-r--r--

8016170: GC id variable in gcTrace.cpp should use typedef GCId
Reviewed-by: johnc, jwilhelm, jmasa

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

mercurial