hotspot/src/share/vm/gc/shared/gcTrace.hpp
changeset 30764 fec48bf5a827
parent 28940 c314cf1db3fa
child 31344 2316eb7a0358
equal deleted inserted replaced
30614:e45861098f5a 30764:fec48bf5a827
       
     1 /*
       
     2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    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 #ifndef SHARE_VM_GC_SHARED_GCTRACE_HPP
       
    26 #define SHARE_VM_GC_SHARED_GCTRACE_HPP
       
    27 
       
    28 #include "gc/shared/copyFailedInfo.hpp"
       
    29 #include "gc/shared/gcCause.hpp"
       
    30 #include "gc/shared/gcId.hpp"
       
    31 #include "gc/shared/gcName.hpp"
       
    32 #include "gc/shared/gcWhen.hpp"
       
    33 #include "memory/allocation.hpp"
       
    34 #include "memory/metaspace.hpp"
       
    35 #include "memory/referenceType.hpp"
       
    36 #include "utilities/macros.hpp"
       
    37 #include "utilities/ticks.hpp"
       
    38 #if INCLUDE_ALL_GCS
       
    39 #include "gc/g1/g1YCTypes.hpp"
       
    40 #endif
       
    41 
       
    42 class EvacuationInfo;
       
    43 class GCHeapSummary;
       
    44 class MetaspaceChunkFreeListSummary;
       
    45 class MetaspaceSummary;
       
    46 class PSHeapSummary;
       
    47 class ReferenceProcessorStats;
       
    48 class TimePartitions;
       
    49 class BoolObjectClosure;
       
    50 
       
    51 class SharedGCInfo VALUE_OBJ_CLASS_SPEC {
       
    52  private:
       
    53   GCId _gc_id;
       
    54   GCName _name;
       
    55   GCCause::Cause _cause;
       
    56   Ticks     _start_timestamp;
       
    57   Ticks     _end_timestamp;
       
    58   Tickspan  _sum_of_pauses;
       
    59   Tickspan  _longest_pause;
       
    60 
       
    61  public:
       
    62   SharedGCInfo(GCName name) :
       
    63     _gc_id(GCId::undefined()),
       
    64     _name(name),
       
    65     _cause(GCCause::_last_gc_cause),
       
    66     _start_timestamp(),
       
    67     _end_timestamp(),
       
    68     _sum_of_pauses(),
       
    69     _longest_pause() {
       
    70   }
       
    71 
       
    72   void set_gc_id(GCId gc_id) { _gc_id = gc_id; }
       
    73   const GCId& gc_id() const { return _gc_id; }
       
    74 
       
    75   void set_start_timestamp(const Ticks& timestamp) { _start_timestamp = timestamp; }
       
    76   const Ticks start_timestamp() const { return _start_timestamp; }
       
    77 
       
    78   void set_end_timestamp(const Ticks& timestamp) { _end_timestamp = timestamp; }
       
    79   const Ticks end_timestamp() const { return _end_timestamp; }
       
    80 
       
    81   void set_name(GCName name) { _name = name; }
       
    82   GCName name() const { return _name; }
       
    83 
       
    84   void set_cause(GCCause::Cause cause) { _cause = cause; }
       
    85   GCCause::Cause cause() const { return _cause; }
       
    86 
       
    87   void set_sum_of_pauses(const Tickspan& duration) { _sum_of_pauses = duration; }
       
    88   const Tickspan sum_of_pauses() const { return _sum_of_pauses; }
       
    89 
       
    90   void set_longest_pause(const Tickspan& duration) { _longest_pause = duration; }
       
    91   const Tickspan longest_pause() const { return _longest_pause; }
       
    92 };
       
    93 
       
    94 class ParallelOldGCInfo VALUE_OBJ_CLASS_SPEC {
       
    95   void* _dense_prefix;
       
    96  public:
       
    97   ParallelOldGCInfo() : _dense_prefix(NULL) {}
       
    98   void report_dense_prefix(void* addr) {
       
    99     _dense_prefix = addr;
       
   100   }
       
   101   void* dense_prefix() const { return _dense_prefix; }
       
   102 };
       
   103 
       
   104 #if INCLUDE_ALL_GCS
       
   105 
       
   106 class G1YoungGCInfo VALUE_OBJ_CLASS_SPEC {
       
   107   G1YCType _type;
       
   108  public:
       
   109   G1YoungGCInfo() : _type(G1YCTypeEndSentinel) {}
       
   110   void set_type(G1YCType type) {
       
   111     _type = type;
       
   112   }
       
   113   G1YCType type() const { return _type; }
       
   114 };
       
   115 
       
   116 #endif // INCLUDE_ALL_GCS
       
   117 
       
   118 class GCTracer : public ResourceObj {
       
   119  protected:
       
   120   SharedGCInfo _shared_gc_info;
       
   121 
       
   122  public:
       
   123   void report_gc_start(GCCause::Cause cause, const Ticks& timestamp);
       
   124   void report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions);
       
   125   void report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const;
       
   126   void report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& metaspace_summary) const;
       
   127   void report_gc_reference_stats(const ReferenceProcessorStats& rp) const;
       
   128   void report_object_count_after_gc(BoolObjectClosure* object_filter) NOT_SERVICES_RETURN;
       
   129   bool has_reported_gc_start() const;
       
   130   const GCId& gc_id() { return _shared_gc_info.gc_id(); }
       
   131 
       
   132  protected:
       
   133   GCTracer(GCName name) : _shared_gc_info(name) {}
       
   134   void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp);
       
   135   virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
       
   136 
       
   137  private:
       
   138   void send_garbage_collection_event() const;
       
   139   void send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const;
       
   140   void send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const;
       
   141   void send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspace::MetadataType mdtype, const MetaspaceChunkFreeListSummary& summary) const;
       
   142   void send_reference_stats_event(ReferenceType type, size_t count) const;
       
   143   void send_phase_events(TimePartitions* time_partitions) const;
       
   144 };
       
   145 
       
   146 class YoungGCTracer : public GCTracer {
       
   147   static const uint UNSET_TENURING_THRESHOLD = (uint) -1;
       
   148 
       
   149   uint _tenuring_threshold;
       
   150 
       
   151  protected:
       
   152   YoungGCTracer(GCName name) : GCTracer(name), _tenuring_threshold(UNSET_TENURING_THRESHOLD) {}
       
   153   virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
       
   154 
       
   155  public:
       
   156   void report_promotion_failed(const PromotionFailedInfo& pf_info) const;
       
   157   void report_tenuring_threshold(const uint tenuring_threshold);
       
   158 
       
   159   /*
       
   160    * Methods for reporting Promotion in new or outside PLAB Events.
       
   161    *
       
   162    * The object age is always required as it is not certain that the mark word
       
   163    * of the oop can be trusted at this stage.
       
   164    *
       
   165    * obj_size is the size of the promoted object in bytes.
       
   166    *
       
   167    * tenured should be true if the object has been promoted to the old
       
   168    * space during this GC, if the object is copied to survivor space
       
   169    * from young space or survivor space (aging) tenured should be false.
       
   170    *
       
   171    * plab_size is the size of the newly allocated PLAB in bytes.
       
   172    */
       
   173   bool should_report_promotion_in_new_plab_event() const;
       
   174   bool should_report_promotion_outside_plab_event() const;
       
   175   void report_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
       
   176                                           uint age, bool tenured,
       
   177                                           size_t plab_size) const;
       
   178   void report_promotion_outside_plab_event(Klass* klass, size_t obj_size,
       
   179                                            uint age, bool tenured) const;
       
   180 
       
   181  private:
       
   182   void send_young_gc_event() const;
       
   183   void send_promotion_failed_event(const PromotionFailedInfo& pf_info) const;
       
   184   bool should_send_promotion_in_new_plab_event() const;
       
   185   bool should_send_promotion_outside_plab_event() const;
       
   186   void send_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
       
   187                                         uint age, bool tenured,
       
   188                                         size_t plab_size) const;
       
   189   void send_promotion_outside_plab_event(Klass* klass, size_t obj_size,
       
   190                                          uint age, bool tenured) const;
       
   191 };
       
   192 
       
   193 class OldGCTracer : public GCTracer {
       
   194  protected:
       
   195   OldGCTracer(GCName name) : GCTracer(name) {}
       
   196   virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
       
   197 
       
   198  public:
       
   199   void report_concurrent_mode_failure();
       
   200 
       
   201  private:
       
   202   void send_old_gc_event() const;
       
   203   void send_concurrent_mode_failure_event();
       
   204 };
       
   205 
       
   206 class ParallelOldTracer : public OldGCTracer {
       
   207   ParallelOldGCInfo _parallel_old_gc_info;
       
   208 
       
   209  public:
       
   210   ParallelOldTracer() : OldGCTracer(ParallelOld) {}
       
   211   void report_dense_prefix(void* dense_prefix);
       
   212 
       
   213  protected:
       
   214   void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
       
   215 
       
   216  private:
       
   217   void send_parallel_old_event() const;
       
   218 };
       
   219 
       
   220 class SerialOldTracer : public OldGCTracer {
       
   221  public:
       
   222   SerialOldTracer() : OldGCTracer(SerialOld) {}
       
   223 };
       
   224 
       
   225 class ParallelScavengeTracer : public YoungGCTracer {
       
   226  public:
       
   227   ParallelScavengeTracer() : YoungGCTracer(ParallelScavenge) {}
       
   228 };
       
   229 
       
   230 class DefNewTracer : public YoungGCTracer {
       
   231  public:
       
   232   DefNewTracer() : YoungGCTracer(DefNew) {}
       
   233 };
       
   234 
       
   235 class ParNewTracer : public YoungGCTracer {
       
   236  public:
       
   237   ParNewTracer() : YoungGCTracer(ParNew) {}
       
   238 };
       
   239 
       
   240 #if INCLUDE_ALL_GCS
       
   241 class G1NewTracer : public YoungGCTracer {
       
   242   G1YoungGCInfo _g1_young_gc_info;
       
   243 
       
   244  public:
       
   245   G1NewTracer() : YoungGCTracer(G1New) {}
       
   246 
       
   247   void report_yc_type(G1YCType type);
       
   248   void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
       
   249   void report_evacuation_info(EvacuationInfo* info);
       
   250   void report_evacuation_failed(EvacuationFailedInfo& ef_info);
       
   251 
       
   252  private:
       
   253   void send_g1_young_gc_event();
       
   254   void send_evacuation_info_event(EvacuationInfo* info);
       
   255   void send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const;
       
   256 };
       
   257 #endif
       
   258 
       
   259 class CMSTracer : public OldGCTracer {
       
   260  public:
       
   261   CMSTracer() : OldGCTracer(ConcurrentMarkSweep) {}
       
   262 };
       
   263 
       
   264 class G1OldTracer : public OldGCTracer {
       
   265  public:
       
   266   G1OldTracer() : OldGCTracer(G1Old) {}
       
   267 };
       
   268 
       
   269 #endif // SHARE_VM_GC_SHARED_GCTRACE_HPP