changeset 21956:35affb9c707a

add properties from <jdk>/jre/lib/jvmci/*.properties files to system properties
author Doug Simon <doug.simon@oracle.com>
date Sat, 13 Jun 2015 00:22:48 +0200
parents 3ce35131bff2
children 555f788b964b
files src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/jvmci/jvmciRuntime.hpp src/share/vm/runtime/arguments.cpp
diffstat 3 files changed, 67 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Fri Jun 12 18:02:58 2015 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Sat Jun 13 00:22:48 2015 +0200
@@ -34,7 +34,6 @@
 #include "prims/jvm.h"
 #include "runtime/biasedLocking.hpp"
 #include "runtime/interfaceSupport.hpp"
-#include "runtime/arguments.hpp"
 #include "runtime/reflection.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/defaultStream.hpp"
@@ -729,6 +728,60 @@
   }
 }
 
+/**
+ * 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.
+ * No special processing of whitespace or any escape characters is performed.
+ * Also, no check is made whether an existing property is overridden.
+ */
+class JVMCIPropertiesFileClosure : public ParseClosure {
+  SystemProperty** _plist;
+public:
+  JVMCIPropertiesFileClosure(SystemProperty** plist) : _plist(plist) {}
+  void do_line(char* line) {
+    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_add(_plist, name, value);
+  }
+};
+
+void JVMCIRuntime::parse_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 int suffix_len = 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, mtInternal);
+    os::closedir(dir);
+  }
+}
+
 OptionValuesTable* JVMCIRuntime::parse_arguments() {
   OptionDescsTable* table = OptionDescsTable::load_options();
   if (table == NULL) {
--- a/src/share/vm/jvmci/jvmciRuntime.hpp	Fri Jun 12 18:02:58 2015 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.hpp	Sat Jun 13 00:22:48 2015 +0200
@@ -26,6 +26,7 @@
 
 #include "interpreter/interpreter.hpp"
 #include "memory/allocation.hpp"
+#include "runtime/arguments.hpp"
 #include "runtime/deoptimization.hpp"
 #include "jvmci/jvmciOptions.hpp"
 
@@ -81,6 +82,11 @@
  public:
 
   /**
+   * Parses *.properties files in jre/lib/jvmci/ and adds the properties to plist.
+   */
+  static void parse_properties(SystemProperty** plist);
+
+  /**
    * Parses the JVMCI specific VM options that were presented by the launcher and sets
    * the relevants Java fields.
    */
--- a/src/share/vm/runtime/arguments.cpp	Fri Jun 12 18:02:58 2015 +0200
+++ b/src/share/vm/runtime/arguments.cpp	Sat Jun 13 00:22:48 2015 +0200
@@ -44,6 +44,9 @@
 #include "utilities/macros.hpp"
 #include "utilities/stringUtils.hpp"
 #include "utilities/taskqueue.hpp"
+#ifdef JVMCI
+#include "jvmci/jvmciRuntime.hpp"
+#endif
 #ifdef TARGET_OS_FAMILY_linux
 # include "os_linux.inline.hpp"
 #endif
@@ -213,6 +216,10 @@
 
   // Set OS specific system properties values
   os::init_system_properties_values();
+
+#ifdef JVMCI
+  JVMCIRuntime::parse_properties(&_system_properties);
+#endif
 }