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

Thu, 22 Sep 2011 10:57:37 -0700

author
johnc
date
Thu, 22 Sep 2011 10:57:37 -0700
changeset 3175
4dfb2df418f2
parent 3126
f1b4e0e0bdad
child 3337
41406797186b
permissions
-rw-r--r--

6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp

tonyp@3114 1 /*
tonyp@3114 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
tonyp@3114 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tonyp@3114 4 *
tonyp@3114 5 * This code is free software; you can redistribute it and/or modify it
tonyp@3114 6 * under the terms of the GNU General Public License version 2 only, as
tonyp@3114 7 * published by the Free Software Foundation.
tonyp@3114 8 *
tonyp@3114 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tonyp@3114 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tonyp@3114 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tonyp@3114 12 * version 2 for more details (a copy is included in the LICENSE file that
tonyp@3114 13 * accompanied this code).
tonyp@3114 14 *
tonyp@3114 15 * You should have received a copy of the GNU General Public License version
tonyp@3114 16 * 2 along with this work; if not, write to the Free Software Foundation,
tonyp@3114 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tonyp@3114 18 *
tonyp@3114 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tonyp@3114 20 * or visit www.oracle.com if you need additional information or have any
tonyp@3114 21 * questions.
tonyp@3114 22 *
tonyp@3114 23 */
tonyp@3114 24
tonyp@3114 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
tonyp@3114 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
tonyp@3114 27
tonyp@3114 28 #include "memory/allocation.hpp"
tonyp@3114 29 #include "utilities/debug.hpp"
tonyp@3114 30
tonyp@3114 31 // The log of G1's heuristic decisions comprises of a series of
tonyp@3114 32 // records which have a similar format in order to maintain
tonyp@3114 33 // consistency across records and ultimately easier parsing of the
tonyp@3114 34 // output, if we ever choose to do that. Each record consists of:
tonyp@3114 35 // * A time stamp to be able to easily correlate each record with
tonyp@3114 36 // other events.
tonyp@3114 37 // * A unique string to allow us to easily identify such records.
tonyp@3114 38 // * The name of the heuristic the record corresponds to.
tonyp@3114 39 // * An action string which describes the action that G1 did or is
tonyp@3114 40 // about to do.
tonyp@3114 41 // * An optional reason string which describes the reason for the
tonyp@3114 42 // action.
tonyp@3114 43 // * An optional number of name/value pairs which contributed to the
tonyp@3114 44 // decision to take the action described in the record.
tonyp@3114 45 //
tonyp@3114 46 // Each record is associated with a "tag" which is the combination of
tonyp@3114 47 // the heuristic the record corresponds to, as well as the min level
tonyp@3114 48 // of verboseness at which the record should be printed. The tag is
tonyp@3114 49 // checked against the current settings to determine whether the record
tonyp@3114 50 // should be printed or not.
tonyp@3114 51
tonyp@3114 52 // The available verboseness levels.
tonyp@3114 53 typedef enum {
tonyp@3114 54 // Determine which part of the tag is occupied by the level.
tonyp@3114 55 ErgoLevelShift = 8,
tonyp@3114 56 ErgoLevelMask = ~((1 << ErgoLevelShift) - 1),
tonyp@3114 57
tonyp@3114 58 // ErgoLow is 0 so that we don't have to explicitly or a heuristic
tonyp@3114 59 // id with ErgoLow to keep its use simpler.
tonyp@3114 60 ErgoLow = 0,
tonyp@3126 61 ErgoHigh = 1 << ErgoLevelShift
tonyp@3114 62 } ErgoLevel;
tonyp@3114 63
tonyp@3114 64 // The available heuristics.
tonyp@3114 65 typedef enum {
tonyp@3114 66 // Determines which part of the tag is occupied by the heuristic id.
tonyp@3114 67 ErgoHeuristicMask = ~ErgoLevelMask,
tonyp@3114 68
tonyp@3114 69 ErgoHeapSizing = 0,
tonyp@3114 70 ErgoCSetConstruction,
tonyp@3114 71 ErgoConcCycles,
tonyp@3114 72 ErgoPartiallyYoungGCs,
tonyp@3114 73
tonyp@3114 74 ErgoHeuristicNum
tonyp@3114 75 } ErgoHeuristic;
tonyp@3114 76
tonyp@3114 77 class G1ErgoVerbose : AllStatic {
tonyp@3114 78 private:
tonyp@3114 79 // Determines the minimum verboseness level at which records will be
tonyp@3114 80 // printed.
tonyp@3114 81 static ErgoLevel _level;
tonyp@3114 82 // Determines which heuristics are currently enabled.
tonyp@3114 83 static bool _enabled[ErgoHeuristicNum];
tonyp@3114 84
tonyp@3114 85 static ErgoLevel extract_level(int tag) {
tonyp@3114 86 return (ErgoLevel) (tag & ErgoLevelMask);
tonyp@3114 87 }
tonyp@3114 88
tonyp@3114 89 static ErgoHeuristic extract_heuristic(int tag) {
tonyp@3114 90 return (ErgoHeuristic) (tag & ErgoHeuristicMask);
tonyp@3114 91 }
tonyp@3114 92
tonyp@3114 93 public:
tonyp@3114 94 // Needs to be explicitly called at GC initialization.
tonyp@3114 95 static void initialize();
tonyp@3114 96
tonyp@3114 97 static void set_level(ErgoLevel level);
tonyp@3114 98 static void set_enabled(ErgoHeuristic h, bool enabled);
tonyp@3114 99 // It is applied to all heuristics.
tonyp@3114 100 static void set_enabled(bool enabled);
tonyp@3114 101
tonyp@3114 102 static bool enabled(int tag) {
tonyp@3114 103 ErgoLevel level = extract_level(tag);
tonyp@3114 104 ErgoHeuristic n = extract_heuristic(tag);
tonyp@3114 105 return level <= _level && _enabled[n];
tonyp@3114 106 }
tonyp@3114 107
tonyp@3114 108 // Extract the heuristic id from the tag and return a string with
tonyp@3114 109 // its name.
tonyp@3114 110 static const char* to_string(int tag);
tonyp@3114 111 };
tonyp@3114 112
tonyp@3114 113 // The macros below generate the format string for values of different
tonyp@3114 114 // types and/or metrics.
tonyp@3114 115
tonyp@3114 116 // The reason for the action is optional and is handled specially: the
tonyp@3114 117 // reason string is concatenated here so it's not necessary to pass it
tonyp@3114 118 // as a parameter.
tonyp@3114 119 #define ergo_format_reason(_reason_) ", reason: " _reason_
tonyp@3114 120
tonyp@3114 121 // Single parameter format strings
tonyp@3114 122 #define ergo_format_str(_name_) ", " _name_ ": %s"
tonyp@3114 123 #define ergo_format_region(_name_) ", " _name_ ": "SIZE_FORMAT" regions"
tonyp@3114 124 #define ergo_format_byte(_name_) ", " _name_ ": "SIZE_FORMAT" bytes"
tonyp@3114 125 #define ergo_format_double(_name_) ", " _name_ ": %1.2f"
tonyp@3114 126 #define ergo_format_perc(_name_) ", " _name_ ": %1.2f %%"
tonyp@3114 127 #define ergo_format_ms(_name_) ", " _name_ ": %1.2f ms"
tonyp@3114 128
tonyp@3114 129 // Double parameter format strings
tonyp@3114 130 #define ergo_format_byte_perc(_name_) \
tonyp@3114 131 ", " _name_ ": "SIZE_FORMAT" bytes (%1.2f %%)"
tonyp@3114 132
tonyp@3114 133 // Generates the format string
tonyp@3114 134 #define ergo_format(_action_, _extra_format_) \
tonyp@3114 135 " %1.3f: [G1Ergonomics (%s) " _action_ _extra_format_ "]"
tonyp@3114 136
tonyp@3114 137 // Conditionally, prints an ergonomic decision record. _extra_format_
tonyp@3114 138 // is the format string for the optional items we'd like to print
tonyp@3114 139 // (i.e., the decision's reason and any associated values). This
tonyp@3114 140 // string should be built up using the ergo_*_format macros (see
tonyp@3114 141 // above) to ensure consistency.
tonyp@3114 142 //
tonyp@3114 143 // Since we cannot rely on the compiler supporting variable argument
tonyp@3114 144 // macros, this macro accepts a fixed number of arguments and passes
tonyp@3114 145 // them to the print method. For convenience, we have wrapper macros
tonyp@3114 146 // below which take a specific number of arguments and set the rest to
tonyp@3114 147 // a default value.
tonyp@3114 148 #define ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 149 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \
tonyp@3114 150 do { \
tonyp@3114 151 if (G1ErgoVerbose::enabled((_tag_))) { \
tonyp@3114 152 gclog_or_tty->print_cr(ergo_format(_action_, _extra_format_), \
tonyp@3114 153 os::elapsedTime(), \
tonyp@3114 154 G1ErgoVerbose::to_string((_tag_)), \
tonyp@3114 155 (_arg0_), (_arg1_), (_arg2_), \
tonyp@3114 156 (_arg3_), (_arg4_), (_arg5_)); \
tonyp@3114 157 } \
tonyp@3114 158 } while (0)
tonyp@3114 159
tonyp@3114 160
tonyp@3114 161 #define ergo_verbose(_tag_, _action_) \
tonyp@3114 162 ergo_verbose_common(_tag_, _action_, "", 0, 0, 0, 0, 0, 0)
tonyp@3114 163
tonyp@3114 164 #define ergo_verbose0(_tag_, _action_, _extra_format_) \
tonyp@3114 165 ergo_verbose_common(_tag_, _action_, _extra_format_, 0, 0, 0, 0, 0, 0)
tonyp@3114 166
tonyp@3114 167 #define ergo_verbose1(_tag_, _action_, _extra_format_, \
tonyp@3114 168 _arg0_) \
tonyp@3114 169 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 170 _arg0_, 0, 0, 0, 0, 0)
tonyp@3114 171
tonyp@3114 172 #define ergo_verbose2(_tag_, _action_, _extra_format_, \
tonyp@3114 173 _arg0_, _arg1_) \
tonyp@3114 174 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 175 _arg0_, _arg1_, 0, 0, 0, 0)
tonyp@3114 176
tonyp@3114 177 #define ergo_verbose3(_tag_, _action_, _extra_format_, \
tonyp@3114 178 _arg0_, _arg1_, _arg2_) \
tonyp@3114 179 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 180 _arg0_, _arg1_, _arg2_, 0, 0, 0)
tonyp@3114 181
tonyp@3114 182 #define ergo_verbose4(_tag_, _action_, _extra_format_, \
tonyp@3114 183 _arg0_, _arg1_, _arg2_, _arg3_) \
tonyp@3114 184 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 185 _arg0_, _arg1_, _arg2_, _arg3_, 0, 0)
tonyp@3114 186
tonyp@3114 187 #define ergo_verbose5(_tag_, _action_, _extra_format_, \
tonyp@3114 188 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_) \
tonyp@3114 189 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 190 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, 0)
tonyp@3114 191
tonyp@3114 192 #define ergo_verbose6(_tag_, _action_, _extra_format_, \
tonyp@3114 193 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \
tonyp@3114 194 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 195 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_)
tonyp@3114 196
tonyp@3114 197 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP

mercurial