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     return ZMinor;
 47   }
 48 
 49   if (UseShenandoahGC) {
 50 #if INCLUDE_SHENANDOAHGC
 51     if (ShenandoahCardBarrier) {
 52       return ShenandoahYoung;
 53     }
 54 #endif
 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 ZMajor;
 72   }
 73 
 74   if (UseShenandoahGC) {
 75 #if INCLUDE_SHENANDOAHGC
 76     if (ShenandoahCardBarrier) {
 77       return ShenandoahOld;
 78     }
 79 #endif
 80     return Shenandoah;
 81   }
 82 
 83   return SerialOld;
 84 }
 85 
 86 uint GCConfiguration::num_parallel_gc_threads() const {
 87   return ParallelGCThreads;
 88 }
 89 
 90 uint GCConfiguration::num_concurrent_gc_threads() const {
 91   return ConcGCThreads;
 92 }
 93 
 94 bool GCConfiguration::uses_dynamic_gc_threads() const {
 95   return UseDynamicNumberOfGCThreads;
 96 }
 97 
 98 bool GCConfiguration::is_explicit_gc_concurrent() const {
 99   return ExplicitGCInvokesConcurrent;
100 }
101 
102 bool GCConfiguration::is_explicit_gc_disabled() const {
103   return DisableExplicitGC;
104 }
105 
106 bool GCConfiguration::has_pause_target_default_value() const {
107   return FLAG_IS_DEFAULT(MaxGCPauseMillis);
108 }
109 
110 uintx GCConfiguration::pause_target() const {
111   return MaxGCPauseMillis;
112 }
113 
114 uintx GCConfiguration::gc_time_ratio() const {
115   return GCTimeRatio;
116 }
117 
118 bool GCTLABConfiguration::uses_tlabs() const {
119   return UseTLAB;
120 }
121 
122 size_t GCTLABConfiguration::min_tlab_size() const {
123   return MinTLABSize;
124 }
125 
126 uint GCTLABConfiguration::tlab_refill_waste_limit() const {
127   return TLABRefillWasteFraction;
128 }
129 
130 intx GCSurvivorConfiguration::max_tenuring_threshold() const {
131   return MaxTenuringThreshold;
132 }
133 
134 intx GCSurvivorConfiguration::initial_tenuring_threshold() const {
135   return InitialTenuringThreshold;
136 }
137 
138 size_t GCHeapConfiguration::max_size() const {
139   return MaxHeapSize;
140 }
141 
142 size_t GCHeapConfiguration::min_size() const {
143   return MinHeapSize;
144 }
145 
146 size_t GCHeapConfiguration::initial_size() const {
147   return InitialHeapSize;
148 }
149 
150 bool GCHeapConfiguration::uses_compressed_oops() const {
151   return UseCompressedOops;
152 }
153 
154 CompressedOops::Mode GCHeapConfiguration::narrow_oop_mode() const {
155   return CompressedOops::mode();
156 }
157 
158 uint GCHeapConfiguration::object_alignment_in_bytes() const {
159   return ObjectAlignmentInBytes;
160 }
161 
162 int GCHeapConfiguration::heap_address_size_in_bits() const {
163   return BitsPerHeapOop;
164 }
165 
166 bool GCYoungGenerationConfiguration::has_max_size_default_value() const {
167   return FLAG_IS_DEFAULT(MaxNewSize);
168 }
169 
170 uintx GCYoungGenerationConfiguration::max_size() const {
171   return MaxNewSize;
172 }
173 
174 uintx GCYoungGenerationConfiguration::min_size() const {
175   return NewSize;
176 }
177 
178 intx GCYoungGenerationConfiguration::new_ratio() const {
179   return NewRatio;
180 }