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

changeset 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1HRPrinter.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,182 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
    1.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
    1.30 +
    1.31 +#include "memory/allocation.hpp"
    1.32 +#include "gc_implementation/g1/heapRegion.hpp"
    1.33 +
    1.34 +#define SKIP_RETIRED_FULL_REGIONS 1
    1.35 +
    1.36 +class G1HRPrinter VALUE_OBJ_CLASS_SPEC {
    1.37 +public:
    1.38 +  typedef enum {
    1.39 +    Alloc,
    1.40 +    AllocForce,
    1.41 +    Retire,
    1.42 +    Reuse,
    1.43 +    CSet,
    1.44 +    EvacFailure,
    1.45 +    Cleanup,
    1.46 +    PostCompaction,
    1.47 +    Commit,
    1.48 +    Uncommit
    1.49 +  } ActionType;
    1.50 +
    1.51 +  typedef enum {
    1.52 +    Unset,
    1.53 +    Eden,
    1.54 +    Survivor,
    1.55 +    Old,
    1.56 +    SingleHumongous,
    1.57 +    StartsHumongous,
    1.58 +    ContinuesHumongous
    1.59 +  } RegionType;
    1.60 +
    1.61 +  typedef enum {
    1.62 +    StartGC,
    1.63 +    EndGC,
    1.64 +    StartFullGC,
    1.65 +    EndFullGC
    1.66 +  } PhaseType;
    1.67 +
    1.68 +private:
    1.69 +  bool _active;
    1.70 +
    1.71 +  static const char* action_name(ActionType action);
    1.72 +  static const char* region_type_name(RegionType type);
    1.73 +  static const char* phase_name(PhaseType phase);
    1.74 +
    1.75 +  // Print an action event. This version is used in most scenarios and
    1.76 +  // only prints the region's bottom. The parameters type and top are
    1.77 +  // optional (the "not set" values are Unset and NULL).
    1.78 +  static void print(ActionType action, RegionType type,
    1.79 +                    HeapRegion* hr, HeapWord* top);
    1.80 +
    1.81 +  // Print an action event. This version prints both the region's
    1.82 +  // bottom and end. Used for Commit / Uncommit events.
    1.83 +  static void print(ActionType action, HeapWord* bottom, HeapWord* end);
    1.84 +
    1.85 +  // Print a phase event.
    1.86 +  static void print(PhaseType phase, size_t phase_num);
    1.87 +
    1.88 +public:
    1.89 +  // In some places we iterate over a list in order to generate output
    1.90 +  // for the list's elements. By exposing this we can avoid this
    1.91 +  // iteration if the printer is not active.
    1.92 +  const bool is_active() { return _active; }
    1.93 +
    1.94 +  // Have to set this explicitly as we have to do this during the
    1.95 +  // heap's initialize() method, not in the constructor.
    1.96 +  void set_active(bool active) { _active = active; }
    1.97 +
    1.98 +  // The methods below are convenient wrappers for the print() methods.
    1.99 +
   1.100 +  void alloc(HeapRegion* hr, RegionType type, bool force = false) {
   1.101 +    if (is_active()) {
   1.102 +      print((!force) ? Alloc : AllocForce, type, hr, NULL);
   1.103 +    }
   1.104 +  }
   1.105 +
   1.106 +  void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {
   1.107 +    if (is_active()) {
   1.108 +      print(Alloc, type, hr, top);
   1.109 +    }
   1.110 +  }
   1.111 +
   1.112 +  void retire(HeapRegion* hr) {
   1.113 +    if (is_active()) {
   1.114 +      if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
   1.115 +        print(Retire, Unset, hr, hr->top());
   1.116 +      }
   1.117 +    }
   1.118 +  }
   1.119 +
   1.120 +  void reuse(HeapRegion* hr) {
   1.121 +    if (is_active()) {
   1.122 +      print(Reuse, Unset, hr, NULL);
   1.123 +    }
   1.124 +  }
   1.125 +
   1.126 +  void cset(HeapRegion* hr) {
   1.127 +    if (is_active()) {
   1.128 +      print(CSet, Unset, hr, NULL);
   1.129 +    }
   1.130 +  }
   1.131 +
   1.132 +  void evac_failure(HeapRegion* hr) {
   1.133 +    if (is_active()) {
   1.134 +      print(EvacFailure, Unset, hr, NULL);
   1.135 +    }
   1.136 +  }
   1.137 +
   1.138 +  void cleanup(HeapRegion* hr) {
   1.139 +    if (is_active()) {
   1.140 +      print(Cleanup, Unset, hr, NULL);
   1.141 +    }
   1.142 +  }
   1.143 +
   1.144 +  void post_compaction(HeapRegion* hr, RegionType type) {
   1.145 +    if (is_active()) {
   1.146 +      print(PostCompaction, type, hr, hr->top());
   1.147 +    }
   1.148 +  }
   1.149 +
   1.150 +  void commit(HeapWord* bottom, HeapWord* end) {
   1.151 +    if (is_active()) {
   1.152 +      print(Commit, bottom, end);
   1.153 +    }
   1.154 +  }
   1.155 +
   1.156 +  void uncommit(HeapWord* bottom, HeapWord* end) {
   1.157 +    if (is_active()) {
   1.158 +      print(Uncommit, bottom, end);
   1.159 +    }
   1.160 +  }
   1.161 +
   1.162 +  void start_gc(bool full, size_t gc_num) {
   1.163 +    if (is_active()) {
   1.164 +      if (!full) {
   1.165 +        print(StartGC, gc_num);
   1.166 +      } else {
   1.167 +        print(StartFullGC, gc_num);
   1.168 +      }
   1.169 +    }
   1.170 +  }
   1.171 +
   1.172 +  void end_gc(bool full, size_t gc_num) {
   1.173 +    if (is_active()) {
   1.174 +      if (!full) {
   1.175 +        print(EndGC, gc_num);
   1.176 +      } else {
   1.177 +        print(EndFullGC, gc_num);
   1.178 +      }
   1.179 +    }
   1.180 +  }
   1.181 +
   1.182 +  G1HRPrinter() : _active(false) { }
   1.183 +};
   1.184 +
   1.185 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP

mercurial