8235539: [JVMCI] -XX:+EnableJVMCIProduct breaks -XX:-EnableJVMCI

Reviewed-by: kvn, thartmann
This commit is contained in:
Doug Simon 2019-12-10 09:34:33 -08:00
parent c185319515
commit 25b5ddc05d
4 changed files with 103 additions and 8 deletions

View File

@ -55,6 +55,15 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {
return false; \
}
if (EnableJVMCIProduct) {
if (FLAG_IS_DEFAULT(EnableJVMCI)) {
FLAG_SET_DEFAULT(EnableJVMCI, true);
}
if (EnableJVMCI && FLAG_IS_DEFAULT(UseJVMCICompiler)) {
FLAG_SET_DEFAULT(UseJVMCICompiler, true);
}
}
JVMCI_FLAG_CHECKED(UseJVMCICompiler)
JVMCI_FLAG_CHECKED(EnableJVMCI)
JVMCI_FLAG_CHECKED(EnableJVMCIProduct)
@ -163,11 +172,11 @@ bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlag::Flags origin) {
if (JVMFlag::boolAtPut(jvmciEnableFlag, &value, origin) != JVMFlag::SUCCESS) {
return false;
}
value = true;
JVMFlag *jvmciCompilerFlag = JVMFlag::find_flag("UseJVMCICompiler");
if (JVMFlag::boolAtPut(jvmciCompilerFlag, &value, origin) != JVMFlag::SUCCESS) {
return false;
}
// Effect of EnableJVMCIProduct on changing defaults of EnableJVMCI
// and UseJVMCICompiler is deferred to check_jvmci_flags_are_consistent
// so that setting these flags explicitly (e.g. on the command line)
// takes precedence.
return true;
}

View File

@ -51,8 +51,8 @@ class fileStream;
experimental(bool, EnableJVMCIProduct, false, \
"Allow JVMCI to be used in product mode. This alters a subset of "\
"JVMCI flags to be non-experimental, defaults UseJVMCICompiler " \
"to true and defaults UseJVMCINativeLibrary to true if a JVMCI " \
"native library is available.") \
"and EnableJVMCI to true and defaults UseJVMCINativeLibrary " \
"to true if a JVMCI native library is available.") \
\
experimental(bool, UseJVMCICompiler, false, \
"Use JVMCI as the default compiler. Defaults to true if " \

View File

@ -3037,6 +3037,12 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
return JNI_ERR;
#endif // INCLUDE_MANAGEMENT
#if INCLUDE_JVMCI
} else if (match_option(option, "-XX:-EnableJVMCIProduct")) {
if (EnableJVMCIProduct) {
jio_fprintf(defaultStream::error_stream(),
"-XX:-EnableJVMCIProduct cannot come after -XX:+EnableJVMCIProduct\n");
return JNI_EINVAL;
}
} else if (match_option(option, "-XX:+EnableJVMCIProduct")) {
JVMFlag *jvmciFlag = JVMFlag::find_flag("EnableJVMCIProduct");
// Allow this flag if it has been unlocked.

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2019, 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
* @bug 8235539
* @summary Tests effect of -XX:+EnableJVMCIProduct on EnableJVMCI and UseJVMCICompiler
* @requires vm.jvmci
* @library /test/lib
*/
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class TestEnableJVMCIProduct {
static class Expectation {
final String name;
final String value;
final String origin;
final String pattern;
Expectation(final String name, String value, String origin) {
this.name = name;
this.value = value;
this.origin = origin;
this.pattern = "bool +" + name + " += " + value + " +\\{JVMCI product\\} \\{" + origin + "\\}";
}
}
public static void main(String[] args) throws Exception {
// Test EnableJVMCIProduct without any other explicit JVMCI option
test("-XX:-PrintWarnings",
new Expectation("EnableJVMCI", "true", "default"),
new Expectation("UseJVMCICompiler", "true", "default"));
test("-XX:+UseJVMCICompiler",
new Expectation("EnableJVMCI", "true", "default"),
new Expectation("UseJVMCICompiler", "true", "command line"));
test("-XX:-UseJVMCICompiler",
new Expectation("EnableJVMCI", "true", "default"),
new Expectation("UseJVMCICompiler", "false", "command line"));
test("-XX:+EnableJVMCI",
new Expectation("EnableJVMCI", "true", "command line"),
new Expectation("UseJVMCICompiler", "true", "default"));
test("-XX:-EnableJVMCI",
new Expectation("EnableJVMCI", "false", "command line"),
new Expectation("UseJVMCICompiler", "false", "default"));
}
static void test(String explicitFlag, Expectation... expectations) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCIProduct", "-XX:-UnlockExperimentalVMOptions",
explicitFlag,
"-XX:+PrintFlagsFinal", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
for (Expectation expectation : expectations) {
output.stdoutShouldMatch(expectation.pattern);
}
output.shouldHaveExitValue(0);
}
}