8068582: UseSerialGC not always set up properly

Reviewed-by: jmasa, brutisso, sjohanss
This commit is contained in:
Per Lidén 2015-04-20 08:53:08 +02:00
parent 0d5c04e00d
commit e4a699552a
5 changed files with 72 additions and 14 deletions

View File

@ -273,11 +273,6 @@ public:
// only and may need to be re-examined in case other
// kinds of collectors are implemented in the future.
virtual bool can_elide_initializing_store_barrier(oop new_obj) {
// We wanted to assert that:-
// assert(UseSerialGC || UseConcMarkSweepGC,
// "Check can_elide_initializing_store_barrier() for this collector");
// but unfortunately the flag UseSerialGC need not necessarily always
// be set when DefNew+Tenured are being used.
return is_in_young(new_obj);
}

View File

@ -714,7 +714,6 @@ jint Universe::initialize_heap() {
fatal("UseG1GC not supported in this VM.");
} else if (UseConcMarkSweepGC) {
fatal("UseConcMarkSweepGC not supported in this VM.");
}
#else
if (UseParallelGC) {
status = Universe::create_heap<ParallelScavengeHeap, GenerationSizer>();
@ -722,12 +721,11 @@ jint Universe::initialize_heap() {
status = Universe::create_heap<G1CollectedHeap, G1CollectorPolicyExt>();
} else if (UseConcMarkSweepGC) {
status = Universe::create_heap<GenCollectedHeap, ConcurrentMarkSweepPolicy>();
}
#endif
else { // UseSerialGC
// Don't assert that UseSerialGC is set here because there are cases
// where no GC it set and we then fall back to using SerialGC.
} else if (UseSerialGC) {
status = Universe::create_heap<GenCollectedHeap, MarkSweepPolicy>();
} else {
ShouldNotReachHere();
}
if (status != JNI_OK) {

View File

@ -1565,12 +1565,15 @@ void Arguments::select_gc_ergonomically() {
} else {
FLAG_SET_ERGO(bool, UseParallelGC, true);
}
} else {
FLAG_SET_ERGO(bool, UseSerialGC, true);
}
}
void Arguments::select_gc() {
if (!gc_selected()) {
select_gc_ergonomically();
guarantee(gc_selected(), "No GC selected");
}
}
@ -2096,10 +2099,8 @@ bool Arguments::check_gc_consistency() {
}
if (UseParNewGC && !UseConcMarkSweepGC) {
// !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
// set up UseSerialGC properly, so that can't be used in the check here.
jio_fprintf(defaultStream::error_stream(),
"It is not possible to combine the ParNew young collector with the Serial old collector.\n");
"It is not possible to combine the ParNew young collector with any collector other than CMS.\n");
return false;
}

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2015, 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 TestSelectDefaultGC
* @summary Test selection of GC when no GC option is specified
* @bug 8068582
* @key gc
* @library /testlibrary
* @modules java.base/sun.misc
* java.management
* @run driver TestSelectDefaultGC
*/
import com.oracle.java.testlibrary.*;
import java.util.regex.*;
public class TestSelectDefaultGC {
public static boolean versionStringContains(OutputAnalyzer output, String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStderr());
return matcher.find();
}
public static void assertVMOption(OutputAnalyzer output, String option, boolean value) {
output.shouldMatch(" " + option + " .*=.* " + value + " ");
}
public static void main(String[] args) throws Exception {
// Start VM without specifying GC
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintFlagsFinal", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
boolean isServerVM = versionStringContains(output, "Server VM");
// Verify GC selection
assertVMOption(output, "UseParallelGC", isServerVM);
assertVMOption(output, "UseParallelOldGC", isServerVM);
assertVMOption(output, "UseSerialGC", !isServerVM);
assertVMOption(output, "UseConcMarkSweepGC", false);
assertVMOption(output, "UseG1GC", false);
assertVMOption(output, "UseParNewGC", false);
}
}

View File

@ -40,7 +40,7 @@ public class TestParNewSerialOld {
public static void main(String args[]) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("It is not possible to combine the ParNew young collector with the Serial old collector.");
output.shouldContain("It is not possible to combine the ParNew young collector with any collector other than CMS.");
output.shouldContain("Error");
output.shouldHaveExitValue(1);
}