8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Reviewed-by: dnsimon, vlivanov
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Tue Mar 08 15:10:02 2016 -0800
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Thu Mar 10 13:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -25,6 +25,7 @@
import jdk.vm.ci.code.CompilationRequest;
import jdk.vm.ci.code.CompilationRequestResult;
import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
import jdk.vm.ci.runtime.JVMCICompiler;
import jdk.vm.ci.runtime.JVMCICompilerFactory;
import jdk.vm.ci.runtime.JVMCIRuntime;
@@ -47,29 +48,33 @@
}
}
+ /**
+ * Factory of the selected system compiler.
+ */
private static JVMCICompilerFactory compilerFactory;
/**
- * Selects the system compiler.
+ * Gets the selected system compiler factory.
*
- * 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.
+ * @return the selected system compiler factory
*/
- static Boolean selectCompiler(String compilerName) {
- assert compilerFactory == null;
- for (JVMCICompilerFactory factory : Services.load(JVMCICompilerFactory.class)) {
- if (factory.getCompilerName().equals(compilerName)) {
- compilerFactory = factory;
- return Boolean.TRUE;
- }
- }
-
- throw new JVMCIError("JVMCI compiler '%s' not found", compilerName);
- }
-
static JVMCICompilerFactory getCompilerFactory() {
if (compilerFactory == null) {
- compilerFactory = new DummyCompilerFactory();
+ JVMCICompilerFactory factory = null;
+ String compilerName = Option.Compiler.getString();
+ if (compilerName != null) {
+ for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
+ if (f.getCompilerName().equals(compilerName)) {
+ factory = f;
+ }
+ }
+ if (factory == null) {
+ throw new JVMCIError("JVMCI compiler '%s' not found", compilerName);
+ }
+ } else {
+ factory = new DummyCompilerFactory();
+ }
+ compilerFactory = factory;
}
return compilerFactory;
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Tue Mar 08 15:10:02 2016 -0800
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu Mar 10 13:04:43 2016 -0800
@@ -91,6 +91,7 @@
* A list of all supported JVMCI options.
*/
public enum Option {
+ Compiler(String.class, null, "Selects the system compiler."),
ImplicitStableValues(boolean.class, true, "Mark well-known stable fields as such."),
// Note: The following one is not used (see InitTimer.ENABLED).
InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."),
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Tue Mar 08 15:10:02 2016 -0800
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Thu Mar 10 13:04:43 2016 -0800
@@ -51,7 +51,6 @@
jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
bool JVMCIRuntime::_well_known_classes_initialized = false;
-const char* JVMCIRuntime::_compiler = NULL;
int JVMCIRuntime::_trivial_prefixes_count = 0;
char** JVMCIRuntime::_trivial_prefixes = NULL;
bool JVMCIRuntime::_shutdown_called = false;
@@ -642,15 +641,6 @@
"HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
#endif
- if (_compiler != NULL) {
- JavaCallArguments args;
- oop compiler = java_lang_String::create_oop_from_str(_compiler, CHECK);
- args.push_oop(compiler);
- callStatic("jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig",
- "selectCompiler",
- "(Ljava/lang/String;)Ljava/lang/Boolean;", &args, CHECK);
- }
-
Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
"runtime",
"()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
@@ -783,66 +773,6 @@
}
JVM_END
-/**
- * Closure for parsing a line from a *.properties file in jre/lib/jvmci/properties.
- * The line must match the regular expression "[^=]+=.*". That is one or more
- * characters other than '=' followed by '=' followed by zero or more characters.
- * Everything before the '=' is the property name and everything after '=' is the value.
- * Lines that start with '#' are treated as comments and ignored.
- * No special processing of whitespace or any escape characters is performed.
- * The last definition of a property "wins" (i.e., it overrides all earlier
- * definitions of the property).
- */
-class JVMCIPropertiesFileClosure : public ParseClosure {
- SystemProperty** _plist;
-public:
- JVMCIPropertiesFileClosure(SystemProperty** plist) : _plist(plist) {}
- void do_line(char* line) {
- if (line[0] == '#') {
- // skip comment
- return;
- }
- size_t len = strlen(line);
- char* sep = strchr(line, '=');
- if (sep == NULL) {
- warn_and_abort("invalid format: could not find '=' character");
- return;
- }
- if (sep == line) {
- warn_and_abort("invalid format: name cannot be empty");
- return;
- }
- *sep = '\0';
- const char* name = line;
- char* value = sep + 1;
- Arguments::PropertyList_unique_add(_plist, name, value);
- }
-};
-
-void JVMCIRuntime::init_system_properties(SystemProperty** plist) {
- char jvmciDir[JVM_MAXPATHLEN];
- const char* fileSep = os::file_separator();
- jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci",
- Arguments::get_java_home(), fileSep, fileSep, fileSep);
- DIR* dir = os::opendir(jvmciDir);
- if (dir != NULL) {
- struct dirent *entry;
- char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal);
- JVMCIPropertiesFileClosure closure(plist);
- const unsigned suffix_len = (unsigned)strlen(".properties");
- while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL && !closure.is_aborted()) {
- const char* name = entry->d_name;
- if (strlen(name) > suffix_len && strcmp(name + strlen(name) - suffix_len, ".properties") == 0) {
- char propertiesFilePath[JVM_MAXPATHLEN];
- jio_snprintf(propertiesFilePath, sizeof(propertiesFilePath), "%s%s%s",jvmciDir, fileSep, name);
- JVMCIRuntime::parse_lines(propertiesFilePath, &closure, false);
- }
- }
- FREE_C_HEAP_ARRAY(char, dbuf);
- os::closedir(dir);
- }
-}
-
#define CHECK_WARN_ABORT_(message) THREAD); \
if (HAS_PENDING_EXCEPTION) { \
warning(message); \
@@ -853,12 +783,6 @@
} \
(void)(0
-void JVMCIRuntime::save_compiler(const char* compiler) {
- assert(compiler != NULL, "npe");
- assert(_compiler == NULL, "cannot reassign JVMCI compiler");
- _compiler = compiler;
-}
-
void JVMCIRuntime::shutdown(TRAPS) {
if (_HotSpotJVMCIRuntime_instance != NULL) {
_shutdown_called = true;
@@ -884,69 +808,3 @@
}
return false;
}
-
-void JVMCIRuntime::parse_lines(char* path, ParseClosure* closure, bool warnStatFailure) {
- struct stat st;
- if (::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
- int file_handle = ::open(path, os::default_file_open_flags(), 0);
- if (file_handle != -1) {
- char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal);
- int num_read;
- num_read = (int) ::read(file_handle, (char*) buffer, st.st_size);
- if (num_read == -1) {
- warning("Error reading file %s due to %s", path, strerror(errno));
- } else if (num_read != st.st_size) {
- warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path);
- }
- ::close(file_handle);
- closure->set_filename(path);
- if (num_read == st.st_size) {
- buffer[num_read] = '\0';
-
- char* line = buffer;
- while (line - buffer < num_read && !closure->is_aborted()) {
- // find line end (\r, \n or \r\n)
- char* nextline = NULL;
- char* cr = strchr(line, '\r');
- char* lf = strchr(line, '\n');
- if (cr != NULL && lf != NULL) {
- char* min = MIN2(cr, lf);
- *min = '\0';
- if (lf == cr + 1) {
- nextline = lf + 1;
- } else {
- nextline = min + 1;
- }
- } else if (cr != NULL) {
- *cr = '\0';
- nextline = cr + 1;
- } else if (lf != NULL) {
- *lf = '\0';
- nextline = lf + 1;
- }
- // trim left
- while (*line == ' ' || *line == '\t') line++;
- char* end = line + strlen(line);
- // trim right
- while (end > line && (*(end -1) == ' ' || *(end -1) == '\t')) end--;
- *end = '\0';
- // skip comments and empty lines
- if (*line != '#' && strlen(line) > 0) {
- closure->parse_line(line);
- }
- if (nextline != NULL) {
- line = nextline;
- } else {
- // File without newline at the end
- break;
- }
- }
- }
- FREE_C_HEAP_ARRAY(char, buffer);
- } else {
- warning("Error opening file %s due to %s", path, strerror(errno));
- }
- } else if (warnStatFailure) {
- warning("Could not stat file %s due to %s", path, strerror(errno));
- }
-}
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp Tue Mar 08 15:10:02 2016 -0800
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp Thu Mar 10 13:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -70,7 +70,6 @@
static jobject _HotSpotJVMCIRuntime_instance;
static bool _HotSpotJVMCIRuntime_initialized;
static bool _well_known_classes_initialized;
- static const char* _compiler;
static int _trivial_prefixes_count;
static char** _trivial_prefixes;
@@ -85,19 +84,9 @@
static Handle create_Service(const char* name, TRAPS);
public:
-
- /**
- * Parses *.properties files in jre/lib/jvmci/ and adds the properties to plist.
- */
- static void init_system_properties(SystemProperty** plist);
-
- /**
- * Saves the value of the "jvmci.compiler" system property for processing
- * when JVMCI is initialized.
- */
- static void save_compiler(const char* compiler);
-
- static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; }
+ static bool is_HotSpotJVMCIRuntime_initialized() {
+ return _HotSpotJVMCIRuntime_initialized;
+ }
/**
* Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary
@@ -136,7 +125,6 @@
}
static bool treat_as_trivial(Method* method);
- static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure);
static BasicType kindToBasicType(Handle kind, TRAPS);
--- a/hotspot/src/share/vm/runtime/arguments.cpp Tue Mar 08 15:10:02 2016 -0800
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Thu Mar 10 13:04:43 2016 -0800
@@ -221,8 +221,6 @@
// Set OS specific system properties values
os::init_system_properties_values();
-
- JVMCI_ONLY(JVMCIRuntime::init_system_properties(&_system_properties);)
}
// Update/Initialize System properties after JDK version number is known
--- a/hotspot/src/share/vm/runtime/thread.cpp Tue Mar 08 15:10:02 2016 -0800
+++ b/hotspot/src/share/vm/runtime/thread.cpp Thu Mar 10 13:04:43 2016 -0800
@@ -3696,15 +3696,6 @@
Chunk::start_chunk_pool_cleaner_task();
}
-#if INCLUDE_JVMCI
- if (EnableJVMCI) {
- const char* jvmciCompiler = Arguments::PropertyList_get_value(Arguments::system_properties(), "jvmci.compiler");
- if (jvmciCompiler != NULL) {
- JVMCIRuntime::save_compiler(jvmciCompiler);
- }
- }
-#endif // INCLUDE_JVMCI
-
// initialize compiler(s)
#if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || INCLUDE_JVMCI
CompileBroker::compilation_init(CHECK_JNI_ERR);