21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/serial/serialArguments.hpp" 27 #include "gc/shared/gcConfig.hpp" 28 #include "runtime/java.hpp" 29 #include "runtime/os.hpp" 30 #include "utilities/macros.hpp" 31 #if INCLUDE_ALL_GCS 32 #include "gc/parallel/parallelArguments.hpp" 33 #include "gc/cms/cmsArguments.hpp" 34 #include "gc/g1/g1Arguments.hpp" 35 #endif // INCLUDE_ALL_GCS 36 37 struct SupportedGC { 38 bool& _flag; 39 CollectedHeap::Name _name; 40 GCArguments& _arguments; 41 42 SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments) : 43 _flag(flag), _name(name), _arguments(arguments) {} 44 }; 45 46 static SerialArguments serialArguments; 47 #if INCLUDE_ALL_GCS 48 static ParallelArguments parallelArguments; 49 static CMSArguments cmsArguments; 50 static G1Arguments g1Arguments; 51 #endif // INCLUDE_ALL_GCS 52 53 // Table of supported GCs, for translating between command 54 // line flag, CollectedHeap::Name and GCArguments instance. 55 static const SupportedGC SupportedGCs[] = { 56 SupportedGC(UseSerialGC, CollectedHeap::Serial, serialArguments), 57 #if INCLUDE_ALL_GCS 58 SupportedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments), 59 SupportedGC(UseParallelOldGC, CollectedHeap::Parallel, parallelArguments), 60 SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS, cmsArguments), 61 SupportedGC(UseG1GC, CollectedHeap::G1, g1Arguments), 62 #endif // INCLUDE_ALL_GCS 63 }; 64 65 GCArguments* GCConfig::_arguments = NULL; 66 bool GCConfig::_gc_selected_ergonomically = false; 67 68 void GCConfig::select_gc_ergonomically() { 69 #if INCLUDE_ALL_GCS 70 if (os::is_server_class_machine()) { 71 FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); 72 } else { 73 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); 74 } 75 #else 76 UNSUPPORTED_OPTION(UseG1GC); 77 UNSUPPORTED_OPTION(UseParallelGC); 78 UNSUPPORTED_OPTION(UseParallelOldGC); 79 UNSUPPORTED_OPTION(UseConcMarkSweepGC); 80 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); 81 #endif // INCLUDE_ALL_GCS 153 } 154 155 // Not supported 156 return false; 157 } 158 159 bool GCConfig::is_gc_selected(CollectedHeap::Name name) { 160 for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) { 161 if (SupportedGCs[i]._name == name && SupportedGCs[i]._flag) { 162 // Selected 163 return true; 164 } 165 } 166 167 // Not selected 168 return false; 169 } 170 171 bool GCConfig::is_gc_selected_ergonomically() { 172 return _gc_selected_ergonomically; 173 } 174 175 GCArguments* GCConfig::arguments() { 176 assert(_arguments != NULL, "Not initialized"); 177 return _arguments; 178 } | 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/serial/serialArguments.hpp" 27 #include "gc/shared/gcConfig.hpp" 28 #include "runtime/java.hpp" 29 #include "runtime/os.hpp" 30 #include "utilities/macros.hpp" 31 #if INCLUDE_ALL_GCS 32 #include "gc/parallel/parallelArguments.hpp" 33 #include "gc/cms/cmsArguments.hpp" 34 #include "gc/g1/g1Arguments.hpp" 35 #endif // INCLUDE_ALL_GCS 36 37 struct SupportedGC { 38 bool& _flag; 39 CollectedHeap::Name _name; 40 GCArguments& _arguments; 41 const char* _hs_err_name; 42 43 SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) : 44 _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {} 45 }; 46 47 static SerialArguments serialArguments; 48 #if INCLUDE_ALL_GCS 49 static ParallelArguments parallelArguments; 50 static CMSArguments cmsArguments; 51 static G1Arguments g1Arguments; 52 #endif // INCLUDE_ALL_GCS 53 54 // Table of supported GCs, for translating between command 55 // line flag, CollectedHeap::Name and GCArguments instance. 56 static const SupportedGC SupportedGCs[] = { 57 SupportedGC(UseSerialGC, CollectedHeap::Serial, serialArguments, "serialgc" ), 58 #if INCLUDE_ALL_GCS 59 SupportedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments, "parallelgc"), 60 SupportedGC(UseParallelOldGC, CollectedHeap::Parallel, parallelArguments, "parallelgc"), 61 SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS, cmsArguments, "cmsgc" ), 62 SupportedGC(UseG1GC, CollectedHeap::G1, g1Arguments, "g1gc" ), 63 #endif // INCLUDE_ALL_GCS 64 }; 65 66 GCArguments* GCConfig::_arguments = NULL; 67 bool GCConfig::_gc_selected_ergonomically = false; 68 69 void GCConfig::select_gc_ergonomically() { 70 #if INCLUDE_ALL_GCS 71 if (os::is_server_class_machine()) { 72 FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); 73 } else { 74 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); 75 } 76 #else 77 UNSUPPORTED_OPTION(UseG1GC); 78 UNSUPPORTED_OPTION(UseParallelGC); 79 UNSUPPORTED_OPTION(UseParallelOldGC); 80 UNSUPPORTED_OPTION(UseConcMarkSweepGC); 81 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); 82 #endif // INCLUDE_ALL_GCS 154 } 155 156 // Not supported 157 return false; 158 } 159 160 bool GCConfig::is_gc_selected(CollectedHeap::Name name) { 161 for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) { 162 if (SupportedGCs[i]._name == name && SupportedGCs[i]._flag) { 163 // Selected 164 return true; 165 } 166 } 167 168 // Not selected 169 return false; 170 } 171 172 bool GCConfig::is_gc_selected_ergonomically() { 173 return _gc_selected_ergonomically; 174 } 175 176 const char* GCConfig::hs_err_name() { 177 if (is_exactly_one_gc_selected()) { 178 // Exacly one GC selected 179 for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) { 180 if (SupportedGCs[i]._flag) { 181 return SupportedGCs[i]._hs_err_name; 182 } 183 } 184 } 185 186 // Zero or more than one GC selected 187 return "<unknown gc>"; 188 } 189 190 GCArguments* GCConfig::arguments() { 191 assert(_arguments != NULL, "Not initialized"); 192 return _arguments; 193 } |