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

Sat, 06 Oct 2012 01:17:44 -0700

author
johnc
date
Sat, 06 Oct 2012 01:17:44 -0700
changeset 4173
8a5ea0a9ccc4
parent 0
f90c822e73f8
permissions
-rw-r--r--

7127708: G1: change task num types from int to uint in concurrent mark
Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich.
Reviewed-by: johnc
Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>

     1 /*
     2  * Copyright (c) 2011, 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  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
    28 #include "memory/allocation.hpp"
    29 #include "gc_implementation/g1/heapRegion.hpp"
    31 #define SKIP_RETIRED_FULL_REGIONS 1
    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;
    48   typedef enum {
    49     Unset,
    50     Eden,
    51     Survivor,
    52     Old,
    53     SingleHumongous,
    54     StartsHumongous,
    55     ContinuesHumongous
    56   } RegionType;
    58   typedef enum {
    59     StartGC,
    60     EndGC,
    61     StartFullGC,
    62     EndFullGC
    63   } PhaseType;
    65 private:
    66   bool _active;
    68   static const char* action_name(ActionType action);
    69   static const char* region_type_name(RegionType type);
    70   static const char* phase_name(PhaseType phase);
    72   // 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
    74   // optional (the "not set" values are Unset and NULL).
    75   static void print(ActionType action, RegionType type,
    76                     HeapRegion* hr, HeapWord* top);
    78   // Print an action event. This version prints both the region's
    79   // bottom and end. Used for Commit / Uncommit events.
    80   static void print(ActionType action, HeapWord* bottom, HeapWord* end);
    82   // Print a phase event.
    83   static void print(PhaseType phase, size_t phase_num);
    85 public:
    86   // 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
    88   // iteration if the printer is not active.
    89   const bool is_active() { return _active; }
    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; }
    95   // The methods below are convenient wrappers for the print() methods.
    97   void alloc(HeapRegion* hr, RegionType type, bool force = false) {
    98     if (is_active()) {
    99       print((!force) ? Alloc : AllocForce, type, hr, NULL);
   100     }
   101   }
   103   void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {
   104     if (is_active()) {
   105       print(Alloc, type, hr, top);
   106     }
   107   }
   109   void retire(HeapRegion* hr) {
   110     if (is_active()) {
   111       if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
   112         print(Retire, Unset, hr, hr->top());
   113       }
   114     }
   115   }
   117   void reuse(HeapRegion* hr) {
   118     if (is_active()) {
   119       print(Reuse, Unset, hr, NULL);
   120     }
   121   }
   123   void cset(HeapRegion* hr) {
   124     if (is_active()) {
   125       print(CSet, Unset, hr, NULL);
   126     }
   127   }
   129   void evac_failure(HeapRegion* hr) {
   130     if (is_active()) {
   131       print(EvacFailure, Unset, hr, NULL);
   132     }
   133   }
   135   void cleanup(HeapRegion* hr) {
   136     if (is_active()) {
   137       print(Cleanup, Unset, hr, NULL);
   138     }
   139   }
   141   void post_compaction(HeapRegion* hr, RegionType type) {
   142     if (is_active()) {
   143       print(PostCompaction, type, hr, hr->top());
   144     }
   145   }
   147   void commit(HeapWord* bottom, HeapWord* end) {
   148     if (is_active()) {
   149       print(Commit, bottom, end);
   150     }
   151   }
   153   void uncommit(HeapWord* bottom, HeapWord* end) {
   154     if (is_active()) {
   155       print(Uncommit, bottom, end);
   156     }
   157   }
   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   }
   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   }
   179   G1HRPrinter() : _active(false) { }
   180 };
   182 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP

mercurial