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 #include "utilities/macros.hpp" 36 37 GCName GCConfiguration::young_collector() const { 38 if (UseG1GC) { 39 return G1New; 40 } 41 42 if (UseParallelGC) { 43 return ParallelScavenge; 44 } 45 46 if (UseShenandoahGC) { 47 #if INCLUDE_SHENANDOAHGC 48 if (strcmp(ShenandoahGCMode, "generational") == 0) { 49 return Shenandoah; 50 } 51 #endif 52 return NA; 53 } 54 55 if (UseZGC) { 56 if (ZGenerational) { 57 return ZMinor; 58 } else { 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 (UseShenandoahGC) { 75 #if INCLUDE_SHENANDOAHGC 76 if (strcmp(ShenandoahGCMode, "generational") == 0) { 77 return Shenandoah; 78 } 79 #endif 80 return NA; 81 } 82 83 if (UseZGC) { 84 if (ZGenerational) { 85 return ZMajor; 86 } else { 87 return Z; 88 } 89 } 90 return SerialOld; 91 } 92 93 uint GCConfiguration::num_parallel_gc_threads() const { 94 return ParallelGCThreads; 95 } 96 97 uint GCConfiguration::num_concurrent_gc_threads() const { 98 return ConcGCThreads; 99 } 100 101 bool GCConfiguration::uses_dynamic_gc_threads() const { 102 return UseDynamicNumberOfGCThreads; 103 } 104 105 bool GCConfiguration::is_explicit_gc_concurrent() const { 106 return ExplicitGCInvokesConcurrent; 107 } 108 109 bool GCConfiguration::is_explicit_gc_disabled() const { 110 return DisableExplicitGC; 111 } 112 113 bool GCConfiguration::has_pause_target_default_value() const { 114 return FLAG_IS_DEFAULT(MaxGCPauseMillis); 115 } 116 117 uintx GCConfiguration::pause_target() const { 118 return MaxGCPauseMillis; 119 } 120 121 uintx GCConfiguration::gc_time_ratio() const { 122 return GCTimeRatio; 123 } 124 125 bool GCTLABConfiguration::uses_tlabs() const { 126 return UseTLAB; 127 } 128 129 size_t GCTLABConfiguration::min_tlab_size() const { 130 return MinTLABSize; 131 } 132 133 uint GCTLABConfiguration::tlab_refill_waste_limit() const { 134 return TLABRefillWasteFraction; 135 } 136 137 intx GCSurvivorConfiguration::max_tenuring_threshold() const { 138 return MaxTenuringThreshold; 139 } 140 141 intx GCSurvivorConfiguration::initial_tenuring_threshold() const { 142 return InitialTenuringThreshold; 143 } 144 145 size_t GCHeapConfiguration::max_size() const { 146 return MaxHeapSize; 147 } 148 149 size_t GCHeapConfiguration::min_size() const { 150 return MinHeapSize; 151 } 152 153 size_t GCHeapConfiguration::initial_size() const { 154 return InitialHeapSize; 155 } 156 157 bool GCHeapConfiguration::uses_compressed_oops() const { 158 return UseCompressedOops; 159 } 160 161 CompressedOops::Mode GCHeapConfiguration::narrow_oop_mode() const { 162 return CompressedOops::mode(); 163 } 164 165 uint GCHeapConfiguration::object_alignment_in_bytes() const { 166 return ObjectAlignmentInBytes; 167 } 168 169 int GCHeapConfiguration::heap_address_size_in_bits() const { 170 return BitsPerHeapOop; 171 } 172 173 bool GCYoungGenerationConfiguration::has_max_size_default_value() const { 174 return FLAG_IS_DEFAULT(MaxNewSize); 175 } 176 177 uintx GCYoungGenerationConfiguration::max_size() const { 178 return MaxNewSize; 179 } 180 181 uintx GCYoungGenerationConfiguration::min_size() const { 182 return NewSize; 183 } 184 185 intx GCYoungGenerationConfiguration::new_ratio() const { 186 return NewRatio; 187 }