# HG changeset patch # User Doug Simon # Date 1497521048 -7200 # Node ID b0077339d77e03f6b07dfef55f6cd4bb509766bf # Parent 15ab3e226b0d96704a0ed4e18354c83f3a17a0dd use existence of /lib/use-jvmci-compiler-by-default to override default value of UseJVMCICompiler diff -r 15ab3e226b0d -r b0077339d77e jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Thu Jun 15 01:01:04 2017 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Thu Jun 15 12:04:08 2017 +0200 @@ -22,6 +22,11 @@ */ package jdk.vm.ci.hotspot; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + import jdk.vm.ci.code.CompilationRequest; import jdk.vm.ci.code.CompilationRequestResult; import jdk.vm.ci.common.JVMCIError; @@ -29,8 +34,9 @@ import jdk.vm.ci.runtime.JVMCICompiler; import jdk.vm.ci.runtime.JVMCICompilerFactory; import jdk.vm.ci.runtime.JVMCIRuntime; +import jdk.vm.ci.services.JVMCIPermission; import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.services.JVMCIPermission; +import sun.misc.VM; final class HotSpotJVMCICompilerConfig { @@ -41,8 +47,14 @@ */ private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { + private final String reason; + + DummyCompilerFactory(String reason) { + this.reason = reason; + } + public CompilationRequestResult compileMethod(CompilationRequest request) { - throw new JVMCIError("no JVMCI compiler selected"); + throw new JVMCIError("No JVMCI compiler selected. " + reason); } @Override @@ -74,7 +86,8 @@ String compilerName = Option.Compiler.getString(); if (compilerName != null) { if (compilerName.isEmpty() || compilerName.equals("null")) { - factory = new DummyCompilerFactory(); + factory = new DummyCompilerFactory("Value of " + Option.Compiler.getPropertyName() + " property is \"" + + compilerName + "\" which denotes the null JVMCI compiler."); } else { for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) { if (f.getCompilerName().equals(compilerName)) { @@ -82,22 +95,33 @@ } } if (factory == null) { - throw new JVMCIError("JVMCI compiler '%s' not found", compilerName); + throw new JVMCIError("JVMCI compiler \"%s\" not found", compilerName); } } } else { // Auto select a single available compiler + List multiple = null; for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) { - if (factory == null) { + if (multiple != null) { + multiple.add(f.getCompilerName()); + } else if (factory == null) { factory = f; } else { - // Multiple factories seen - cancel auto selection + multiple = new ArrayList<>(); + multiple.add(f.getCompilerName()); + multiple.add(factory.getCompilerName()); factory = null; - break; } } - if (factory == null) { - factory = new DummyCompilerFactory(); + if (multiple != null) { + factory = new DummyCompilerFactory("Multiple providers of " + JVMCICompilerFactory.class + " available: " + + String.join(", ", multiple) + + ". You can select one of these with the " + Option.Compiler.getPropertyName() + " property " + + "(e.g., -D" + Option.Compiler.getPropertyName() + "=" + multiple.get(0) + ")."); + } else if (factory == null) { + Path jvmciDir = Paths.get(VM.getSavedProperty("java.home"), "lib", "jvmci"); + factory = new DummyCompilerFactory("No providers of " + JVMCICompilerFactory.class + " found in " + jvmciDir + + " or on the class path specified by the jvmci.class.path.append property."); } } factory.onSelection(); diff -r 15ab3e226b0d -r b0077339d77e src/share/vm/jvmci/jvmci_globals.cpp --- a/src/share/vm/jvmci/jvmci_globals.cpp Thu Jun 15 01:01:04 2017 +0200 +++ b/src/share/vm/jvmci/jvmci_globals.cpp Thu Jun 15 12:04:08 2017 +0200 @@ -118,35 +118,12 @@ void JVMCIGlobals::set_jvmci_specific_flags() { if (FLAG_IS_DEFAULT(UseJVMCICompiler) && !UseJVMCICompiler) { - if (Arguments::get_property("jvmci.class.path.append") != NULL) { - // If jvmci.class.path.append is defined then - // assume there is a JVMCI compiler. + 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); - } else { - // If lib/jvmci contains at least one jar apart from - // jvmci-api.jar and jvmci-hotspot.jar, then - // assume there is a JVMCI compiler. - char jvmciDir[JVM_MAXPATHLEN]; - const char* fileSep = os::file_separator(); - jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci", Arguments::get_java_home(), fileSep, fileSep); - DIR* dir = os::opendir(jvmciDir); - if (dir != NULL) { - /* Scan the directory for jars */ - struct dirent *entry; - char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal); - while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { - const char* name = entry->d_name; - const char* ext = name + strlen(name) - 4; - if (ext > name && os::file_name_strcmp(ext, ".jar") == 0) { - if (strcmp(name, "jvmci-api.jar") != 0 && strcmp(name, "jvmci-hotspot.jar") != 0) { - FLAG_SET_ERGO(bool, UseJVMCICompiler, true); - break; - } - } - } - FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); - os::closedir(dir); - } } } diff -r 15ab3e226b0d -r b0077339d77e src/share/vm/jvmci/jvmci_globals.hpp --- a/src/share/vm/jvmci/jvmci_globals.hpp Thu Jun 15 01:01:04 2017 +0200 +++ b/src/share/vm/jvmci/jvmci_globals.hpp Thu Jun 15 12:04:08 2017 +0200 @@ -50,9 +50,8 @@ "Enable JVMCI") \ \ product(bool, UseJVMCICompiler, false, \ - "Use JVMCI as the default compiler. Ergonomically set to " \ - "true if non-core JVMCI jars are in jre/lib/jvmci/ or the " \ - "jvmci.class.path.append system property is defined.") \ + "Use JVMCI as the default compiler. Will be true by default " \ + "if /lib/use-jvmci-compiler-by-default exists.") \ \ product(bool, JVMCIPrintProperties, false, \ "Prints properties used by the JVMCI compiler and exits") \