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_interface/collectedHeap.hpp"
  27 #include "gc_implementation/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   return DefNew;
  47 }
  48 
  49 GCName GCConfiguration::old_collector() const {
  50   if (UseG1GC) {
  51     return G1Old;
  52   }
  53 
  54   if (UseConcMarkSweepGC) {
  55     return ConcurrentMarkSweep;
  56   }
  57 
  58   if (UseParallelOldGC) {
  59     return ParallelOld;
  60   }
  61 
  62   return SerialOld;
  63 }
  64 
  65 uint GCConfiguration::num_parallel_gc_threads() const {
  66   return ParallelGCThreads;
  67 }
  68 
  69 uint GCConfiguration::num_concurrent_gc_threads() const {
  70   return ConcGCThreads;
  71 }
  72 
  73 bool GCConfiguration::uses_dynamic_gc_threads() const {
  74   return UseDynamicNumberOfGCThreads;
  75 }
  76 
  77 bool GCConfiguration::is_explicit_gc_concurrent() const {
  78   return ExplicitGCInvokesConcurrent;
  79 }
  80 
  81 bool GCConfiguration::is_explicit_gc_disabled() const {
  82   return DisableExplicitGC;
  83 }
  84 
  85 bool GCConfiguration::has_pause_target_default_value() const {
  86   return FLAG_IS_DEFAULT(MaxGCPauseMillis);
  87 }
  88 
  89 uintx GCConfiguration::pause_target() const {
  90   return MaxGCPauseMillis;
  91 }
  92 
  93 uintx GCConfiguration::gc_time_ratio() const {
  94   return GCTimeRatio;
  95 }
  96 
  97 bool GCTLABConfiguration::uses_tlabs() const {
  98   return UseTLAB;
  99 }
 100 
 101 size_t GCTLABConfiguration::min_tlab_size() const {
 102   return MinTLABSize;
 103 }
 104 
 105 uint GCTLABConfiguration::tlab_refill_waste_limit() const {
 106   return TLABRefillWasteFraction;
 107 }
 108 
 109 intx GCSurvivorConfiguration::max_tenuring_threshold() const {
 110   return MaxTenuringThreshold;
 111 }
 112 
 113 intx GCSurvivorConfiguration::initial_tenuring_threshold() const {
 114   return InitialTenuringThreshold;
 115 }
 116 
 117 size_t GCHeapConfiguration::max_size() const {
 118   return MaxHeapSize;
 119 }
 120 
 121 size_t GCHeapConfiguration::min_size() const {
 122   return Arguments::min_heap_size();
 123 }
 124 
 125 size_t GCHeapConfiguration::initial_size() const {
 126   return InitialHeapSize;
 127 }
 128 
 129 bool GCHeapConfiguration::uses_compressed_oops() const {
 130   return UseCompressedOops;
 131 }
 132 
 133 Universe::NARROW_OOP_MODE GCHeapConfiguration::narrow_oop_mode() const {
 134   return Universe::narrow_oop_mode();
 135 }
 136 
 137 uint GCHeapConfiguration::object_alignment_in_bytes() const {
 138   return ObjectAlignmentInBytes;
 139 }
 140 
 141 int GCHeapConfiguration::heap_address_size_in_bits() const {
 142   return BitsPerHeapOop;
 143 }
 144 
 145 bool GCYoungGenerationConfiguration::has_max_size_default_value() const {
 146   return FLAG_IS_DEFAULT(MaxNewSize);
 147 }
 148 
 149 uintx GCYoungGenerationConfiguration::max_size() const {
 150   return MaxNewSize;
 151 }
 152 
 153 uintx GCYoungGenerationConfiguration::min_size() const {
 154   return NewSize;
 155 }
 156 
 157 intx GCYoungGenerationConfiguration::new_ratio() const {
 158   return NewRatio;
 159 }