hotspot/src/share/vm/gc/g1/g1HRPrinter.hpp
changeset 35061 be6025ebffea
parent 33786 ac8da6513351
child 35079 edab77f91231
equal deleted inserted replaced
35060:382d0689141c 35061:be6025ebffea
    24 
    24 
    25 #ifndef SHARE_VM_GC_G1_G1HRPRINTER_HPP
    25 #ifndef SHARE_VM_GC_G1_G1HRPRINTER_HPP
    26 #define SHARE_VM_GC_G1_G1HRPRINTER_HPP
    26 #define SHARE_VM_GC_G1_G1HRPRINTER_HPP
    27 
    27 
    28 #include "gc/g1/heapRegion.hpp"
    28 #include "gc/g1/heapRegion.hpp"
       
    29 #include "logging/log.hpp"
    29 #include "memory/allocation.hpp"
    30 #include "memory/allocation.hpp"
    30 
    31 
    31 #define SKIP_RETIRED_FULL_REGIONS 1
    32 #define SKIP_RETIRED_FULL_REGIONS 1
    32 
    33 
    33 class G1HRPrinter VALUE_OBJ_CLASS_SPEC {
    34 class G1HRPrinter VALUE_OBJ_CLASS_SPEC {
    53     StartsHumongous,
    54     StartsHumongous,
    54     ContinuesHumongous,
    55     ContinuesHumongous,
    55     Archive
    56     Archive
    56   } RegionType;
    57   } RegionType;
    57 
    58 
    58   typedef enum {
       
    59     StartGC,
       
    60     EndGC,
       
    61     StartFullGC,
       
    62     EndFullGC
       
    63   } PhaseType;
       
    64 
       
    65 private:
    59 private:
    66   bool _active;
       
    67 
       
    68   static const char* action_name(ActionType action);
    60   static const char* action_name(ActionType action);
    69   static const char* region_type_name(RegionType type);
    61   static const char* region_type_name(RegionType type);
    70   static const char* phase_name(PhaseType phase);
       
    71 
    62 
    72   // Print an action event. This version is used in most scenarios and
    63   // Print an action event. This version is used in most scenarios and
    73   // only prints the region's bottom. The parameters type and top are
    64   // only prints the region's bottom. The parameters type and top are
    74   // optional (the "not set" values are Unset and NULL).
    65   // optional (the "not set" values are Unset and NULL).
    75   static void print(ActionType action, RegionType type,
    66   static void print(ActionType action, RegionType type,
    77 
    68 
    78   // Print an action event. This version prints both the region's
    69   // Print an action event. This version prints both the region's
    79   // bottom and end. Used for Commit / Uncommit events.
    70   // bottom and end. Used for Commit / Uncommit events.
    80   static void print(ActionType action, HeapWord* bottom, HeapWord* end);
    71   static void print(ActionType action, HeapWord* bottom, HeapWord* end);
    81 
    72 
    82   // Print a phase event.
       
    83   static void print(PhaseType phase, size_t phase_num);
       
    84 
       
    85 public:
    73 public:
    86   // In some places we iterate over a list in order to generate output
    74   // In some places we iterate over a list in order to generate output
    87   // for the list's elements. By exposing this we can avoid this
    75   // for the list's elements. By exposing this we can avoid this
    88   // iteration if the printer is not active.
    76   // iteration if the printer is not active.
    89   const bool is_active() { return _active; }
    77   const bool is_active() { return log_is_enabled(Trace, gc, region); }
    90 
       
    91   // Have to set this explicitly as we have to do this during the
       
    92   // heap's initialize() method, not in the constructor.
       
    93   void set_active(bool active) { _active = active; }
       
    94 
    78 
    95   // The methods below are convenient wrappers for the print() methods.
    79   // The methods below are convenient wrappers for the print() methods.
    96 
    80 
    97   void alloc(HeapRegion* hr, RegionType type, bool force = false) {
    81   void alloc(HeapRegion* hr, RegionType type, bool force = false) {
    98     if (is_active()) {
    82     if (is_active()) {
   153   void uncommit(HeapWord* bottom, HeapWord* end) {
   137   void uncommit(HeapWord* bottom, HeapWord* end) {
   154     if (is_active()) {
   138     if (is_active()) {
   155       print(Uncommit, bottom, end);
   139       print(Uncommit, bottom, end);
   156     }
   140     }
   157   }
   141   }
   158 
       
   159   void start_gc(bool full, size_t gc_num) {
       
   160     if (is_active()) {
       
   161       if (!full) {
       
   162         print(StartGC, gc_num);
       
   163       } else {
       
   164         print(StartFullGC, gc_num);
       
   165       }
       
   166     }
       
   167   }
       
   168 
       
   169   void end_gc(bool full, size_t gc_num) {
       
   170     if (is_active()) {
       
   171       if (!full) {
       
   172         print(EndGC, gc_num);
       
   173       } else {
       
   174         print(EndFullGC, gc_num);
       
   175       }
       
   176     }
       
   177   }
       
   178 
       
   179   G1HRPrinter() : _active(false) { }
       
   180 };
   142 };
   181 
   143 
   182 #endif // SHARE_VM_GC_G1_G1HRPRINTER_HPP
   144 #endif // SHARE_VM_GC_G1_G1HRPRINTER_HPP