1 /*
   2  * Copyright (c) 2012, 2018, 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 #include "precompiled.hpp"
  25 
  26 #include "gc/shared/collectedHeap.hpp"
  27 #include "gc/shared/gcConfiguration.hpp"
  28 #include "memory/universe.hpp"
  29 #include "runtime/arguments.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "utilities/debug.hpp"
  32 
  33 GCName GCConfiguration::young_collector() const {
  34   if (UseG1GC) {
  35     return G1New;
  36   }
  37 
  38   if (UseParallelGC) {
  39     return ParallelScavenge;
  40   }
  41 
  42   if (UseConcMarkSweepGC) {
  43     return ParNew;
  44   }
  45 
  46   if (UseZGC) {
  47     return NA;
  48   }
  49 
  50   return DefNew;
  51 }
  52 
  53 GCName GCConfiguration::old_collector() const {
  54   if (UseG1GC) {
  55     return G1Old;
  56   }
  57 
  58   if (UseConcMarkSweepGC) {
  59     return ConcurrentMarkSweep;
  60   }
  61 
  62   if (UseParallelOldGC) {
  63     return ParallelOld;
  64   }
  65 
  66   if (UseZGC) {
  67     return Z;
  68   }
  69 
  70   return SerialOld;
  71 }
  72 
  73 uint GCConfiguration::num_parallel_gc_threads() const {
  74   return ParallelGCThreads;
  75 }
  76 
  77 uint GCConfiguration::num_concurrent_gc_threads() const {
  78   return ConcGCThreads;
  79 }
  80 
  81 bool GCConfiguration::uses_dynamic_gc_threads() const {
  82   return UseDynamicNumberOfGCThreads;
  83 }
  84 
  85 bool GCConfiguration::is_explicit_gc_concurrent() const {
  86   return ExplicitGCInvokesConcurrent;
  87 }
  88 
  89 bool GCConfiguration::is_explicit_gc_disabled() const {
  90   return DisableExplicitGC;
  91 }
  92 
  93 bool GCConfiguration::has_pause_target_default_value() const {
  94   return FLAG_IS_DEFAULT(MaxGCPauseMillis);
  95 }
  96 
  97 uintx GCConfiguration::pause_target() const {
  98   return MaxGCPauseMillis;
  99 }
 100 
 101 uintx GCConfiguration::gc_time_ratio() const {
 102   return GCTimeRatio;
 103 }
 104 
 105 bool GCTLABConfiguration::uses_tlabs() const {
 106   return UseTLAB;
 107 }
 108 
 109 size_t GCTLABConfiguration::min_tlab_size() const {
 110   return MinTLABSize;
 111 }
 112 
 113 uint GCTLABConfiguration::tlab_refill_waste_limit() const {
 114   return TLABRefillWasteFraction;
 115 }
 116 
 117 intx GCSurvivorConfiguration::max_tenuring_threshold() const {
 118   return MaxTenuringThreshold;
 119 }
 120 
 121 intx GCSurvivorConfiguration::initial_tenuring_threshold() const {
 122   return InitialTenuringThreshold;
 123 }
 124 
 125 size_t GCHeapConfiguration::max_size() const {
 126   return MaxHeapSize;
 127 }
 128 
 129 size_t GCHeapConfiguration::min_size() const {
 130   return Arguments::min_heap_size();
 131 }
 132 
 133 size_t GCHeapConfiguration::initial_size() const {
 134   return InitialHeapSize;
 135 }
 136 
 137 bool GCHeapConfiguration::uses_compressed_oops() const {
 138   return UseCompressedOops;
 139 }
 140 
 141 Universe::NARROW_OOP_MODE GCHeapConfiguration::narrow_oop_mode() const {
 142   return Universe::narrow_oop_mode();
 143 }
 144 
 145 uint GCHeapConfiguration::object_alignment_in_bytes() const {
 146   return ObjectAlignmentInBytes;
 147 }
 148 
 149 int GCHeapConfiguration::heap_address_size_in_bits() const {
 150   return BitsPerHeapOop;
 151 }
 152 
 153 bool GCYoungGenerationConfiguration::has_max_size_default_value() const {
 154   return FLAG_IS_DEFAULT(MaxNewSize);
 155 }
 156 
 157 uintx GCYoungGenerationConfiguration::max_size() const {
 158   return MaxNewSize;
 159 }
 160 
 161 uintx GCYoungGenerationConfiguration::min_size() const {
 162   return NewSize;
 163 }
 164 
 165 intx GCYoungGenerationConfiguration::new_ratio() const {
 166   return NewRatio;
 167 }