< prev index next >

src/hotspot/share/gc/shared/gcConfig.cpp

Print this page

        

@@ -36,13 +36,14 @@
 
 struct SupportedGC {
   bool&               _flag;
   CollectedHeap::Name _name;
   GCArguments&        _arguments;
+  const char*         _hs_err_name;
 
-  SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments) :
-      _flag(flag), _name(name), _arguments(arguments) {}
+  SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) :
+      _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {}
 };
 
 static SerialArguments   serialArguments;
 #if INCLUDE_ALL_GCS
 static ParallelArguments parallelArguments;

@@ -51,16 +52,16 @@
 #endif // INCLUDE_ALL_GCS
 
 // Table of supported GCs, for translating between command
 // line flag, CollectedHeap::Name and GCArguments instance.
 static const SupportedGC SupportedGCs[] = {
-  SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments),
+  SupportedGC(UseSerialGC,        CollectedHeap::Serial,   serialArguments,   "serialgc"  ),
 #if INCLUDE_ALL_GCS
-  SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments),
-  SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments),
-  SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments),
-  SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments),
+  SupportedGC(UseParallelGC,      CollectedHeap::Parallel, parallelArguments, "parallelgc"),
+  SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments, "parallelgc"),
+  SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments,      "cmsgc"     ),
+  SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments,       "g1gc"      ),
 #endif // INCLUDE_ALL_GCS
 };
 
 GCArguments* GCConfig::_arguments = NULL;
 bool GCConfig::_gc_selected_ergonomically = false;

@@ -170,9 +171,23 @@
 
 bool GCConfig::is_gc_selected_ergonomically() {
   return _gc_selected_ergonomically;
 }
 
+const char* GCConfig::hs_err_name() {
+  if (is_exactly_one_gc_selected()) {
+    // Exacly one GC selected
+    for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
+      if (SupportedGCs[i]._flag) {
+        return SupportedGCs[i]._hs_err_name;
+      }
+    }
+  }
+
+  // Zero or more than one GC selected
+  return "<unknown gc>";
+}
+
 GCArguments* GCConfig::arguments() {
   assert(_arguments != NULL, "Not initialized");
   return _arguments;
 }
< prev index next >