changeset 21607:71b338926f2e

moved JVMCI classes into their own distributions (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Fri, 29 May 2015 22:27:38 +0200
parents 625b2b12b418
children 4a8d4ee0fdd6
files graal/com.oracle.jvmci.hotspot.loader/src/com/oracle/jvmci/hotspot/loader/Factory.java graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/JVMCIClassLoaderFactory.java graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java make/defs.make mx/mx_graal.py mx/suite.py src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/prims/nativeLookup.cpp src/share/vm/runtime/os.cpp
diffstat 9 files changed, 146 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.jvmci.hotspot.loader/src/com/oracle/jvmci/hotspot/loader/Factory.java	Fri May 29 13:19:05 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2014, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.jvmci.hotspot.loader;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Utility to create and register a separate class loader for loading JVMCI classes (i.e., those in
- * found in lib/jvmci/*.jar).
- */
-public class Factory {
-
-    /**
-     * Copy of the {@code UseJVMCIClassLoader} VM option. Set by the VM before the static
-     * initializer is called.
-     */
-    private static boolean useJVMCIClassLoader;
-
-    /**
-     * Registers the JVMCI class loader in the VM.
-     */
-    private static native void init(ClassLoader loader);
-
-    static {
-        init(useJVMCIClassLoader ? newClassLoader() : null);
-    }
-
-    /**
-     * Creates a new class loader for loading JVMCI classes.
-     */
-    private static ClassLoader newClassLoader() {
-        URL[] urls = getJVMCIJarsUrls();
-        ClassLoader parent = null;
-        return URLClassLoader.newInstance(urls, parent);
-    }
-
-    /**
-     * Gets the URLs for lib/jvmci/*.jar.
-     */
-    private static URL[] getJVMCIJarsUrls() {
-        File javaHome = new File(System.getProperty("java.home"));
-        File lib = new File(javaHome, "lib");
-        File jvmci = new File(lib, "jvmci");
-        if (!jvmci.exists()) {
-            throw new InternalError(jvmci + " does not exist");
-        }
-
-        List<URL> urls = new ArrayList<>();
-        for (String fileName : jvmci.list()) {
-            if (fileName.endsWith(".jar")) {
-                File file = new File(jvmci, fileName);
-                if (file.isDirectory()) {
-                    continue;
-                }
-                try {
-                    urls.add(file.toURI().toURL());
-                } catch (MalformedURLException e) {
-                    throw new InternalError(e);
-                }
-            }
-        }
-
-        return urls.toArray(new URL[urls.size()]);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/JVMCIClassLoaderFactory.java	Fri May 29 22:27:38 2015 +0200
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.jvmci.service;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+/**
+ * Utility called from the VM to create and register a separate class loader for loading JVMCI
+ * classes (i.e., those in found in lib/jvmci/*.jar).
+ */
+class JVMCIClassLoaderFactory {
+
+    /**
+     * Copy of the {@code UseJVMCIClassLoader} VM option. Set by the VM before the static
+     * initializer is called.
+     */
+    private static boolean useJVMCIClassLoader;
+
+    /**
+     * Registers the JVMCI class loader in the VM.
+     */
+    private static native void init(ClassLoader loader);
+
+    static {
+        init(useJVMCIClassLoader ? newClassLoader() : null);
+    }
+
+    /**
+     * Creates a new class loader for loading JVMCI classes.
+     */
+    private static ClassLoader newClassLoader() {
+        URL[] urls = getJVMCIJarsUrls();
+        ClassLoader parent = null;
+        return URLClassLoader.newInstance(urls, parent);
+    }
+
+    /**
+     * Gets the URLs for lib/jvmci/*.jar.
+     */
+    private static URL[] getJVMCIJarsUrls() {
+        File javaHome = new File(System.getProperty("java.home"));
+        File lib = new File(javaHome, "lib");
+        File jvmci = new File(lib, "jvmci");
+        if (!jvmci.exists()) {
+            throw new InternalError(jvmci + " does not exist");
+        }
+
+        List<URL> urls = new ArrayList<>();
+        for (String fileName : jvmci.list()) {
+            if (fileName.endsWith(".jar")) {
+                File file = new File(jvmci, fileName);
+                if (file.isDirectory()) {
+                    continue;
+                }
+                try {
+                    urls.add(file.toURI().toURL());
+                } catch (MalformedURLException e) {
+                    throw new InternalError(e);
+                }
+            }
+        }
+
+        return urls.toArray(new URL[urls.size()]);
+    }
+}
--- a/graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java	Fri May 29 13:19:05 2015 -0700
+++ b/graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java	Fri May 29 22:27:38 2015 +0200
@@ -26,6 +26,8 @@
 
 import java.util.*;
 
+import sun.reflect.*;
+
 /**
  * A mechanism on top of the standard {@link ServiceLoader} that enables a runtime to efficiently
  * load services marked by {@link Service}. This may be important for services loaded early in the
@@ -50,15 +52,19 @@
      * Gets an {@link Iterable} of the implementations available for a given service.
      */
     @SuppressWarnings("unchecked")
+    @CallerSensitive
     public static <S> Iterable<S> load(Class<S> service) {
         if (Service.class.isAssignableFrom(service)) {
             try {
                 return (Iterable<S>) cache.get(service);
             } catch (UnsatisfiedLinkError e) {
-                // Fall back to standard SerivceLoader
+                // Fall back to standard ServiceLoader
             }
         }
-        return ServiceLoader.load(service, Services.class.getClassLoader());
+
+        // Need to use the ClassLoader of the caller
+        ClassLoader cl = Reflection.getCallerClass().getClassLoader();
+        return ServiceLoader.load(service, cl);
     }
 
     private static native <S> S[] getServiceImpls(Class<?> service);
--- a/make/defs.make	Fri May 29 13:19:05 2015 -0700
+++ b/make/defs.make	Fri May 29 22:27:38 2015 +0200
@@ -358,10 +358,12 @@
 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h
 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h
 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h
-EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/jvmci-loader.jar
+EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/jvmci-service.jar
 EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/truffle.jar
 EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/graal.jar
 EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/graal-truffle.jar
+EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/jvmci-api.jar
+EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/jvmci-hotspot.jar
 
 EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotJVMCIBackendFactory
 EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotVMEventListener
--- a/mx/mx_graal.py	Fri May 29 13:19:05 2015 -0700
+++ b/mx/mx_graal.py	Fri May 29 22:27:38 2015 +0200
@@ -95,7 +95,9 @@
 
 _jdkDeployedDists = [
     JDKDeployedDist('TRUFFLE'),
-    JDKDeployedDist('JVMCI_LOADER'),
+    JDKDeployedDist('JVMCI_SERVICE'),
+    JDKDeployedDist('JVMCI_API', usesJVMCIClassLoader=True),
+    JDKDeployedDist('JVMCI_HOTSPOT', usesJVMCIClassLoader=True),
     JDKDeployedDist('GRAAL', usesJVMCIClassLoader=True),
     JDKDeployedDist('GRAAL_TRUFFLE', usesJVMCIClassLoader=True)
 ]
@@ -667,10 +669,10 @@
 
 def _updateJVMCIFiles(jdkDir):
     jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci')
-    graalJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.startswith('graal') and e.endswith('.jar')]
+    jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')]
     jreGraalServicesDir = join(jreJVMCIDir, 'services')
     jreGraalOptionsDir = join(jreJVMCIDir, 'options')
-    _extractJVMCIFiles(graalJars, jreGraalServicesDir, jreGraalOptionsDir)
+    _extractJVMCIFiles(jvmciJars, jreGraalServicesDir, jreGraalOptionsDir)
 
 def _patchGraalVersionConstant(dist):
     """
--- a/mx/suite.py	Fri May 29 13:19:05 2015 -0700
+++ b/mx/suite.py	Fri May 29 22:27:38 2015 +0200
@@ -358,15 +358,6 @@
       "workingSets" : "Graal,HotSpot",
     },
 
-    "com.oracle.jvmci.hotspot.loader" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,HotSpot",
-    },
-
     "com.oracle.graal.hotspot.jfr" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -1248,6 +1239,41 @@
   },
 
   "distributions" : {
+
+    "JVMCI_SERVICE" : {
+      "path" : "build/jvmci-service.jar",
+      "subDir" : "graal",
+      "sourcesPath" : "build/jvmci-service.src.zip",
+      "dependencies" : ["com.oracle.jvmci.service"],
+      "exclude" : ["FINDBUGS"],
+    },
+
+    "JVMCI_API" : {
+      "path" : "build/jvmci-api.jar",
+      "subDir" : "graal",
+      "sourcesPath" : "build/jvmci-api.src.zip",
+      "dependencies" : [
+        "com.oracle.jvmci.runtime",
+        "com.oracle.jvmci.options",
+        "com.oracle.jvmci.common",
+        "com.oracle.jvmci.debug",
+      ],
+      "exclude" : ["FINDBUGS"],
+      "distDependencies" : [
+        "JVMCI_SERVICE",
+      ],
+    },
+
+    "JVMCI_HOTSPOT" : {
+      "path" : "build/jvmci-hotspot.jar",
+      "subDir" : "graal",
+      "sourcesPath" : "build/jvmci-hotspot.src.zip",
+      "dependencies" : ["com.oracle.jvmci.hotspot"],
+      "distDependencies" : [
+        "JVMCI_API",
+      ],
+    },
+
     "GRAAL" : {
       "path" : "build/graal.jar",
       "subDir" : "graal",
@@ -1259,13 +1285,10 @@
         "com.oracle.graal.hotspot.jfr",
       ],
       "exclude" : ["FINDBUGS"],
-    },
-
-    "JVMCI_LOADER" : {
-      "path" : "build/jvmci-loader.jar",
-      "subDir" : "graal",
-      "sourcesPath" : "build/jvmci-loader.src.zip",
-      "dependencies" : ["com.oracle.jvmci.hotspot.loader"],
+      "distDependencies" : [
+        "JVMCI_HOTSPOT",
+        "TRUFFLE",
+      ],
     },
 
     "TRUFFLE" : {
@@ -1306,5 +1329,4 @@
       "distDependencies" : ["TRUFFLE"],
     }
   },
-
 }
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Fri May 29 13:19:05 2015 -0700
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Fri May 29 22:27:38 2015 +0200
@@ -623,7 +623,7 @@
   return value;
 JRT_END
 
-// private static void Factory.init()
+// private static void JVMCIClassLoaderFactory.init()
 JVM_ENTRY(void, JVM_InitJVMCIClassLoader(JNIEnv *env, jclass c, jobject loader_handle))
   SystemDictionary::init_jvmci_loader(JNIHandles::resolve(loader_handle));
   SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID;
@@ -722,7 +722,7 @@
   static Klass* _FactoryKlass = NULL;
   if (_FactoryKlass == NULL) {
     Thread* THREAD = Thread::current();
-    TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/loader/Factory", CHECK_ABORT);
+    TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/service/JVMCIClassLoaderFactory", CHECK_ABORT);
     KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, THREAD);
     if (HAS_PENDING_EXCEPTION) {
       static volatile int seen_error = 0;
--- a/src/share/vm/prims/nativeLookup.cpp	Fri May 29 13:19:05 2015 -0700
+++ b/src/share/vm/prims/nativeLookup.cpp	Fri May 29 22:27:38 2015 +0200
@@ -149,7 +149,7 @@
   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 #ifdef JVMCI
-  { CC"Java_com_oracle_jvmci_hotspot_loader_Factory_init",                     NULL, FN_PTR(JVM_InitJVMCIClassLoader)               },
+  { CC"Java_com_oracle_jvmci_service_JVMCIClassLoaderFactory_init",            NULL, FN_PTR(JVM_InitJVMCIClassLoader)               },
   { CC"Java_com_oracle_jvmci_runtime_JVMCI_initializeRuntime",                 NULL, FN_PTR(JVM_GetJVMCIRuntime)                    },
   { CC"Java_com_oracle_jvmci_service_Services_getServiceImpls",                NULL, FN_PTR(JVM_GetJVMCIServiceImpls)               },
   { CC"Java_com_oracle_truffle_api_Truffle_createRuntime",                     NULL, FN_PTR(JVM_CreateTruffleRuntime)               },
--- a/src/share/vm/runtime/os.cpp	Fri May 29 13:19:05 2015 -0700
+++ b/src/share/vm/runtime/os.cpp	Fri May 29 22:27:38 2015 +0200
@@ -1190,7 +1190,7 @@
         "%/lib/charsets.jar:"
         "%/lib/jfr.jar:"
 #ifdef JVMCI
-        "%/lib/jvmci-loader.jar:"
+        "%/lib/jvmci-service.jar:"
 #endif
 #ifndef NO_TRUFFLE_JAR
         "%/lib/truffle.jar:"