< prev index next >

src/share/vm/gc/g1/g1HRPrinter.hpp

Print this page




   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_G1_G1HRPRINTER_HPP
  26 #define SHARE_VM_GC_G1_G1HRPRINTER_HPP
  27 
  28 #include "gc/g1/heapRegion.hpp"

  29 #include "memory/allocation.hpp"
  30 
  31 #define SKIP_RETIRED_FULL_REGIONS 1
  32 
  33 class G1HRPrinter VALUE_OBJ_CLASS_SPEC {
  34 public:
  35   typedef enum {
  36     Alloc,
  37     AllocForce,
  38     Retire,
  39     Reuse,
  40     CSet,
  41     EvacFailure,
  42     Cleanup,
  43     PostCompaction,
  44     Commit,
  45     Uncommit
  46   } ActionType;
  47 
  48   typedef enum {
  49     Unset,
  50     Eden,
  51     Survivor,
  52     Old,
  53     SingleHumongous,
  54     StartsHumongous,
  55     ContinuesHumongous,
  56     Archive
  57   } RegionType;
  58 
  59   typedef enum {
  60     StartGC,
  61     EndGC,
  62     StartFullGC,
  63     EndFullGC
  64   } PhaseType;
  65 
  66 private:
  67   bool _active;
  68 
  69   static const char* action_name(ActionType action);
  70   static const char* region_type_name(RegionType type);
  71   static const char* phase_name(PhaseType phase);
  72 
  73   // Print an action event. This version is used in most scenarios and
  74   // only prints the region's bottom. The parameters type and top are
  75   // optional (the "not set" values are Unset and NULL).
  76   static void print(ActionType action, RegionType type,
  77                     HeapRegion* hr, HeapWord* top);
  78 
  79   // Print an action event. This version prints both the region's
  80   // bottom and end. Used for Commit / Uncommit events.
  81   static void print(ActionType action, HeapWord* bottom, HeapWord* end);
  82 
  83   // Print a phase event.
  84   static void print(PhaseType phase, size_t phase_num);
  85 
  86 public:
  87   // In some places we iterate over a list in order to generate output
  88   // for the list's elements. By exposing this we can avoid this
  89   // iteration if the printer is not active.
  90   const bool is_active() { return _active; }
  91 
  92   // Have to set this explicitly as we have to do this during the
  93   // heap's initialize() method, not in the constructor.
  94   void set_active(bool active) { _active = active; }
  95 
  96   // The methods below are convenient wrappers for the print() methods.
  97 
  98   void alloc(HeapRegion* hr, RegionType type, bool force = false) {
  99     if (is_active()) {
 100       print((!force) ? Alloc : AllocForce, type, hr, NULL);
 101     }
 102   }
 103 
 104   void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {
 105     if (is_active()) {
 106       print(Alloc, type, hr, top);
 107     }
 108   }
 109 
 110   void retire(HeapRegion* hr) {
 111     if (is_active()) {
 112       if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
 113         print(Retire, Unset, hr, hr->top());
 114       }


 139     }
 140   }
 141 
 142   void post_compaction(HeapRegion* hr, RegionType type) {
 143     if (is_active()) {
 144       print(PostCompaction, type, hr, hr->top());
 145     }
 146   }
 147 
 148   void commit(HeapWord* bottom, HeapWord* end) {
 149     if (is_active()) {
 150       print(Commit, bottom, end);
 151     }
 152   }
 153 
 154   void uncommit(HeapWord* bottom, HeapWord* end) {
 155     if (is_active()) {
 156       print(Uncommit, bottom, end);
 157     }
 158   }
 159 
 160   void start_gc(bool full, size_t gc_num) {
 161     if (is_active()) {
 162       if (!full) {
 163         print(StartGC, gc_num);
 164       } else {
 165         print(StartFullGC, gc_num);
 166       }
 167     }
 168   }
 169 
 170   void end_gc(bool full, size_t gc_num) {
 171     if (is_active()) {
 172       if (!full) {
 173         print(EndGC, gc_num);
 174       } else {
 175         print(EndFullGC, gc_num);
 176       }
 177     }
 178   }
 179 
 180   G1HRPrinter() : _active(false) { }
 181 };
 182 
 183 #endif // SHARE_VM_GC_G1_G1HRPRINTER_HPP


   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_G1_G1HRPRINTER_HPP
  26 #define SHARE_VM_GC_G1_G1HRPRINTER_HPP
  27 
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "logging/log.hpp"
  30 #include "memory/allocation.hpp"
  31 
  32 #define SKIP_RETIRED_FULL_REGIONS 1
  33 
  34 class G1HRPrinter VALUE_OBJ_CLASS_SPEC {
  35 public:
  36   typedef enum {
  37     Alloc,
  38     AllocForce,
  39     Retire,
  40     Reuse,
  41     CSet,
  42     EvacFailure,
  43     Cleanup,
  44     PostCompaction,
  45     Commit,
  46     Uncommit
  47   } ActionType;
  48 
  49   typedef enum {
  50     Unset,
  51     Eden,
  52     Survivor,
  53     Old,
  54     SingleHumongous,
  55     StartsHumongous,
  56     ContinuesHumongous,
  57     Archive
  58   } RegionType;
  59 







  60 private:


  61   static const char* action_name(ActionType action);
  62   static const char* region_type_name(RegionType type);

  63 
  64   // Print an action event. This version is used in most scenarios and
  65   // only prints the region's bottom. The parameters type and top are
  66   // optional (the "not set" values are Unset and NULL).
  67   static void print(ActionType action, RegionType type,
  68                     HeapRegion* hr, HeapWord* top);
  69 
  70   // Print an action event. This version prints both the region's
  71   // bottom and end. Used for Commit / Uncommit events.
  72   static void print(ActionType action, HeapWord* bottom, HeapWord* end);
  73 



  74 public:
  75   // In some places we iterate over a list in order to generate output
  76   // for the list's elements. By exposing this we can avoid this
  77   // iteration if the printer is not active.
  78   const bool is_active() { return log_is_enabled(Trace, gc, region); }




  79 
  80   // The methods below are convenient wrappers for the print() methods.
  81 
  82   void alloc(HeapRegion* hr, RegionType type, bool force = false) {
  83     if (is_active()) {
  84       print((!force) ? Alloc : AllocForce, type, hr, NULL);
  85     }
  86   }
  87 
  88   void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {
  89     if (is_active()) {
  90       print(Alloc, type, hr, top);
  91     }
  92   }
  93 
  94   void retire(HeapRegion* hr) {
  95     if (is_active()) {
  96       if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
  97         print(Retire, Unset, hr, hr->top());
  98       }


 123     }
 124   }
 125 
 126   void post_compaction(HeapRegion* hr, RegionType type) {
 127     if (is_active()) {
 128       print(PostCompaction, type, hr, hr->top());
 129     }
 130   }
 131 
 132   void commit(HeapWord* bottom, HeapWord* end) {
 133     if (is_active()) {
 134       print(Commit, bottom, end);
 135     }
 136   }
 137 
 138   void uncommit(HeapWord* bottom, HeapWord* end) {
 139     if (is_active()) {
 140       print(Uncommit, bottom, end);
 141     }
 142   }






















 143 };
 144 
 145 #endif // SHARE_VM_GC_G1_G1HRPRINTER_HPP
< prev index next >