Mercurial > hg > graal-jvmci-8
changeset 22511:df5a7841f92a
revived support for specifying JVMCI options in <jre>/lib/jvmci/options
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 03 Sep 2015 14:47:36 +0200 |
parents | 45723ab25426 |
children | 1852abfbaca3 |
files | jvmci/jdk.internal.jvmci.options/src/jdk/internal/jvmci/options/OptionsParser.java mx.jvmci/mx_jvmci.py src/share/vm/jvmci/jvmciRuntime.cpp |
diffstat | 3 files changed, 51 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.options/src/jdk/internal/jvmci/options/OptionsParser.java Thu Sep 03 12:03:25 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.options/src/jdk/internal/jvmci/options/OptionsParser.java Thu Sep 03 14:47:36 2015 +0200 @@ -67,24 +67,50 @@ } /** - * Parses the set of space separated JVMCI options in {@code options}. + * Parses the options in {@code <jre>/lib/jvmci/options} if {@code parseOptionsFile == true} and + * the file exists followed by the space separated JVMCI options in {@code options} if + * {@code options != null}. * * Called from VM. This method has an object return type to allow it to be called with a VM * utility function used to call other static initialization methods. * * @param options space separated set of JVMCI options to parse + * @param parseOptionsFile specifies whether to look for and parse + * {@code <jre>/lib/jvmci.options} */ @SuppressWarnings("try") - public static Boolean parseOptionsFromVM(String options) { + public static Boolean parseOptionsFromVM(String options, boolean parseOptionsFile) { try (InitTimer t = timer("ParseOptions")) { JVMCIJarsOptionDescriptorsProvider odp = new JVMCIJarsOptionDescriptorsProvider(); - assert options != null; - int index = skip(options, 0, true); - while (index < options.length()) { - int end = skip(options, index, false); - String option = options.substring(index, end); - parseOption(option, null, odp); - index = skip(options, end, true); + + if (parseOptionsFile) { + File javaHome = new File(System.getProperty("java.home")); + File lib = new File(javaHome, "lib"); + File jvmci = new File(lib, "jvmci"); + File jvmciOptions = new File(jvmci, "options"); + if (jvmciOptions.exists()) { + try (BufferedReader br = new BufferedReader(new FileReader(jvmciOptions))) { + String option = null; + while ((option = br.readLine()) != null) { + option = option.trim(); + if (!option.isEmpty() && option.charAt(0) != '#') { + parseOption(option, null, odp); + } + } + } catch (IOException e) { + throw new InternalError("Error reading " + jvmciOptions, e); + } + } + } + + if (options != null) { + int index = skip(options, 0, true); + while (index < options.length()) { + int end = skip(options, index, false); + String option = options.substring(index, end); + parseOption(option, null, odp); + index = skip(options, end, true); + } } } return Boolean.TRUE;
--- a/mx.jvmci/mx_jvmci.py Thu Sep 03 12:03:25 2015 +0200 +++ b/mx.jvmci/mx_jvmci.py Thu Sep 03 14:47:36 2015 +0200 @@ -595,9 +595,9 @@ jvmciOptions = join(_suite.dir, 'jvmci.options') jreLibDir = join(jdkDir, 'jre', 'lib') if exists(jvmciOptions): - shutil.copy(jvmciOptions, join(jreLibDir, 'jvmci.options')) + shutil.copy(jvmciOptions, join(jreLibDir, 'jvmci', 'options')) else: - toDelete = join(jreLibDir, 'jvmci.options') + toDelete = join(jreLibDir, 'jvmci', 'options') if exists(toDelete): os.unlink(toDelete)
--- a/src/share/vm/jvmci/jvmciRuntime.cpp Thu Sep 03 12:03:25 2015 +0200 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Thu Sep 03 14:47:36 2015 +0200 @@ -663,6 +663,16 @@ return Handle((oop)result.get_jobject()); } +static bool jvmci_options_file_exists() { + const char* home = Arguments::get_java_home(); + size_t path_len = strlen(home) + strlen("/lib/jvmci/options") + 1; + char path[JVM_MAXPATHLEN]; + char sep = os::file_separator()[0]; + jio_snprintf(path, JVM_MAXPATHLEN, "%s%clib%cjvmci%coptions", home, sep, sep, sep); + struct stat st; + return os::stat(path, &st) == 0; +} + void JVMCIRuntime::initialize_HotSpotJVMCIRuntime() { if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { Thread* THREAD = Thread::current(); @@ -674,13 +684,15 @@ "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); #endif - if (_options != NULL) { + bool parseOptionsFile = jvmci_options_file_exists(); + if (_options != NULL || parseOptionsFile) { JavaCallArguments args; oop options = java_lang_String::create_oop_from_str(_options, CHECK_ABORT); args.push_oop(options); + args.push_int(parseOptionsFile); callStatic("jdk/internal/jvmci/options/OptionsParser", "parseOptionsFromVM", - "(Ljava/lang/String;)Ljava/lang/Boolean;", &args); + "(Ljava/lang/String;Z)Ljava/lang/Boolean;", &args); } if (_compiler != NULL) {