1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/shared/gcTrace.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,243 @@ 1.4 +/* 1.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACE_HPP 1.29 +#define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACE_HPP 1.30 + 1.31 +#include "gc_interface/gcCause.hpp" 1.32 +#include "gc_interface/gcName.hpp" 1.33 +#include "gc_implementation/shared/gcWhen.hpp" 1.34 +#include "gc_implementation/shared/copyFailedInfo.hpp" 1.35 +#include "memory/allocation.hpp" 1.36 +#include "memory/metaspace.hpp" 1.37 +#include "memory/referenceType.hpp" 1.38 +#if INCLUDE_ALL_GCS 1.39 +#include "gc_implementation/g1/g1YCTypes.hpp" 1.40 +#endif 1.41 +#include "utilities/macros.hpp" 1.42 +#include "utilities/ticks.hpp" 1.43 + 1.44 +typedef uint GCId; 1.45 + 1.46 +class EvacuationInfo; 1.47 +class GCHeapSummary; 1.48 +class MetaspaceChunkFreeListSummary; 1.49 +class MetaspaceSummary; 1.50 +class PSHeapSummary; 1.51 +class ReferenceProcessorStats; 1.52 +class TimePartitions; 1.53 +class BoolObjectClosure; 1.54 + 1.55 +class SharedGCInfo VALUE_OBJ_CLASS_SPEC { 1.56 + public: 1.57 + static const GCId UNSET_GCID = (GCId)-1; 1.58 + 1.59 + private: 1.60 + GCId _id; 1.61 + GCName _name; 1.62 + GCCause::Cause _cause; 1.63 + Ticks _start_timestamp; 1.64 + Ticks _end_timestamp; 1.65 + Tickspan _sum_of_pauses; 1.66 + Tickspan _longest_pause; 1.67 + 1.68 + public: 1.69 + SharedGCInfo(GCName name) : 1.70 + _id(UNSET_GCID), 1.71 + _name(name), 1.72 + _cause(GCCause::_last_gc_cause), 1.73 + _start_timestamp(), 1.74 + _end_timestamp(), 1.75 + _sum_of_pauses(), 1.76 + _longest_pause() { 1.77 + } 1.78 + 1.79 + void set_id(GCId id) { _id = id; } 1.80 + GCId id() const { return _id; } 1.81 + 1.82 + void set_start_timestamp(const Ticks& timestamp) { _start_timestamp = timestamp; } 1.83 + const Ticks start_timestamp() const { return _start_timestamp; } 1.84 + 1.85 + void set_end_timestamp(const Ticks& timestamp) { _end_timestamp = timestamp; } 1.86 + const Ticks end_timestamp() const { return _end_timestamp; } 1.87 + 1.88 + void set_name(GCName name) { _name = name; } 1.89 + GCName name() const { return _name; } 1.90 + 1.91 + void set_cause(GCCause::Cause cause) { _cause = cause; } 1.92 + GCCause::Cause cause() const { return _cause; } 1.93 + 1.94 + void set_sum_of_pauses(const Tickspan& duration) { _sum_of_pauses = duration; } 1.95 + const Tickspan sum_of_pauses() const { return _sum_of_pauses; } 1.96 + 1.97 + void set_longest_pause(const Tickspan& duration) { _longest_pause = duration; } 1.98 + const Tickspan longest_pause() const { return _longest_pause; } 1.99 +}; 1.100 + 1.101 +class ParallelOldGCInfo VALUE_OBJ_CLASS_SPEC { 1.102 + void* _dense_prefix; 1.103 + public: 1.104 + ParallelOldGCInfo() : _dense_prefix(NULL) {} 1.105 + void report_dense_prefix(void* addr) { 1.106 + _dense_prefix = addr; 1.107 + } 1.108 + void* dense_prefix() const { return _dense_prefix; } 1.109 +}; 1.110 + 1.111 +#if INCLUDE_ALL_GCS 1.112 + 1.113 +class G1YoungGCInfo VALUE_OBJ_CLASS_SPEC { 1.114 + G1YCType _type; 1.115 + public: 1.116 + G1YoungGCInfo() : _type(G1YCTypeEndSentinel) {} 1.117 + void set_type(G1YCType type) { 1.118 + _type = type; 1.119 + } 1.120 + G1YCType type() const { return _type; } 1.121 +}; 1.122 + 1.123 +#endif // INCLUDE_ALL_GCS 1.124 + 1.125 +class GCTracer : public ResourceObj { 1.126 + protected: 1.127 + SharedGCInfo _shared_gc_info; 1.128 + 1.129 + public: 1.130 + void report_gc_start(GCCause::Cause cause, const Ticks& timestamp); 1.131 + void report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions); 1.132 + void report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const; 1.133 + void report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& metaspace_summary) const; 1.134 + void report_gc_reference_stats(const ReferenceProcessorStats& rp) const; 1.135 + void report_object_count_after_gc(BoolObjectClosure* object_filter) NOT_SERVICES_RETURN; 1.136 + bool has_reported_gc_start() const; 1.137 + 1.138 + protected: 1.139 + GCTracer(GCName name) : _shared_gc_info(name) {} 1.140 + virtual void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp); 1.141 + virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 1.142 + 1.143 + private: 1.144 + void send_garbage_collection_event() const; 1.145 + void send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const; 1.146 + void send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const; 1.147 + void send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspace::MetadataType mdtype, const MetaspaceChunkFreeListSummary& summary) const; 1.148 + void send_reference_stats_event(ReferenceType type, size_t count) const; 1.149 + void send_phase_events(TimePartitions* time_partitions) const; 1.150 +}; 1.151 + 1.152 +class YoungGCTracer : public GCTracer { 1.153 + static const uint UNSET_TENURING_THRESHOLD = (uint) -1; 1.154 + 1.155 + uint _tenuring_threshold; 1.156 + 1.157 + protected: 1.158 + YoungGCTracer(GCName name) : GCTracer(name), _tenuring_threshold(UNSET_TENURING_THRESHOLD) {} 1.159 + virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 1.160 + 1.161 + public: 1.162 + void report_promotion_failed(const PromotionFailedInfo& pf_info); 1.163 + void report_tenuring_threshold(const uint tenuring_threshold); 1.164 + 1.165 + private: 1.166 + void send_young_gc_event() const; 1.167 + void send_promotion_failed_event(const PromotionFailedInfo& pf_info) const; 1.168 +}; 1.169 + 1.170 +class OldGCTracer : public GCTracer { 1.171 + protected: 1.172 + OldGCTracer(GCName name) : GCTracer(name) {} 1.173 + virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 1.174 + 1.175 + public: 1.176 + void report_concurrent_mode_failure(); 1.177 + 1.178 + private: 1.179 + void send_old_gc_event() const; 1.180 + void send_concurrent_mode_failure_event(); 1.181 +}; 1.182 + 1.183 +class ParallelOldTracer : public OldGCTracer { 1.184 + ParallelOldGCInfo _parallel_old_gc_info; 1.185 + 1.186 + public: 1.187 + ParallelOldTracer() : OldGCTracer(ParallelOld) {} 1.188 + void report_dense_prefix(void* dense_prefix); 1.189 + 1.190 + protected: 1.191 + void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 1.192 + 1.193 + private: 1.194 + void send_parallel_old_event() const; 1.195 +}; 1.196 + 1.197 +class SerialOldTracer : public OldGCTracer { 1.198 + public: 1.199 + SerialOldTracer() : OldGCTracer(SerialOld) {} 1.200 +}; 1.201 + 1.202 +class ParallelScavengeTracer : public YoungGCTracer { 1.203 + public: 1.204 + ParallelScavengeTracer() : YoungGCTracer(ParallelScavenge) {} 1.205 +}; 1.206 + 1.207 +class DefNewTracer : public YoungGCTracer { 1.208 + public: 1.209 + DefNewTracer() : YoungGCTracer(DefNew) {} 1.210 +}; 1.211 + 1.212 +class ParNewTracer : public YoungGCTracer { 1.213 + public: 1.214 + ParNewTracer() : YoungGCTracer(ParNew) {} 1.215 +}; 1.216 + 1.217 +#if INCLUDE_ALL_GCS 1.218 +class G1NewTracer : public YoungGCTracer { 1.219 + G1YoungGCInfo _g1_young_gc_info; 1.220 + 1.221 + public: 1.222 + G1NewTracer() : YoungGCTracer(G1New) {} 1.223 + 1.224 + void report_yc_type(G1YCType type); 1.225 + void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 1.226 + void report_evacuation_info(EvacuationInfo* info); 1.227 + void report_evacuation_failed(EvacuationFailedInfo& ef_info); 1.228 + 1.229 + private: 1.230 + void send_g1_young_gc_event(); 1.231 + void send_evacuation_info_event(EvacuationInfo* info); 1.232 + void send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const; 1.233 +}; 1.234 +#endif 1.235 + 1.236 +class CMSTracer : public OldGCTracer { 1.237 + public: 1.238 + CMSTracer() : OldGCTracer(ConcurrentMarkSweep) {} 1.239 +}; 1.240 + 1.241 +class G1OldTracer : public OldGCTracer { 1.242 + public: 1.243 + G1OldTracer() : OldGCTracer(G1Old) {} 1.244 +}; 1.245 + 1.246 +#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACE_HPP