comparison src/share/vm/gc_implementation/shared/gcTrace.cpp @ 11113:2cbc8f3011a0

8015972: Refactor the sending of the object count after GC event Reviewed-by: brutisso, pliden
author ehelin
date Wed, 05 Jun 2013 09:44:03 +0200
parents f2110083203d
children 63cffb381adc
comparison
equal deleted inserted replaced
11088:ea4d24c1e0c6 11113:2cbc8f3011a0
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "gc_implementation/shared/copyFailedInfo.hpp"
26 #include "gc_implementation/shared/gcHeapSummary.hpp" 27 #include "gc_implementation/shared/gcHeapSummary.hpp"
27 #include "gc_implementation/shared/gcTimer.hpp" 28 #include "gc_implementation/shared/gcTimer.hpp"
28 #include "gc_implementation/shared/gcTrace.hpp" 29 #include "gc_implementation/shared/gcTrace.hpp"
29 #include "gc_implementation/shared/copyFailedInfo.hpp" 30 #include "gc_implementation/shared/objectCountEventSender.hpp"
30 #include "memory/heapInspection.hpp" 31 #include "memory/heapInspection.hpp"
31 #include "memory/referenceProcessorStats.hpp" 32 #include "memory/referenceProcessorStats.hpp"
32 #include "utilities/globalDefinitions.hpp" 33 #include "utilities/globalDefinitions.hpp"
33 34
34 #if INCLUDE_ALL_GCS 35 #if INCLUDE_ALL_GCS
89 send_reference_stats_event(REF_FINAL, rps.final_count()); 90 send_reference_stats_event(REF_FINAL, rps.final_count());
90 send_reference_stats_event(REF_PHANTOM, rps.phantom_count()); 91 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
91 } 92 }
92 93
93 #if INCLUDE_SERVICES 94 #if INCLUDE_SERVICES
94 void ObjectCountEventSenderClosure::do_cinfo(KlassInfoEntry* entry) { 95 class ObjectCountEventSenderClosure : public KlassInfoClosure {
95 if (should_send_event(entry)) { 96 const GCId _gc_id;
96 send_event(entry); 97 const double _size_threshold_percentage;
98 const size_t _total_size_in_words;
99
100 public:
101 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words) :
102 _gc_id(gc_id),
103 _size_threshold_percentage(ObjectCountCutOffPercent / 100),
104 _total_size_in_words(total_size_in_words)
105 {}
106
107 virtual void do_cinfo(KlassInfoEntry* entry) {
108 if (should_send_event(entry)) {
109 ObjectCountEventSender::send(entry, _gc_id);
110 }
97 } 111 }
98 } 112
99 113 private:
100 void ObjectCountEventSenderClosure::send_event(KlassInfoEntry* entry) { 114 bool should_send_event(const KlassInfoEntry* entry) const {
101 _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(), 115 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
102 entry->words() * BytesPerWord); 116 return percentage_of_heap >= _size_threshold_percentage;
103 } 117 }
104 118 };
105 bool ObjectCountEventSenderClosure::should_send_event(KlassInfoEntry* entry) const {
106 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
107 return percentage_of_heap > _size_threshold_percentage;
108 }
109 119
110 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) { 120 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
111 assert_set_gc_id(); 121 assert_set_gc_id();
112 122 assert(is_alive_cl != NULL, "Must supply function to check liveness");
113 if (should_send_object_count_after_gc_event()) { 123
124 if (ObjectCountEventSender::should_send_event()) {
114 ResourceMark rm; 125 ResourceMark rm;
115 126
116 KlassInfoTable cit(false); 127 KlassInfoTable cit(false);
117 if (!cit.allocation_failed()) { 128 if (!cit.allocation_failed()) {
118 HeapInspection hi(false, false, false, NULL); 129 HeapInspection hi(false, false, false, NULL);
119 hi.populate_table(&cit, is_alive_cl); 130 hi.populate_table(&cit, is_alive_cl);
120 131
121 ObjectCountEventSenderClosure event_sender(this, cit.size_of_instances_in_words()); 132 ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words());
122 cit.iterate(&event_sender); 133 cit.iterate(&event_sender);
123 } 134 }
124 } 135 }
125 } 136 }
126 #endif 137 #endif // INCLUDE_SERVICES
127 138
128 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_summary) const { 139 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_summary) const {
129 assert_set_gc_id(); 140 assert_set_gc_id();
130 141
131 send_gc_heap_summary_event(when, heap_summary); 142 send_gc_heap_summary_event(when, heap_summary);