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