Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp
38920 views
/*1* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc_implementation/shared/copyFailedInfo.hpp"26#include "gc_implementation/shared/gcHeapSummary.hpp"27#include "gc_implementation/shared/gcId.hpp"28#include "gc_implementation/shared/gcTimer.hpp"29#include "gc_implementation/shared/gcTrace.hpp"30#include "gc_implementation/shared/objectCountEventSender.hpp"31#include "memory/heapInspection.hpp"32#include "memory/referenceProcessorStats.hpp"33#include "runtime/os.hpp"34#include "utilities/globalDefinitions.hpp"35#include "utilities/ticks.hpp"3637#if INCLUDE_ALL_GCS38#include "gc_implementation/g1/evacuationInfo.hpp"39#endif4041#define assert_unset_gc_id() assert(_shared_gc_info.gc_id().is_undefined(), "GC already started?")42#define assert_set_gc_id() assert(!_shared_gc_info.gc_id().is_undefined(), "GC not started?")4344void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) {45assert_unset_gc_id();4647GCId gc_id = GCId::create();48_shared_gc_info.set_gc_id(gc_id);49_shared_gc_info.set_cause(cause);50_shared_gc_info.set_start_timestamp(timestamp);51}5253void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) {54assert_unset_gc_id();5556report_gc_start_impl(cause, timestamp);57}5859bool GCTracer::has_reported_gc_start() const {60return !_shared_gc_info.gc_id().is_undefined();61}6263void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {64assert_set_gc_id();6566_shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());67_shared_gc_info.set_longest_pause(time_partitions->longest_pause());68_shared_gc_info.set_end_timestamp(timestamp);6970send_phase_events(time_partitions);71send_garbage_collection_event();72}7374void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) {75assert_set_gc_id();7677report_gc_end_impl(timestamp, time_partitions);7879_shared_gc_info.set_gc_id(GCId::undefined());80}8182void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {83assert_set_gc_id();8485send_reference_stats_event(REF_SOFT, rps.soft_count());86send_reference_stats_event(REF_WEAK, rps.weak_count());87send_reference_stats_event(REF_FINAL, rps.final_count());88send_reference_stats_event(REF_PHANTOM, rps.phantom_count());89}9091#if INCLUDE_SERVICES92class ObjectCountEventSenderClosure : public KlassInfoClosure {93const GCId _gc_id;94const double _size_threshold_percentage;95const size_t _total_size_in_words;96const Ticks _timestamp;9798public:99ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, const Ticks& timestamp) :100_gc_id(gc_id),101_size_threshold_percentage(ObjectCountCutOffPercent / 100),102_total_size_in_words(total_size_in_words),103_timestamp(timestamp)104{}105106virtual void do_cinfo(KlassInfoEntry* entry) {107if (should_send_event(entry)) {108ObjectCountEventSender::send(entry, _gc_id, _timestamp);109}110}111112private:113bool should_send_event(const KlassInfoEntry* entry) const {114double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;115return percentage_of_heap >= _size_threshold_percentage;116}117};118119void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {120assert_set_gc_id();121assert(is_alive_cl != NULL, "Must supply function to check liveness");122123if (ObjectCountEventSender::should_send_event()) {124ResourceMark rm;125126KlassInfoTable cit(false);127if (!cit.allocation_failed()) {128HeapInspection hi(false, false, false, NULL);129hi.populate_table(&cit, is_alive_cl);130ObjectCountEventSenderClosure event_sender(_shared_gc_info.gc_id(), cit.size_of_instances_in_words(), Ticks::now());131cit.iterate(&event_sender);132}133}134}135#endif // INCLUDE_SERVICES136137void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const {138assert_set_gc_id();139140send_gc_heap_summary_event(when, heap_summary);141}142143void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const {144assert_set_gc_id();145146send_meta_space_summary_event(when, summary);147148send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary());149if (UseCompressedClassPointers) {150send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary());151}152}153154void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {155assert_set_gc_id();156assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");157158GCTracer::report_gc_end_impl(timestamp, time_partitions);159send_young_gc_event();160161_tenuring_threshold = UNSET_TENURING_THRESHOLD;162}163164void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {165assert_set_gc_id();166167send_promotion_failed_event(pf_info);168}169170void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {171_tenuring_threshold = tenuring_threshold;172}173174bool YoungGCTracer::should_report_promotion_events() const {175return should_report_promotion_in_new_plab_event() ||176should_report_promotion_outside_plab_event();177}178179bool YoungGCTracer::should_report_promotion_in_new_plab_event() const {180return should_send_promotion_in_new_plab_event();181}182183bool YoungGCTracer::should_report_promotion_outside_plab_event() const {184return should_send_promotion_outside_plab_event();185}186187void YoungGCTracer::report_promotion_in_new_plab_event(Klass* klass, size_t obj_size,188uint age, bool tenured,189size_t plab_size) const {190send_promotion_in_new_plab_event(klass, obj_size, age, tenured, plab_size);191}192193void YoungGCTracer::report_promotion_outside_plab_event(Klass* klass, size_t obj_size,194uint age, bool tenured) const {195send_promotion_outside_plab_event(klass, obj_size, age, tenured);196}197198void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {199assert_set_gc_id();200201GCTracer::report_gc_end_impl(timestamp, time_partitions);202send_old_gc_event();203}204205void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {206assert_set_gc_id();207208OldGCTracer::report_gc_end_impl(timestamp, time_partitions);209send_parallel_old_event();210}211212void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {213assert_set_gc_id();214215_parallel_old_gc_info.report_dense_prefix(dense_prefix);216}217218void OldGCTracer::report_concurrent_mode_failure() {219assert_set_gc_id();220221send_concurrent_mode_failure_event();222}223224#if INCLUDE_ALL_GCS225void G1MMUTracer::report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec) {226send_g1_mmu_event(time_slice_sec * MILLIUNITS,227gc_time_sec * MILLIUNITS,228max_time_sec * MILLIUNITS);229}230231void G1NewTracer::report_yc_type(G1YCType type) {232assert_set_gc_id();233234_g1_young_gc_info.set_type(type);235}236237void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {238assert_set_gc_id();239240YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);241send_g1_young_gc_event();242}243244void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {245assert_set_gc_id();246247send_evacuation_info_event(info);248}249250void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {251assert_set_gc_id();252253send_evacuation_failed_event(ef_info);254ef_info.reset();255}256#endif257258259