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_implementation/shared/gcHeapSummary.hpp" 27 #include "gc_implementation/shared/gcTimer.hpp" 28 #include "gc_implementation/shared/gcTrace.hpp" 29 #include "gc_implementation/shared/promotionFailedInfo.hpp" 30 #include "memory/referenceProcessorStats.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 33 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?") 34 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?") 35 36 static jlong GCTracer_next_gc_id = 0; 37 static GCId create_new_gc_id() { 38 return GCTracer_next_gc_id++; 39 } 40 41 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) { 42 assert_unset_gc_id(); 43 44 GCId gc_id = create_new_gc_id(); 45 _shared_gc_info.set_id(gc_id); 46 _shared_gc_info.set_cause(cause); 47 _shared_gc_info.set_start_timestamp(timestamp); 48 } 49 66 67 send_phase_events(time_partitions); 68 send_garbage_collection_event(); 69 } 70 71 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) { 72 assert_set_gc_id(); 73 74 report_gc_end_impl(timestamp, time_partitions); 75 76 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID); 77 } 78 79 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const { 80 assert_set_gc_id(); 81 82 send_reference_stats_event(REF_SOFT, rps.soft_count()); 83 send_reference_stats_event(REF_WEAK, rps.weak_count()); 84 send_reference_stats_event(REF_FINAL, rps.final_count()); 85 send_reference_stats_event(REF_PHANTOM, rps.phantom_count()); 86 } 87 88 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const { 89 assert_set_gc_id(); 90 91 send_gc_heap_summary_event(when, heap_summary); 92 send_perm_gen_summary_event(when, perm_gen_summary); 93 } 94 95 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 96 assert_set_gc_id(); 97 98 GCTracer::report_gc_end_impl(timestamp, time_partitions); 99 send_young_gc_event(); 100 } 101 102 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) { 103 assert_set_gc_id(); 104 105 send_promotion_failed_event(pf_info); | 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_implementation/shared/gcHeapSummary.hpp" 27 #include "gc_implementation/shared/gcTimer.hpp" 28 #include "gc_implementation/shared/gcTrace.hpp" 29 #include "gc_implementation/shared/promotionFailedInfo.hpp" 30 #include "memory/heapInspection.hpp" 31 #include "memory/iterator.hpp" 32 #include "memory/referenceProcessorStats.hpp" 33 #include "utilities/globalDefinitions.hpp" 34 35 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?") 36 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?") 37 38 static jlong GCTracer_next_gc_id = 0; 39 static GCId create_new_gc_id() { 40 return GCTracer_next_gc_id++; 41 } 42 43 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) { 44 assert_unset_gc_id(); 45 46 GCId gc_id = create_new_gc_id(); 47 _shared_gc_info.set_id(gc_id); 48 _shared_gc_info.set_cause(cause); 49 _shared_gc_info.set_start_timestamp(timestamp); 50 } 51 68 69 send_phase_events(time_partitions); 70 send_garbage_collection_event(); 71 } 72 73 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) { 74 assert_set_gc_id(); 75 76 report_gc_end_impl(timestamp, time_partitions); 77 78 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID); 79 } 80 81 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const { 82 assert_set_gc_id(); 83 84 send_reference_stats_event(REF_SOFT, rps.soft_count()); 85 send_reference_stats_event(REF_WEAK, rps.weak_count()); 86 send_reference_stats_event(REF_FINAL, rps.final_count()); 87 send_reference_stats_event(REF_PHANTOM, rps.phantom_count()); 88 } 89 90 class ObjectCountEventSenderClosure : public KlassInfoClosure { 91 GCTracer* _gc_tracer; 92 public: 93 ObjectCountEventSenderClosure(GCTracer* gc_tracer) : _gc_tracer(gc_tracer) {} 94 private: 95 void do_cinfo(KlassInfoEntry* entry) { 96 _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(), 97 entry->words() * BytesPerWord); 98 } 99 }; 100 101 void GCTracer::report_object_count_after_gc(BoolObjectClosure *is_alive_cl) { 102 if (should_send_object_count_after_gc_event()) { 103 ResourceMark rm; 104 105 KlassInfoTable cit(HeapInspection::start_of_perm_gen()); 106 if (!cit.allocation_failed()) { 107 ObjectCountEventSenderClosure event_sender(this); 108 HeapInspection::instance_inspection(&cit, &event_sender, false, is_alive_cl); 109 } 110 } 111 } 112 113 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const { 114 assert_set_gc_id(); 115 116 send_gc_heap_summary_event(when, heap_summary); 117 send_perm_gen_summary_event(when, perm_gen_summary); 118 } 119 120 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) { 121 assert_set_gc_id(); 122 123 GCTracer::report_gc_end_impl(timestamp, time_partitions); 124 send_young_gc_event(); 125 } 126 127 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) { 128 assert_set_gc_id(); 129 130 send_promotion_failed_event(pf_info); |