mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8068579: Running with -XX:-UseParallelGC does not turn ParalleGC off
Reviewed-by: jmasa, dfazunen, brutisso
This commit is contained in:
parent
ae4cc4b56a
commit
0fb3d6a52e
4 changed files with 92 additions and 46 deletions
|
@ -67,14 +67,14 @@
|
||||||
#define DEFAULT_JAVA_LAUNCHER "generic"
|
#define DEFAULT_JAVA_LAUNCHER "generic"
|
||||||
|
|
||||||
#define UNSUPPORTED_GC_OPTION(gc) \
|
#define UNSUPPORTED_GC_OPTION(gc) \
|
||||||
do { \
|
do { \
|
||||||
if (gc) { \
|
if (gc) { \
|
||||||
if (FLAG_IS_CMDLINE(gc)) { \
|
if (FLAG_IS_CMDLINE(gc)) { \
|
||||||
warning(#gc " is not supported in this VM. Using Serial GC."); \
|
warning("-XX:+" #gc " not supported in this VM"); \
|
||||||
} \
|
} \
|
||||||
FLAG_SET_DEFAULT(gc, false); \
|
FLAG_SET_DEFAULT(gc, false); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
char* Arguments::_jvm_flags_file = NULL;
|
char* Arguments::_jvm_flags_file = NULL;
|
||||||
char** Arguments::_jvm_flags_array = NULL;
|
char** Arguments::_jvm_flags_array = NULL;
|
||||||
|
@ -1936,26 +1936,45 @@ void Arguments::set_conservative_max_heap_alignment() {
|
||||||
CollectorPolicy::compute_heap_alignment());
|
CollectorPolicy::compute_heap_alignment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Arguments::gc_selected() {
|
||||||
|
#if INCLUDE_ALL_GCS
|
||||||
|
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
|
||||||
|
#else
|
||||||
|
return UseSerialGC;
|
||||||
|
#endif // INCLUDE_ALL_GCS
|
||||||
|
}
|
||||||
|
|
||||||
void Arguments::select_gc_ergonomically() {
|
void Arguments::select_gc_ergonomically() {
|
||||||
|
#if INCLUDE_ALL_GCS
|
||||||
if (os::is_server_class_machine()) {
|
if (os::is_server_class_machine()) {
|
||||||
if (should_auto_select_low_pause_collector()) {
|
if (should_auto_select_low_pause_collector()) {
|
||||||
FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
|
FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
|
||||||
} else {
|
} else {
|
||||||
#if defined(JAVASE_EMBEDDED)
|
#if defined(JAVASE_EMBEDDED)
|
||||||
FLAG_SET_ERGO(bool, UseParallelGC, true);
|
FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
|
||||||
#else
|
#else
|
||||||
FLAG_SET_ERGO(bool, UseG1GC, true);
|
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FLAG_SET_ERGO(bool, UseSerialGC, true);
|
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UNSUPPORTED_GC_OPTION(UseG1GC);
|
||||||
|
UNSUPPORTED_GC_OPTION(UseParallelGC);
|
||||||
|
UNSUPPORTED_GC_OPTION(UseParallelOldGC);
|
||||||
|
UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
|
||||||
|
UNSUPPORTED_GC_OPTION(UseParNewGC);
|
||||||
|
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
|
||||||
|
#endif // INCLUDE_ALL_GCS
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arguments::select_gc() {
|
void Arguments::select_gc() {
|
||||||
if (!gc_selected()) {
|
if (!gc_selected()) {
|
||||||
select_gc_ergonomically();
|
select_gc_ergonomically();
|
||||||
guarantee(gc_selected(), "No GC selected");
|
if (!gc_selected()) {
|
||||||
|
vm_exit_during_initialization("Garbage collector not selected (default collector explicitly disabled)", NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2080,16 +2099,6 @@ void Arguments::set_g1_gc_flags() {
|
||||||
log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
|
log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !INCLUDE_ALL_GCS
|
|
||||||
#ifdef ASSERT
|
|
||||||
static bool verify_serial_gc_flags() {
|
|
||||||
return (UseSerialGC &&
|
|
||||||
!(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
|
|
||||||
UseParallelGC || UseParallelOldGC));
|
|
||||||
}
|
|
||||||
#endif // ASSERT
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
|
||||||
|
|
||||||
void Arguments::set_gc_specific_flags() {
|
void Arguments::set_gc_specific_flags() {
|
||||||
#if INCLUDE_ALL_GCS
|
#if INCLUDE_ALL_GCS
|
||||||
// Set per-collector flags
|
// Set per-collector flags
|
||||||
|
@ -2111,8 +2120,6 @@ void Arguments::set_gc_specific_flags() {
|
||||||
// Keeping the heap 100% free is hard ;-) so limit it to 99%.
|
// Keeping the heap 100% free is hard ;-) so limit it to 99%.
|
||||||
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
|
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
|
||||||
}
|
}
|
||||||
#else // INCLUDE_ALL_GCS
|
|
||||||
assert(verify_serial_gc_flags(), "SerialGC unset");
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
#endif // INCLUDE_ALL_GCS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3955,17 +3962,6 @@ void Arguments::set_shared_spaces_flags() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !INCLUDE_ALL_GCS
|
|
||||||
static void force_serial_gc() {
|
|
||||||
FLAG_SET_DEFAULT(UseSerialGC, true);
|
|
||||||
UNSUPPORTED_GC_OPTION(UseG1GC);
|
|
||||||
UNSUPPORTED_GC_OPTION(UseParallelGC);
|
|
||||||
UNSUPPORTED_GC_OPTION(UseParallelOldGC);
|
|
||||||
UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
|
|
||||||
UNSUPPORTED_GC_OPTION(UseParNewGC);
|
|
||||||
}
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
|
||||||
|
|
||||||
// Sharing support
|
// Sharing support
|
||||||
// Construct the path to the archive
|
// Construct the path to the archive
|
||||||
static char* get_shared_archive_path() {
|
static char* get_shared_archive_path() {
|
||||||
|
@ -4360,9 +4356,6 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
|
||||||
// Set object alignment values.
|
// Set object alignment values.
|
||||||
set_object_alignment();
|
set_object_alignment();
|
||||||
|
|
||||||
#if !INCLUDE_ALL_GCS
|
|
||||||
force_serial_gc();
|
|
||||||
#endif // INCLUDE_ALL_GCS
|
|
||||||
#if !INCLUDE_CDS
|
#if !INCLUDE_CDS
|
||||||
if (DumpSharedSpaces || RequireSharedSpaces) {
|
if (DumpSharedSpaces || RequireSharedSpaces) {
|
||||||
jio_fprintf(defaultStream::error_stream(),
|
jio_fprintf(defaultStream::error_stream(),
|
||||||
|
|
|
@ -567,7 +567,7 @@ class Arguments : AllStatic {
|
||||||
static jint adjust_after_os();
|
static jint adjust_after_os();
|
||||||
|
|
||||||
static void set_gc_specific_flags();
|
static void set_gc_specific_flags();
|
||||||
static inline bool gc_selected(); // whether a gc has been selected
|
static bool gc_selected(); // whether a gc has been selected
|
||||||
static void select_gc_ergonomically();
|
static void select_gc_ergonomically();
|
||||||
#if INCLUDE_JVMCI
|
#if INCLUDE_JVMCI
|
||||||
// Check consistency of jvmci vm argument settings.
|
// Check consistency of jvmci vm argument settings.
|
||||||
|
@ -732,10 +732,6 @@ class Arguments : AllStatic {
|
||||||
static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
|
static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Arguments::gc_selected() {
|
|
||||||
return UseConcMarkSweepGC || UseG1GC || UseParallelGC || UseParallelOldGC || UseSerialGC;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable options not supported in this release, with a warning if they
|
// Disable options not supported in this release, with a warning if they
|
||||||
// were explicitly requested on the command-line
|
// were explicitly requested on the command-line
|
||||||
#define UNSUPPORTED_OPTION(opt, description) \
|
#define UNSUPPORTED_OPTION(opt, description) \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -290,6 +290,12 @@ typedef enum {
|
||||||
|
|
||||||
#define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::COMMAND_LINE))
|
#define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::COMMAND_LINE))
|
||||||
#define FLAG_SET_ERGO(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::ERGONOMIC))
|
#define FLAG_SET_ERGO(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::ERGONOMIC))
|
||||||
|
#define FLAG_SET_ERGO_IF_DEFAULT(type, name, value) \
|
||||||
|
do { \
|
||||||
|
if (FLAG_IS_DEFAULT(name)) { \
|
||||||
|
FLAG_SET_ERGO(type, name, value); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
// Can't put the following in CommandLineFlags because
|
// Can't put the following in CommandLineFlags because
|
||||||
// of a circular dependency on the enum definition.
|
// of a circular dependency on the enum definition.
|
||||||
|
|
51
hotspot/test/gc/arguments/TestDisableDefaultGC.java
Normal file
51
hotspot/test/gc/arguments/TestDisableDefaultGC.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test TestDisableDefaultGC
|
||||||
|
* @summary Test that the VM complains when the default GC is disabled and no other GC is specified
|
||||||
|
* @bug 8068579
|
||||||
|
* @key gc
|
||||||
|
* @library /testlibrary
|
||||||
|
* @requires vm.gc=="null"
|
||||||
|
* @modules java.base/sun.misc
|
||||||
|
* java.management
|
||||||
|
* @run driver TestDisableDefaultGC
|
||||||
|
*/
|
||||||
|
|
||||||
|
import jdk.test.lib.ProcessTools;
|
||||||
|
import jdk.test.lib.OutputAnalyzer;
|
||||||
|
|
||||||
|
public class TestDisableDefaultGC {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// Start VM, disabling all possible default GCs
|
||||||
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseSerialGC",
|
||||||
|
"-XX:-UseParallelGC",
|
||||||
|
"-XX:-UseG1GC",
|
||||||
|
"-XX:-UseConcMarkSweepGC",
|
||||||
|
"-version");
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldMatch("Garbage collector not selected");
|
||||||
|
output.shouldHaveExitValue(1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue