1 /*
   2  * Copyright (c) 2016, Red Hat, Inc. and/or its affiliates.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP
  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP
  26 
  27 #include "runtime/globals.hpp"
  28 
  29 #define SHENANDOAH_FLAGS(develop, \
  30                          develop_pd, \
  31                          product, \
  32                          product_pd, \
  33                          diagnostic, \
  34                          experimental, \
  35                          notproduct, \
  36                          manageable, \
  37                          product_rw, \
  38                          range, \
  39                          constraint, \
  40                          writeable) \
  41                                                                             \
  42   product(bool, UseShenandoahGC, false,                                     \
  43           "Use the Shenandoah garbage collector")                           \
  44                                                                             \
  45   product(bool, ShenandoahOptimizeFinals, true,                             \
  46           "Optimize barriers on final and stable fields/arrays. "           \
  47           "Turn it off for maximum compatibility with reflection or JNI "   \
  48           "code that manipulates final fields."                             \
  49           "Defaults to true. ")                                             \
  50                                                                             \
  51   product(size_t, ShenandoahHeapRegionSize, 0,                              \
  52           "Size of the Shenandoah regions. "                                \
  53           "Determined automatically by default.")                           \
  54                                                                             \
  55   experimental(size_t, ShenandoahMinRegionSize, 256 * K,                    \
  56           "Minimum heap region size. ")                                     \
  57                                                                             \
  58   experimental(size_t, ShenandoahMaxRegionSize, 32 * M,                     \
  59           "Maximum heap region size. ")                                     \
  60                                                                             \
  61   experimental(size_t, ShenandoahTargetNumRegions, 2048,                    \
  62           "Target number of regions. We try to get around that many "       \
  63           "regions, based on ShenandoahMinRegionSize and "                  \
  64           "ShenandoahMaxRegionSizeSize. ")                                  \
  65                                                                             \
  66   product(bool, UseShenandoahMatrix, false,                                 \
  67           "Keep a connection matrix and use this to drive collection sets") \
  68                                                                             \
  69   product(bool, PrintShenandoahMatrix, false,                               \
  70           "Print connection matrix after marking")                          \
  71                                                                             \
  72   product(bool, VerifyShenandoahMatrix, false,                              \
  73           "Verify connection matrix after marking")                         \
  74                                                                             \
  75   product(ccstr, ShenandoahGCHeuristics, "adaptive",                        \
  76           "The heuristics to use in Shenandoah GC. Possible values: "       \
  77           "adaptive (adapt to maintain the given amount of free memory), "  \
  78           "dynamic (start concurrent GC based on amount of free memory, "   \
  79           "allocation threshold, etc), "                                    \
  80           "passive (do not start concurrent GC, wait for Full GC) "         \
  81           "aggressive (run concurrent GC continuously, evacuate everything), " \
  82           "partial (run partial collections along with concurrent GC). "    \
  83           "Defaults to adaptive")                                           \
  84                                                                             \
  85   experimental(ccstr, ShenandoahUpdateRefsEarly, "adaptive",                \
  86           "Run a separate concurrent reference updating phase after"        \
  87           "concurrent evacuation. Possible values: 'on', 'off', 'adaptive'")\
  88                                                                             \
  89   product(uintx, ShenandoahRefProcFrequency, 5,                             \
  90           "How often should (weak, soft, etc) references be processed. "    \
  91           "References get processed at every Nth GC cycle. "                \
  92           "Set to 0 to disable reference processing. "                      \
  93           "Defaults to process references every 5 cycles.")                 \
  94                                                                             \
  95   product(uintx, ShenandoahUnloadClassesFrequency, 5,                       \
  96           "How often should classes get unloaded. "                         \
  97           "Class unloading is performed at every Nth GC cycle. "            \
  98           "Set to 0 to disable concurrent class unloading. "                \
  99           "Defaults to unload classes every 5 cycles.")                     \
 100                                                                             \
 101   experimental(uintx, ShenandoahFullGCThreshold, 3,                         \
 102           "How many cycles in a row to do degenerated marking on "          \
 103           "cancelled GC before triggering a full-gc"                        \
 104           "Defaults to 3")                                                  \
 105           writeable(Always)                                                 \
 106                                                                             \
 107   product_rw(uintx, ShenandoahGarbageThreshold, 60,                         \
 108           "Sets the percentage of garbage a region need to contain before " \
 109           "it can be marked for collection. Applies to "                    \
 110           "Shenandoah GC dynamic Heuristic mode only (ignored otherwise). " \
 111           "Defaults to 60%.")                                               \
 112           range(0,100)                                                      \
 113                                                                             \
 114   product_rw(uintx, ShenandoahFreeThreshold, 10,                            \
 115           "Set the percentage of free heap at which a GC cycle is started. " \
 116           "Applies to Shenandoah GC dynamic Heuristic mode only "           \
 117           "(ignored otherwise). Defaults to 10%.")                          \
 118           range(0,100)                                                      \
 119                                                                             \
 120   product_rw(uintx, ShenandoahCSetThreshold, 40,                            \
 121           "Set the approximate target percentage of the heap for the"       \
 122           "collection set. Defaults to 40%.")                               \
 123           range(0,100)                                                      \
 124                                                                             \
 125   product_rw(uintx, ShenandoahAllocationThreshold, 0,                       \
 126           "Set percentage of memory allocated since last GC cycle before "  \
 127           "a new GC cycle is started. "                                     \
 128           "Applies to Shenandoah GC dynamic Heuristic mode only "           \
 129           "(ignored otherwise). Defauls to 0%.")                            \
 130           range(0,100)                                                      \
 131                                                                             \
 132   experimental(uintx, ShenandoahMergeUpdateRefsMinGap, 100,                 \
 133                "If GC is currently running in separate update-refs mode "   \
 134                "this numbers gives the threshold when to switch to "        \
 135                "merged update-refs mode. Number is percentage relative to"  \
 136                "duration(marking)+duration(update-refs).")                  \
 137           writeable(Always)                                                 \
 138                                                                             \
 139   experimental(uintx, ShenandoahMergeUpdateRefsMaxGap, 200,                 \
 140                "If GC is currently running in merged update-refs mode "     \
 141                "this numbers gives the threshold when to switch to "        \
 142                "separate update-refs mode. Number is percentage relative "  \
 143                "to duration(marking)+duration(update-refs).")               \
 144           writeable(Always)                                                 \
 145                                                                             \
 146   experimental(double, ShenandoahGCWorkerPerJavaThread, 0.5,                \
 147           "Set GC worker to Java thread ratio when "                        \
 148           "UseDynamicNumberOfGCThreads is enabled")                         \
 149           range(0.1,10.0)                                                   \
 150                                                                             \
 151   experimental(uintx, ShenandoahInitFreeThreshold, 30,                      \
 152                "Initial remaining free threshold for adaptive heuristics")  \
 153           range(0,100)                                                      \
 154                                                                             \
 155   experimental(uintx, ShenandoahMinFreeThreshold, 3,                        \
 156                "Minimum remaining free threshold for adaptive heuristics")  \
 157           range(0,100)                                                      \
 158                                                                             \
 159   experimental(uintx, ShenandoahMaxFreeThreshold, 70,                       \
 160                "Maximum remaining free threshold for adaptive heuristics")  \
 161           range(0,100)                                                      \
 162                                                                             \
 163   experimental(uintx, ShenandoahHappyCyclesThreshold, 3,                    \
 164           "How many successful marking cycles before improving free "       \
 165                "threshold for adaptive heuristics")                    \
 166                                                                             \
 167   experimental(uintx, ShenandoahPartialInboundThreshold, 10,                \
 168           "Specifies how many inbound regions a region can have maximum "   \
 169           "to be considered for collection set in partial collections.")    \
 170           writeable(Always)                                                 \
 171                                                                             \
 172   experimental(uint, ShenandoahMarkLoopStride, 1000,                        \
 173           "How many items are processed during one marking step")           \
 174                                                                             \
 175   experimental(bool, ShenandoahConcurrentCodeRoots, true,                   \
 176           "Scan code roots concurrently, instead of during a pause")        \
 177                                                                             \
 178   experimental(bool, ShenandoahNoBarriersForConst, true,                    \
 179           "Constant oops don't need barriers")                              \
 180                                                                             \
 181   experimental(bool, ShenandoahDontIncreaseWBFreq, true,                    \
 182           "Common 2 WriteBarriers or WriteBarrier and a ReadBarrier only "  \
 183           "if the resulting WriteBarrier isn't executed more frequently")   \
 184                                                                             \
 185   experimental(bool, ShenandoahNoLivenessFullGC, true,                      \
 186           "Skip liveness counting for mark during full GC.")                \
 187                                                                             \
 188   experimental(bool, ShenandoahWriteBarrierToIR, true,                      \
 189           "Convert write barrier to IR instead of using assembly blob")     \
 190                                                                             \
 191   experimental(bool, ShenandoahWriteBarrierCsetTestInIR, true,              \
 192           "Perform cset test in IR rather than in the stub")                \
 193                                                                             \
 194   experimental(bool, ShenandoahLoopOptsAfterExpansion, true,                \
 195           "Attempt more loop opts after write barrier expansion")           \
 196                                                                             \
 197   experimental(bool, UseShenandoahOWST, true,                               \
 198           "Use Shenandoah work stealing termination protocol")              \
 199                                                                             \
 200   experimental(size_t, ShenandoahSATBBufferSize, 1 * K,                     \
 201           "Number of entries in an SATB log buffer.")                       \
 202           range(1, max_uintx)                                               \
 203                                                                             \
 204   experimental(int, ShenandoahRegionSamplingRate, 40,                       \
 205           "Sampling rate for heap region sampling. "                        \
 206           "Number of milliseconds between samples")                         \
 207            writeable(Always)                                                \
 208                                                                             \
 209   experimental(bool, ShenandoahRegionSampling, false,                       \
 210           "Turns on heap region sampling via JVMStat")                      \
 211            writeable(Always)                                                \
 212                                                                             \
 213   experimental(bool, ShenandoahReduceStoreValBarrier, false,                \
 214           "If true, only execute storeval barrier when updating "           \
 215           "references.")                                                    \
 216                                                                             \
 217   experimental(bool, ShenandoahFastSyncRoots, true,                         \
 218           "Enable fast synchronizer roots scanning")                        \
 219                                                                             \
 220   diagnostic(bool, ShenandoahSATBBarrier, true,                             \
 221           "Turn on/off SATB barriers in Shenandoah")                        \
 222                                                                             \
 223   diagnostic(bool, ShenandoahWriteBarrier, true,                            \
 224           "Turn on/off write barriers in Shenandoah")                       \
 225                                                                             \
 226   diagnostic(bool, ShenandoahReadBarrier, true,                             \
 227           "Turn on/off read barriers in Shenandoah")                        \
 228                                                                             \
 229   diagnostic(bool, ShenandoahCASBarrier, true,                              \
 230           "Turn on/off CAS barriers in Shenandoah")                         \
 231                                                                             \
 232   diagnostic(bool, ShenandoahAcmpBarrier, true,                             \
 233           "Turn on/off acmp barriers in Shenandoah")                        \
 234                                                                             \
 235   diagnostic(bool, ShenandoahCloneBarrier, true,                            \
 236           "Turn on/off clone barriers in Shenandoah")                       \
 237                                                                             \
 238   diagnostic(bool, ShenandoahStoreCheck, false,                             \
 239           "Emit additional code that checks objects are written to only"    \
 240           " in to-space")                                                   \
 241                                                                             \
 242   develop(bool, ShenandoahVerify, false,                                    \
 243           "Verify the  Shenandoah garbage collector")                       \
 244                                                                             \
 245   develop(bool, VerifyStrictOopOperations, false,                           \
 246           "Verify that == and != are not used on oops. Only in fastdebug")  \
 247                                                                             \
 248   develop(bool, ShenandoahVerifyOptoBarriers, false,                        \
 249           "Verify no missing barriers in c2")                               \
 250                                                                             \
 251   product(bool, ShenandoahAlwaysPreTouch, false,                            \
 252           "Pre-touch heap memory, overrides global AlwaysPreTouch")         \
 253                                                                             \
 254   experimental(intx, ShenandoahMarkScanPrefetch, 32,                        \
 255           "How many objects to prefetch ahead when traversing mark bitmaps." \
 256           "Set to 0 to disable prefetching.")                               \
 257           range(0, 256)                                                     \
 258                                                                             \
 259   experimental(intx, ShenandoahFullGCTries, 3,                              \
 260           "How many times to try to do Full GC on allocation failure."      \
 261           "Set to 0 to never try, and fail instead.")                       \
 262           range(0, 16)                                                      \
 263 
 264 
 265 SHENANDOAH_FLAGS(DECLARE_DEVELOPER_FLAG, \
 266                  DECLARE_PD_DEVELOPER_FLAG,     \
 267                  DECLARE_PRODUCT_FLAG,          \
 268                  DECLARE_PD_PRODUCT_FLAG,       \
 269                  DECLARE_DIAGNOSTIC_FLAG,       \
 270                  DECLARE_EXPERIMENTAL_FLAG,     \
 271                  DECLARE_NOTPRODUCT_FLAG,       \
 272                  DECLARE_MANAGEABLE_FLAG,       \
 273                  DECLARE_PRODUCT_RW_FLAG,       \
 274                  IGNORE_RANGE,                  \
 275                  IGNORE_CONSTRAINT, \
 276                  IGNORE_WRITEABLE)
 277 
 278 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP