src/hotspot/share/gc/g1/g1HRPrinter.hpp
changeset 47216 71c04702a3d5
parent 35079 edab77f91231
child 49392 2956d0ece7a9
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 2011, 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_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 
       
    36 private:
       
    37 
       
    38   // Print an action event.
       
    39   static void print(const char* action, HeapRegion* hr) {
       
    40     log_trace(gc, region)("G1HR %s(%s) [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT "]",
       
    41                           action, hr->get_type_str(), p2i(hr->bottom()), p2i(hr->top()), p2i(hr->end()));
       
    42   }
       
    43 
       
    44 public:
       
    45   // In some places we iterate over a list in order to generate output
       
    46   // for the list's elements. By exposing this we can avoid this
       
    47   // iteration if the printer is not active.
       
    48   const bool is_active() { return log_is_enabled(Trace, gc, region); }
       
    49 
       
    50   // The methods below are convenient wrappers for the print() method.
       
    51 
       
    52   void alloc(HeapRegion* hr, bool force = false) {
       
    53     if (is_active()) {
       
    54       print((force) ? "ALLOC-FORCE" : "ALLOC", hr);
       
    55     }
       
    56   }
       
    57 
       
    58   void retire(HeapRegion* hr) {
       
    59     if (is_active()) {
       
    60       if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
       
    61         print("RETIRE", hr);
       
    62       }
       
    63     }
       
    64   }
       
    65 
       
    66   void reuse(HeapRegion* hr) {
       
    67     if (is_active()) {
       
    68       print("REUSE", hr);
       
    69     }
       
    70   }
       
    71 
       
    72   void cset(HeapRegion* hr) {
       
    73     if (is_active()) {
       
    74       print("CSET", hr);
       
    75     }
       
    76   }
       
    77 
       
    78   void evac_failure(HeapRegion* hr) {
       
    79     if (is_active()) {
       
    80       print("EVAC-FAILURE", hr);
       
    81     }
       
    82   }
       
    83 
       
    84   void cleanup(HeapRegion* hr) {
       
    85     if (is_active()) {
       
    86       print("CLEANUP", hr);
       
    87     }
       
    88   }
       
    89 
       
    90   void post_compaction(HeapRegion* hr) {
       
    91     if (is_active()) {
       
    92       print("POST-COMPACTION", hr);
       
    93     }
       
    94   }
       
    95 
       
    96   void commit(HeapRegion* hr) {
       
    97     if (is_active()) {
       
    98       print("COMMIT", hr);
       
    99     }
       
   100   }
       
   101 
       
   102   void uncommit(HeapRegion* hr) {
       
   103     if (is_active()) {
       
   104       print("UNCOMMIT", hr);
       
   105     }
       
   106   }
       
   107 };
       
   108 
       
   109 #endif // SHARE_VM_GC_G1_G1HRPRINTER_HPP