comparison src/share/vm/gc_implementation/shared/gcTrace.cpp @ 13400:86e6d691f2e1

8028128: Add a type safe alternative for working with counter based data Reviewed-by: dholmes, egahlin
author mgronlun
date Sat, 23 Nov 2013 12:25:13 +0100
parents 6aa440bc1125
children 9fdaa79b0c27
comparison
equal deleted inserted replaced
13399:260ac69dc096 13400:86e6d691f2e1
30 #include "gc_implementation/shared/objectCountEventSender.hpp" 30 #include "gc_implementation/shared/objectCountEventSender.hpp"
31 #include "memory/heapInspection.hpp" 31 #include "memory/heapInspection.hpp"
32 #include "memory/referenceProcessorStats.hpp" 32 #include "memory/referenceProcessorStats.hpp"
33 #include "runtime/os.hpp" 33 #include "runtime/os.hpp"
34 #include "utilities/globalDefinitions.hpp" 34 #include "utilities/globalDefinitions.hpp"
35 #include "utilities/ticks.inline.hpp"
35 36
36 #if INCLUDE_ALL_GCS 37 #if INCLUDE_ALL_GCS
37 #include "gc_implementation/g1/evacuationInfo.hpp" 38 #include "gc_implementation/g1/evacuationInfo.hpp"
38 #endif 39 #endif
39 40
43 static GCId GCTracer_next_gc_id = 0; 44 static GCId GCTracer_next_gc_id = 0;
44 static GCId create_new_gc_id() { 45 static GCId create_new_gc_id() {
45 return GCTracer_next_gc_id++; 46 return GCTracer_next_gc_id++;
46 } 47 }
47 48
48 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) { 49 void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) {
49 assert_unset_gc_id(); 50 assert_unset_gc_id();
50 51
51 GCId gc_id = create_new_gc_id(); 52 GCId gc_id = create_new_gc_id();
52 _shared_gc_info.set_id(gc_id); 53 _shared_gc_info.set_id(gc_id);
53 _shared_gc_info.set_cause(cause); 54 _shared_gc_info.set_cause(cause);
54 _shared_gc_info.set_start_timestamp(timestamp); 55 _shared_gc_info.set_start_timestamp(timestamp);
55 } 56 }
56 57
57 void GCTracer::report_gc_start(GCCause::Cause cause, jlong timestamp) { 58 void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) {
58 assert_unset_gc_id(); 59 assert_unset_gc_id();
59 60
60 report_gc_start_impl(cause, timestamp); 61 report_gc_start_impl(cause, timestamp);
61 } 62 }
62 63
63 bool GCTracer::has_reported_gc_start() const { 64 bool GCTracer::has_reported_gc_start() const {
64 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID; 65 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
65 } 66 }
66 67
67 void GCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 68 void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
68 assert_set_gc_id(); 69 assert_set_gc_id();
69 70
70 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses()); 71 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
71 _shared_gc_info.set_longest_pause(time_partitions->longest_pause()); 72 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
72 _shared_gc_info.set_end_timestamp(timestamp); 73 _shared_gc_info.set_end_timestamp(timestamp);
73 74
74 send_phase_events(time_partitions); 75 send_phase_events(time_partitions);
75 send_garbage_collection_event(); 76 send_garbage_collection_event();
76 } 77 }
77 78
78 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) { 79 void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) {
79 assert_set_gc_id(); 80 assert_set_gc_id();
80 81
81 report_gc_end_impl(timestamp, time_partitions); 82 report_gc_end_impl(timestamp, time_partitions);
82 83
83 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID); 84 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
95 #if INCLUDE_SERVICES 96 #if INCLUDE_SERVICES
96 class ObjectCountEventSenderClosure : public KlassInfoClosure { 97 class ObjectCountEventSenderClosure : public KlassInfoClosure {
97 const GCId _gc_id; 98 const GCId _gc_id;
98 const double _size_threshold_percentage; 99 const double _size_threshold_percentage;
99 const size_t _total_size_in_words; 100 const size_t _total_size_in_words;
100 const jlong _timestamp; 101 const Ticks _timestamp;
101 102
102 public: 103 public:
103 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, jlong timestamp) : 104 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, const Ticks& timestamp) :
104 _gc_id(gc_id), 105 _gc_id(gc_id),
105 _size_threshold_percentage(ObjectCountCutOffPercent / 100), 106 _size_threshold_percentage(ObjectCountCutOffPercent / 100),
106 _total_size_in_words(total_size_in_words), 107 _total_size_in_words(total_size_in_words),
107 _timestamp(timestamp) 108 _timestamp(timestamp)
108 {} 109 {}
129 130
130 KlassInfoTable cit(false); 131 KlassInfoTable cit(false);
131 if (!cit.allocation_failed()) { 132 if (!cit.allocation_failed()) {
132 HeapInspection hi(false, false, false, NULL); 133 HeapInspection hi(false, false, false, NULL);
133 hi.populate_table(&cit, is_alive_cl); 134 hi.populate_table(&cit, is_alive_cl);
134 135 ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), Ticks::now());
135 jlong timestamp = os::elapsed_counter();
136 ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), timestamp);
137 cit.iterate(&event_sender); 136 cit.iterate(&event_sender);
138 } 137 }
139 } 138 }
140 } 139 }
141 #endif // INCLUDE_SERVICES 140 #endif // INCLUDE_SERVICES
145 144
146 send_gc_heap_summary_event(when, heap_summary); 145 send_gc_heap_summary_event(when, heap_summary);
147 send_meta_space_summary_event(when, meta_space_summary); 146 send_meta_space_summary_event(when, meta_space_summary);
148 } 147 }
149 148
150 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 149 void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
151 assert_set_gc_id(); 150 assert_set_gc_id();
152 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported"); 151 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
153 152
154 GCTracer::report_gc_end_impl(timestamp, time_partitions); 153 GCTracer::report_gc_end_impl(timestamp, time_partitions);
155 send_young_gc_event(); 154 send_young_gc_event();
165 164
166 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) { 165 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
167 _tenuring_threshold = tenuring_threshold; 166 _tenuring_threshold = tenuring_threshold;
168 } 167 }
169 168
170 void OldGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 169 void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
171 assert_set_gc_id(); 170 assert_set_gc_id();
172 171
173 GCTracer::report_gc_end_impl(timestamp, time_partitions); 172 GCTracer::report_gc_end_impl(timestamp, time_partitions);
174 send_old_gc_event(); 173 send_old_gc_event();
175 } 174 }
176 175
177 void ParallelOldTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 176 void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
178 assert_set_gc_id(); 177 assert_set_gc_id();
179 178
180 OldGCTracer::report_gc_end_impl(timestamp, time_partitions); 179 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
181 send_parallel_old_event(); 180 send_parallel_old_event();
182 } 181 }
198 assert_set_gc_id(); 197 assert_set_gc_id();
199 198
200 _g1_young_gc_info.set_type(type); 199 _g1_young_gc_info.set_type(type);
201 } 200 }
202 201
203 void G1NewTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 202 void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
204 assert_set_gc_id(); 203 assert_set_gc_id();
205 204
206 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions); 205 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
207 send_g1_young_gc_event(); 206 send_g1_young_gc_event();
208 } 207 }