changeset 23319:c1935b089c01

8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler Reviewed-by: dnsimon, vlivanov Contributed-by: twisti
author Roland Schatz <roland.schatz@oracle.com>
date Fri, 11 Mar 2016 16:00:25 +0100
parents 293eb76b86d3
children d9ae6a4319be
files jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java mx.jvmci/mx_jvmci.py src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/jvmci/jvmciRuntime.hpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/thread.cpp
diffstat 7 files changed, 30 insertions(+), 122 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Tue Mar 08 10:01:31 2016 -0800
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Fri Mar 11 16:00:25 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 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/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Tue Mar 08 10:01:31 2016 -0800
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Fri Mar 11 16:00:25 2016 +0100
@@ -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/mx.jvmci/mx_jvmci.py	Tue Mar 08 10:01:31 2016 -0800
+++ b/mx.jvmci/mx_jvmci.py	Fri Mar 11 16:00:25 2016 +0100
@@ -687,14 +687,14 @@
     if exists(jvmciProperties):
         with open(jvmciProperties) as fp:
             for line in fp:
-                if line.startswith('jvmci.compiler='):
+                if line.startswith('jvmci.Compiler='):
                     compiler = line.strip().split('=')[1]
                     if compiler not in compilers:
                         lines.append(line.strip())
                 else:
                     lines.append(line.strip())
     for compiler in compilers:
-        lines.append("jvmci.compiler=" + compiler)
+        lines.append("jvmci.Compiler=" + compiler)
     createFile(lines)
 
 def _installDistInJdks(deployableDist):
@@ -1828,7 +1828,7 @@
             if isinstance(jdkDist, JvmciJDKDeployedDist):
                 if jdkDist._compilers:
                     jvmciCompiler = jdkDist._compilers[-1]
-                    args = ['-Djvmci.compiler=' + jvmciCompiler] + args
+                    args = ['-Djvmci.Compiler=' + jvmciCompiler] + args
                     break
 
         if '-version' in args:
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Tue Mar 08 10:01:31 2016 -0800
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Fri Mar 11 16:00:25 2016 +0100
@@ -47,7 +47,6 @@
 
 jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
 bool JVMCIRuntime::_HotSpotJVMCIRuntime_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);
@@ -824,66 +814,6 @@
   }
 }
 
-/**
- * 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, mtInternal);
-    os::closedir(dir);
-  }
-}
-
 #define CHECK_WARN_ABORT_(message) THREAD); \
   if (HAS_PENDING_EXCEPTION) { \
     warning(message); \
@@ -894,12 +824,6 @@
   } \
   (void)(0
 
-void JVMCIRuntime::save_compiler(const char* compiler) {
-  assert(compiler != NULL, "npe");
-  assert(_compiler == NULL, "cannot reassign JVMCI compiler");
-  _compiler = compiler;
-}
-
 Handle JVMCIRuntime::create_Service(const char* name, TRAPS) {
   TempNewSymbol kname = SymbolTable::new_symbol(name, CHECK_NH);
   Klass* k = resolve_or_fail(kname, CHECK_NH);
--- a/src/share/vm/jvmci/jvmciRuntime.hpp	Tue Mar 08 10:01:31 2016 -0800
+++ b/src/share/vm/jvmci/jvmciRuntime.hpp	Fri Mar 11 16:00:25 2016 +0100
@@ -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
@@ -71,7 +71,6 @@
  private:
   static jobject _HotSpotJVMCIRuntime_instance;
   static bool _HotSpotJVMCIRuntime_initialized;
-  static const char* _compiler;
 
   static int _trivial_prefixes_count;
   static char** _trivial_prefixes;
@@ -86,24 +85,14 @@
   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);
-
   /**
    * Ensures that the JVMCI class loader is initialized and the well known JVMCI classes are loaded.
    */
   static void ensure_jvmci_class_loader_is_initialized();
 
-  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
--- a/src/share/vm/runtime/arguments.cpp	Tue Mar 08 10:01:31 2016 -0800
+++ b/src/share/vm/runtime/arguments.cpp	Fri Mar 11 16:00:25 2016 +0100
@@ -212,10 +212,6 @@
 
   // Set OS specific system properties values
   os::init_system_properties_values();
-
-#if INCLUDE_JVMCI
-  JVMCIRuntime::init_system_properties(&_system_properties);
-#endif
 }
 
 
--- a/src/share/vm/runtime/thread.cpp	Tue Mar 08 10:01:31 2016 -0800
+++ b/src/share/vm/runtime/thread.cpp	Fri Mar 11 16:00:25 2016 +0100
@@ -3705,13 +3705,6 @@
     Chunk::start_chunk_pool_cleaner_task();
   }
 
-#if INCLUDE_JVMCI
-  const char* jvmciCompiler = Arguments::PropertyList_get_value(Arguments::system_properties(), "jvmci.compiler");
-  if (jvmciCompiler != NULL) {
-    JVMCIRuntime::save_compiler(jvmciCompiler);
-  }
-#endif
-
   // initialize compiler(s)
 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(COMPILERJVMCI)
   CompileBroker::compilation_init(THREAD);