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