< prev index next >

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

Print this page

        

@@ -22,33 +22,53 @@
  *
  */
 
 #include "precompiled.hpp"
 #include "gc/shared/gc.hpp"
+#include "gc/shared/gcFactory.hpp"
 #include "gc/serial/serialGC.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
+#include "runtime/java.hpp"
 #include "runtime/os.hpp"
 #include "utilities/macros.hpp"
 
 #if INCLUDE_ALL_GCS
 #include "gc/parallel/parallelGC.hpp"
 #include "gc/cms/cmsGC.hpp"
 #include "gc/g1/g1GC.hpp"
 #endif
 
-GC* GC::_gc = NULL;
+GC* GCFactory::_gc = NULL;
 
-bool GC::gc_selected() {
+GC* GCFactory::gc() {
+  assert(_gc != NULL, "GC not yet created");
+  return _gc;
+}
+
+bool GCFactory::is_initialized() {
+  return _gc != NULL;
+}
+
+bool GCFactory::gc_selected() {
 #if INCLUDE_ALL_GCS
   return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
 #else
   return UseSerialGC;
 #endif // INCLUDE_ALL_GCS
 }
 
-void GC::select_gc_ergonomically() {
+void GCFactory::select_gc() {
+  if (!gc_selected()) {
+    select_gc_ergonomically();
+    if (!gc_selected()) {
+      vm_exit_during_initialization("Garbage collector not selected (default collector explicitly disabled)", NULL);
+    }
+  }
+}
+
+void GCFactory::select_gc_ergonomically() {
 #if INCLUDE_ALL_GCS
   if (os::is_server_class_machine()) {
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
   } else {
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);

@@ -60,11 +80,11 @@
   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
 #endif // INCLUDE_ALL_GCS
 }
 
-void GC::initialize_flags_global() {
+void GCFactory::initialize_flags_global() {
 #if INCLUDE_ALL_GCS
   if (AssumeMP && !UseSerialGC) {
     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
       warning("If the number of processors is expected to increase from one, then"
               " you should configure the number of parallel GC threads appropriately"

@@ -82,11 +102,11 @@
     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
   }
 #endif // INCLUDE_ALL_GCS
 }
 
-jint GC::initialize() {
+jint GCFactory::initialize() {
   assert(_gc == NULL, "GC already created");
 
   select_gc();
 
 #if !INCLUDE_ALL_GCS
< prev index next >