# HG changeset patch # User Doug Simon # Date 1497555501 -7200 # Node ID 2f2299c6857163025cb0364eb1fcd00d34488f9f # Parent b0077339d77e03f6b07dfef55f6cd4bb509766bf change default of UseJVMCICompiler based on jvmci.Compiler property (which can now be set from /jre/lib/jvmci/compiler-name) diff -r b0077339d77e -r 2f2299c68571 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu Jun 15 12:04:08 2017 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu Jun 15 21:38:21 2017 +0200 @@ -89,9 +89,9 @@ public enum Option { // @formatter:off Compiler(String.class, null, "Selects the system compiler. This must match the getCompilerName() value returned " + - "by a jdk.vm.ci.runtime.JVMCICompilerFactory provider. " + - "An empty string or the value \"null\" selects a compiler " + - "that will raise an exception upon receiving a compilation request."), + "by a jdk.vm.ci.runtime.JVMCICompilerFactory provider. An empty string or the value \"null\" " + + "selects a compiler that will raise an exception upon receiving a compilation request. This " + + "property can also be defined by the contents of /lib/jvmci/compiler-name."), // Note: The following one is not used (see InitTimer.ENABLED). It is added here // so that -XX:+JVMCIPrintProperties shows the option. InitTimer(Boolean.class, false, "Specifies if initialization timing is enabled."), diff -r b0077339d77e -r 2f2299c68571 src/share/vm/jvmci/jvmci_globals.cpp --- a/src/share/vm/jvmci/jvmci_globals.cpp Thu Jun 15 12:04:08 2017 +0200 +++ b/src/share/vm/jvmci/jvmci_globals.cpp Thu Jun 15 21:38:21 2017 +0200 @@ -66,6 +66,56 @@ return false; \ } + if (FLAG_IS_DEFAULT(UseJVMCICompiler) && !UseJVMCICompiler) { + const char* compiler_name = Arguments::get_property("jvmci.Compiler"); + if (compiler_name != NULL) { + FLAG_SET_DEFAULT(UseJVMCICompiler, true); + } else { + char filename[JVM_MAXPATHLEN]; + const char* fileSep = os::file_separator(); + jio_snprintf(filename, sizeof(filename), "%s%slib%sjvmci%scompiler-name", Arguments::get_java_home(), fileSep, fileSep, fileSep); + struct stat statbuf; + if (os::stat(filename, &statbuf) == 0) { + char line[256]; + if ((size_t) statbuf.st_size > sizeof(line)) { + jio_fprintf(defaultStream::error_stream(), "Size of %s is greater than %d\n", filename, sizeof(line)); + return false; + } + + FILE* stream = fopen(filename, "r"); + if (stream != NULL) { + char line[256]; + if (fgets(line, sizeof(line), stream) != NULL) { + // Strip newline from end of the line + char* p = line + strlen(line) - 1; + while (p >= line && (*p == '\r' || *p == '\n')) { + *p-- = 0; + } + SystemProperty* props = Arguments::system_properties(); + if (props != NULL) { + while (props->next() != NULL) { + props = props->next(); + } + SystemProperty* new_p = new SystemProperty("jvmci.Compiler", line, true); + props->set_next(new_p); + FLAG_SET_DEFAULT(UseJVMCICompiler, true); + } + } else { + jio_fprintf(defaultStream::error_stream(), + "Failed to read from %s (errno = %d)\n", filename, errno); + fclose(stream); + return false; + } + fclose(stream); + } else { + jio_fprintf(defaultStream::error_stream(), + "Failed to open %s (errno = %d)\n", filename, errno); + return false; + } + } + } + } + JVMCI_FLAG_CHECKED(UseJVMCICompiler) JVMCI_FLAG_CHECKED(EnableJVMCI) @@ -117,16 +167,6 @@ } void JVMCIGlobals::set_jvmci_specific_flags() { - if (FLAG_IS_DEFAULT(UseJVMCICompiler) && !UseJVMCICompiler) { - char filename[JVM_MAXPATHLEN]; - const char* fileSep = os::file_separator(); - jio_snprintf(filename, sizeof(filename), "%s%slib%suse-jvmci-compiler-by-default", Arguments::get_java_home(), fileSep, fileSep); - struct stat statbuf; - if (os::stat(filename, &statbuf) == 0) { - FLAG_SET_ERGO(bool, UseJVMCICompiler, true); - } - } - if (UseJVMCICompiler) { if (FLAG_IS_DEFAULT(TypeProfileWidth)) { FLAG_SET_DEFAULT(TypeProfileWidth, 8); diff -r b0077339d77e -r 2f2299c68571 src/share/vm/jvmci/jvmci_globals.hpp --- a/src/share/vm/jvmci/jvmci_globals.hpp Thu Jun 15 12:04:08 2017 +0200 +++ b/src/share/vm/jvmci/jvmci_globals.hpp Thu Jun 15 21:38:21 2017 +0200 @@ -51,7 +51,8 @@ \ product(bool, UseJVMCICompiler, false, \ "Use JVMCI as the default compiler. Will be true by default " \ - "if /lib/use-jvmci-compiler-by-default exists.") \ + "if jvmci.Compiler property is set (either on command line or " \ + "from contents of /lib/jvmci/compiler-name") \ \ product(bool, JVMCIPrintProperties, false, \ "Prints properties used by the JVMCI compiler and exits") \