Mercurial > hg > truffle
changeset 21040:12e94cba3696
Graal Loader: load all jars matching lib/graal/graal*.jar
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 20 Apr 2015 17:56:38 +0200 |
parents | 13a255e29236 |
children | e121783a0df9 |
files | CHANGELOG.md graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java make/defs.make mx/mx_graal.py src/share/vm/runtime/arguments.cpp |
diffstat | 6 files changed, 83 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG.md Wed Apr 15 20:05:51 2015 +0200 +++ b/CHANGELOG.md Mon Apr 20 17:56:38 2015 +0200 @@ -8,6 +8,7 @@ * Add utilities ModifiersProvider#isConcrete, ResolvedJavaMethod#hasBytecodes, ResolvedJavaMethod#hasReceiver to Graal API. * Add `GraalDirectives` API, containing methods to influence compiler behavior for unittests and microbenchmarks. * Introduce `LIRSuites`, an extensible configuration for the low-level compiler pipeline. +* The Graal class loader now loads all lib/graal/graal*.jar jars * ... ### Truffle
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Wed Apr 15 20:05:51 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Mon Apr 20 17:56:38 2015 +0200 @@ -42,7 +42,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.graphbuilderconf.*; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; +import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.java.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; @@ -57,9 +57,8 @@ import com.oracle.graal.test.*; /** - * Checks that all classes in graal.jar (which must be on the class path) comply with global - * invariants such as using {@link Object#equals(Object)} to compare certain types instead of - * identity comparisons. + * Checks that all classes in graal*.jar from the boot classpath comply with global invariants such + * as using {@link Object#equals(Object)} to compare certain types instead of identity comparisons. */ public class CheckGraalInvariants extends GraalTest { @@ -82,31 +81,26 @@ bootclasspath.split(File.pathSeparator); final List<String> classNames = new ArrayList<>(); - for (String jarName : new String[]{"graal.jar", "graal-truffle.jar"}) { - - String jar = null; - for (String e : bootclasspath.split(File.pathSeparator)) { - if (e.endsWith(jarName)) { - jar = e; - break; + for (String path : bootclasspath.split(File.pathSeparator)) { + File file = new File(path); + String fileName = file.getName(); + if (fileName.startsWith("graal") && fileName.endsWith(".jar")) { + try { + final ZipFile zipFile = new ZipFile(file); + for (final Enumeration<? extends ZipEntry> entry = zipFile.entries(); entry.hasMoreElements();) { + final ZipEntry zipEntry = entry.nextElement(); + String name = zipEntry.getName(); + if (name.endsWith(".class")) { + String className = name.substring(0, name.length() - ".class".length()).replace('/', '.'); + classNames.add(className); + } + } + } catch (IOException ex) { + Assert.fail(ex.toString()); } } - Assert.assertNotNull("Could not find graal.jar on boot class path: " + bootclasspath, jar); - - try { - final ZipFile zipFile = new ZipFile(new File(jar)); - for (final Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) { - final ZipEntry zipEntry = e.nextElement(); - String name = zipEntry.getName(); - if (name.endsWith(".class")) { - String className = name.substring(0, name.length() - ".class".length()).replace('/', '.'); - classNames.add(className); - } - } - } catch (IOException e) { - Assert.fail(e.toString()); - } } + Assert.assertFalse("Could not find graal jars on boot class path: " + bootclasspath, classNames.isEmpty()); // Allows a subset of methods to be checked through use of a system property String property = System.getProperty(CheckGraalInvariants.class.getName() + ".filters");
--- a/graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java Wed Apr 15 20:05:51 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java Mon Apr 20 17:56:38 2015 +0200 @@ -24,10 +24,11 @@ import java.io.*; import java.net.*; +import java.util.*; /** * Utility to create and register a separate class loader for loading Graal classes (i.e., those in - * {@code graal.jar} and {@code graal-truffle.jar}). + * found in lib/graal/graal*.jar). */ public class Factory { @@ -47,32 +48,40 @@ } /** - * Creates a new class loader for loading classes in {@code graal.jar} and - * {@code graal-truffle.jar}. + * Creates a new class loader for loading graal classes. */ private static ClassLoader newClassLoader() { - URL[] urls = {getGraalJarUrl("graal"), getGraalJarUrl("graal-truffle")}; + URL[] urls = getGraalJarsUrls(); ClassLoader parent = null; return URLClassLoader.newInstance(urls, parent); } /** - * Gets the URL for {@code base.jar}. + * Gets the URLs for lib/graal/graal*.jar. */ - private static URL getGraalJarUrl(String base) { - File file = new File(System.getProperty("java.home")); - for (String name : new String[]{"lib", base + ".jar"}) { - file = new File(file, name); + private static URL[] getGraalJarsUrls() { + File javaHome = new File(System.getProperty("java.home")); + File lib = new File(javaHome, "lib"); + File graal = new File(lib, "graal"); + if (!graal.exists()) { + throw new InternalError(graal + " does not exist"); } - if (!file.exists()) { - throw new InternalError(file + " does not exist"); + List<URL> urls = new ArrayList<>(); + for (String fileName : graal.list()) { + if (fileName.startsWith("graal") && fileName.endsWith(".jar")) { + File file = new File(graal, fileName); + if (file.isDirectory()) { + continue; + } + try { + urls.add(file.toURI().toURL()); + } catch (MalformedURLException e) { + throw new InternalError(e); + } + } } - try { - return file.toURI().toURL(); - } catch (MalformedURLException e) { - throw new InternalError(e); - } + return urls.toArray(new URL[urls.size()]); } }
--- a/make/defs.make Wed Apr 15 20:05:51 2015 +0200 +++ b/make/defs.make Mon Apr 20 17:56:38 2015 +0200 @@ -341,6 +341,7 @@ EXPORT_JRE_BIN_DIR = $(EXPORT_JRE_DIR)/bin EXPORT_JRE_LIB_DIR = $(EXPORT_JRE_DIR)/lib EXPORT_JRE_LIB_EXT_DIR = $(EXPORT_JRE_LIB_DIR)/ext +EXPORT_JRE_LIB_GRAAL_DIR = $(EXPORT_JRE_LIB_DIR)/graal EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)/$(LIBARCH) # non-universal macosx builds need to appear universal @@ -356,8 +357,8 @@ 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)/graal.jar -EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/graal-truffle.jar +EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/graal.jar +EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/graal-truffle.jar EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/graal-loader.jar EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/truffle.jar
--- a/mx/mx_graal.py Wed Apr 15 20:05:51 2015 +0200 +++ b/mx/mx_graal.py Mon Apr 20 17:56:38 2015 +0200 @@ -614,14 +614,20 @@ if exists(jdks): for e in os.listdir(jdks): jreLibDir = join(jdks, e, 'jre', 'lib') - if deployableDist.isExtension: - jreLibDir = join(jreLibDir, 'ext') if exists(jreLibDir): - _copyToJdk(dist.path, jreLibDir) + if deployableDist.isExtension: + targetDir = join(jreLibDir, 'ext') + elif deployableDist.isGraalClassLoader: + targetDir = join(jreLibDir, 'graal') + else: + targetDir = jreLibDir + if not exists(targetDir): + os.makedirs(targetDir) + _copyToJdk(dist.path, targetDir) if dist.sourcesPath: _copyToJdk(dist.sourcesPath, join(jdks, e)) + # deploy service files if deployableDist.isGraalClassLoader: - assert not deployableDist.isExtension # deploy services files jreGraalServicesDir = join(jreLibDir, 'graal', 'services') if not exists(jreGraalServicesDir): @@ -801,6 +807,8 @@ defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) if jdkDist.isExtension: defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path) + elif jdkDist.isGraalClassLoader: + defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/' + basename(dist.path) else: defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) if defLine not in defs: @@ -2574,7 +2582,6 @@ for jdkDist in _jdkDeployedDists: def _close(jdkDeployable): def _install(dist): - mx.log("install " + dist.name) assert dist.name == jdkDeployable.name, dist.name + "!=" + jdkDeployable.name _installDistInJdks(jdkDeployable) return _install
--- a/src/share/vm/runtime/arguments.cpp Wed Apr 15 20:05:51 2015 +0200 +++ b/src/share/vm/runtime/arguments.cpp Mon Apr 20 17:56:38 2015 +0200 @@ -3621,10 +3621,28 @@ #ifdef GRAAL if (!UseGraalClassLoader) { - // Append graal.jar to boot class path - const char* home = Arguments::get_java_home(); - scp_p->add_suffix(os::format_boot_path("%/lib/graal.jar:%/lib/graal-truffle.jar", home, (int)strlen(home), os::file_separator()[0], os::path_separator()[0])); - scp_assembly_required = true; + // Append lib/graal/graal*.jar to boot class path + char graalDir[JVM_MAXPATHLEN]; + const char* fileSep = os::file_separator(); + jio_snprintf(graalDir, sizeof(graalDir), "%s%slib%sgraal", Arguments::get_java_home(), fileSep, fileSep); + DIR* dir = os::opendir(graalDir); + if (dir != NULL) { + struct dirent *entry; + char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(graalDir), mtInternal); + while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { + const char* name = entry->d_name; + const char* ext = name + strlen(name) - 4; + if (ext > name && strcmp(ext, ".jar") == 0 + && strlen(name) > strlen("graal") + && strncmp(name, "graal", strlen("graal")) == 0) { + char fileName[JVM_MAXPATHLEN]; + jio_snprintf(fileName, sizeof(fileName), "%s%s%s", graalDir, fileSep, name); + scp_p->add_suffix(fileName); + scp_assembly_required = true; + } + } + } + } #endif