changeset 24145:2f2299c68571 jvmci-0.27

change default of UseJVMCICompiler based on jvmci.Compiler property (which can now be set from <java.home>/jre/lib/jvmci/compiler-name)
author Doug Simon <doug.simon@oracle.com>
date Thu, 15 Jun 2017 21:38:21 +0200
parents b0077339d77e
children a63c0eedf71e
files jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java src/share/vm/jvmci/jvmci_globals.cpp src/share/vm/jvmci/jvmci_globals.hpp
diffstat 3 files changed, 55 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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 <java.home>/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."),
--- 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);
--- 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 <java.home>/lib/use-jvmci-compiler-by-default exists.")       \
+          "if jvmci.Compiler property is set (either on command line or "   \
+          "from contents of <java.home>/lib/jvmci/compiler-name")           \
                                                                             \
   product(bool, JVMCIPrintProperties, false,                                \
           "Prints properties used by the JVMCI compiler and exits")         \