--- old/src/hotspot/share/gc/cms/cmsGC.hpp 2017-10-17 23:16:51.402789803 +0200 +++ new/src/hotspot/share/gc/cms/cmsGC.hpp 2017-10-17 23:16:50.912788612 +0200 @@ -22,8 +22,8 @@ * */ -#ifndef SHARE_VM_GC_CMS_CMS_GC_HPP -#define SHARE_VM_GC_CMS_CMS_GC_HPP +#ifndef SHARE_GC_CMS_CMSGC_HPP +#define SHARE_GC_CMS_CMSGC_HPP #include "gc/shared/gc.hpp" @@ -36,4 +36,4 @@ virtual size_t conservative_max_heap_alignment(); }; -#endif // SHARE_VM_GC_CMS_CMS_GC_HPP +#endif // SHARE_GC_CMS_CMSGC_HPP --- old/src/hotspot/share/gc/g1/g1GC.hpp 2017-10-17 23:16:52.617792758 +0200 +++ new/src/hotspot/share/gc/g1/g1GC.hpp 2017-10-17 23:16:52.161791649 +0200 @@ -22,8 +22,8 @@ * */ -#ifndef SHARE_VM_GC_G1_G1_GC_HPP -#define SHARE_VM_GC_G1_G1_GC_HPP +#ifndef SHARE_GC_G1_G1GC_HPP +#define SHARE_GC_G1_G1GC_HPP #include "gc/shared/gc.hpp" @@ -33,4 +33,4 @@ virtual size_t conservative_max_heap_alignment(); }; -#endif // SHARE_VM_GC_G1_G1_GC_HPP +#endif // SHARE_GC_G1_G1GC_HPP --- old/src/hotspot/share/gc/parallel/parallelGC.hpp 2017-10-17 23:16:53.783795594 +0200 +++ new/src/hotspot/share/gc/parallel/parallelGC.hpp 2017-10-17 23:16:53.315794456 +0200 @@ -22,8 +22,8 @@ * */ -#ifndef SHARE_VM_GC_PARALLEL_PARALLEL_GC_HPP -#define SHARE_VM_GC_PARALLEL_PARALLEL_GC_HPP +#ifndef SHARE_GC_PARALLEL_PARALLELGC_HPP +#define SHARE_GC_PARALLEL_PARALLELGC_HPP #include "gc/shared/gc.hpp" @@ -33,4 +33,4 @@ virtual size_t conservative_max_heap_alignment(); }; -#endif // SHARE_VM_GC_CMS_PARALLEL_GC_HPP +#endif // SHARE_GC_CMS_PARALLELGC_HPP --- old/src/hotspot/share/gc/serial/serialGC.hpp 2017-10-17 23:16:54.979798502 +0200 +++ new/src/hotspot/share/gc/serial/serialGC.hpp 2017-10-17 23:16:54.549797457 +0200 @@ -22,8 +22,8 @@ * */ -#ifndef SHARE_VM_GC_SERIAL_SERIAL_GC_HPP -#define SHARE_VM_GC_SERIAL_SERIAL_GC_HPP +#ifndef SHARE_GC_SERIAL_SERIALGC_HPP +#define SHARE_GC_SERIAL_SERIALGC_HPP #include "gc/shared/gc.hpp" @@ -32,4 +32,4 @@ virtual size_t conservative_max_heap_alignment(); }; -#endif // SHARE_VM_GC_SERIAL_SERIAL_GC_HPP +#endif // SHARE_GC_SERIAL_SERIALGC_HPP --- old/src/hotspot/share/gc/shared/gc.hpp 2017-10-17 23:16:56.118801272 +0200 +++ new/src/hotspot/share/gc/shared/gc.hpp 2017-10-17 23:16:55.644800119 +0200 @@ -22,28 +22,17 @@ * */ -#ifndef SHARE_VM_GC_SHARED_GC_HPP -#define SHARE_VM_GC_SHARED_GC_HPP +#ifndef SHARE_GC_SHARED_GC_HPP +#define SHARE_GC_SHARED_GC_HPP #include "memory/allocation.hpp" class GC : public CHeapObj { -private: - static GC* _gc; - - static void select_gc(); - static void select_gc_ergonomically(); - static bool gc_selected(); - public: - static jint initialize(); - static bool is_initialized(); - static GC* gc(); - - static void initialize_flags_global(); - - virtual void initialize_flags(); + virtual void initialize_flags() { + // Default does nothing. + } virtual size_t conservative_max_heap_alignment() = 0; }; -#endif // SHARE_VM_GC_SHARED_GC_HPP +#endif // SHARE_GC_SHARED_GC_HPP --- old/src/hotspot/share/runtime/arguments.cpp 2017-10-17 23:16:57.236803991 +0200 +++ new/src/hotspot/share/runtime/arguments.cpp 2017-10-17 23:16:56.731802763 +0200 @@ -29,6 +29,7 @@ #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" #include "gc/shared/gc.hpp" +#include "gc/shared/gcFactory.hpp" #include "gc/shared/genCollectedHeap.hpp" #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/taskqueue.hpp" @@ -1587,7 +1588,7 @@ // the alignments imposed by several sources: any requirements from the heap // itself, the collector policy and the maximum page size we may run the VM // with. - size_t heap_alignment = GC::gc()->conservative_max_heap_alignment(); + size_t heap_alignment = GCFactory::gc()->conservative_max_heap_alignment(); _conservative_max_heap_alignment = MAX4(heap_alignment, (size_t)os::vm_allocation_granularity(), os::max_page_size(), @@ -1653,7 +1654,7 @@ } #endif - jint gc_result = GC::initialize(); + jint gc_result = GCFactory::initialize(); if (gc_result != JNI_OK) { return gc_result; } @@ -1690,9 +1691,9 @@ void Arguments::set_gc_specific_flags() { // Set per-collector flags - GC::gc()->initialize_flags(); + GCFactory::gc()->initialize_flags(); // Set flags for all collectors. - GC::initialize_flags_global(); + GCFactory::initialize_flags_global(); } julong Arguments::limit_by_allocatable_memory(julong limit) { --- old/src/hotspot/share/gc/shared/gc_factory.cpp 2017-10-17 23:16:59.300809011 +0200 +++ /dev/null 2017-10-04 16:47:44.101817018 +0200 @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/shared/gc.hpp" -#include "gc/serial/serialGC.hpp" -#include "runtime/globals.hpp" -#include "runtime/globals_extension.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; - -bool GC::gc_selected() { -#if INCLUDE_ALL_GCS - return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC; -#else - return UseSerialGC; -#endif // INCLUDE_ALL_GCS -} - -void GC::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); - } -#else - UNSUPPORTED_OPTION(UseG1GC); - UNSUPPORTED_OPTION(UseParallelGC); - UNSUPPORTED_OPTION(UseParallelOldGC); - UNSUPPORTED_OPTION(UseConcMarkSweepGC); - FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); -#endif // INCLUDE_ALL_GCS -} - -void GC::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" - " using -XX:ParallelGCThreads=N"); - } - } - if (MinHeapFreeRatio == 100) { - // Keeping the heap 100% free is hard ;-) so limit it to 99%. - FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); - } - - // If class unloading is disabled, also disable concurrent class unloading. - if (!ClassUnloading) { - FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); - FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); - } -#endif // INCLUDE_ALL_GCS -} - -jint GC::initialize() { - assert(_gc == NULL, "GC already created"); - - select_gc(); - -#if !INCLUDE_ALL_GCS - if (UseParallelGC || UseParallelOldGC) { - fatal("UseParallelGC not supported in this VM."); - } else if (UseG1GC) { - fatal("UseG1GC not supported in this VM."); - } else if (UseConcMarkSweepGC) { - fatal("UseConcMarkSweepGC not supported in this VM."); -#else - if (UseParallelGC || UseParallelOldGC) { - _gc = new ParallelGC(); - } else if (UseG1GC) { - _gc = new G1GC(); - } else if (UseConcMarkSweepGC) { - _gc = new CMSGC(); -#endif - } else if (UseSerialGC) { - _gc = new SerialGC(); - } else { - ShouldNotReachHere(); - } - return JNI_OK; -} --- /dev/null 2017-10-04 16:47:44.101817018 +0200 +++ new/src/hotspot/share/gc/shared/gcFactory.cpp 2017-10-17 23:16:58.090806068 +0200 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#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* GCFactory::_gc = NULL; + +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 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); + } +#else + UNSUPPORTED_OPTION(UseG1GC); + UNSUPPORTED_OPTION(UseParallelGC); + UNSUPPORTED_OPTION(UseParallelOldGC); + UNSUPPORTED_OPTION(UseConcMarkSweepGC); + FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); +#endif // INCLUDE_ALL_GCS +} + +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" + " using -XX:ParallelGCThreads=N"); + } + } + if (MinHeapFreeRatio == 100) { + // Keeping the heap 100% free is hard ;-) so limit it to 99%. + FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); + } + + // If class unloading is disabled, also disable concurrent class unloading. + if (!ClassUnloading) { + FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); + FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); + } +#endif // INCLUDE_ALL_GCS +} + +jint GCFactory::initialize() { + assert(_gc == NULL, "GC already created"); + + select_gc(); + +#if !INCLUDE_ALL_GCS + if (UseParallelGC || UseParallelOldGC) { + fatal("UseParallelGC not supported in this VM."); + } else if (UseG1GC) { + fatal("UseG1GC not supported in this VM."); + } else if (UseConcMarkSweepGC) { + fatal("UseConcMarkSweepGC not supported in this VM."); +#else + if (UseParallelGC || UseParallelOldGC) { + _gc = new ParallelGC(); + } else if (UseG1GC) { + _gc = new G1GC(); + } else if (UseConcMarkSweepGC) { + _gc = new CMSGC(); +#endif + } else if (UseSerialGC) { + _gc = new SerialGC(); + } else { + ShouldNotReachHere(); + } + return JNI_OK; +} --- /dev/null 2017-10-04 16:47:44.101817018 +0200 +++ new/src/hotspot/share/gc/shared/gcFactory.hpp 2017-10-17 23:17:03.378818928 +0200 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_SHARED_GCFACTORY_HPP +#define SHARE_GC_SHARED_GCFACTORY_HPP + +#include "memory/allocation.hpp" + +class GCFactory : public AllStatic { +private: + static GC* _gc; + + static void select_gc(); + static void select_gc_ergonomically(); + static bool gc_selected(); + +public: + static jint initialize(); + static bool is_initialized(); + static GC* gc(); + + static void initialize_flags_global(); +}; + +#endif // SHARE_GC_SHARED_GCFACTORY_HPP --- old/src/hotspot/share/gc/shared/gc.cpp 2017-10-17 23:17:05.907825078 +0200 +++ /dev/null 2017-10-04 16:47:44.101817018 +0200 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/shared/gc.hpp" -#include "runtime/globals.hpp" -#include "runtime/globals_extension.hpp" -#include "runtime/java.hpp" - -GC* GC::gc() { - assert(_gc != NULL, "GC not yet created"); - return _gc; -} - -bool GC::is_initialized() { - return _gc != NULL; -} - -void GC::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 GC::initialize_flags() { - // Default does nothing. -}