# HG changeset patch # User Stefan Anzinger # Date 1406816953 25200 # Node ID 2f4487a0b588a7c454acca8357ec479352b8bd7a # Parent 62f295bdea36b767c406ddf6e09a7d700b98769d# Parent be59a1d392817608ca4fee2a84f6c541ce584029 Merge diff -r 62f295bdea36 -r 2f4487a0b588 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java Thu Jul 31 07:07:38 2014 -0700 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java Thu Jul 31 07:29:13 2014 -0700 @@ -31,22 +31,15 @@ /** * An instance of {@link Unsafe} for use within Graal. */ - public static final Unsafe unsafe = getUnsafe(); + public static final Unsafe unsafe; - private static Unsafe getUnsafe() { - try { - // this will fail if Graal is not part of the boot class path - return Unsafe.getUnsafe(); - } catch (SecurityException e) { - // nothing to do - } + static { try { Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe"); theUnsafeInstance.setAccessible(true); - return (Unsafe) theUnsafeInstance.get(Unsafe.class); + unsafe = (Unsafe) theUnsafeInstance.get(Unsafe.class); } catch (Exception e) { - // currently we rely on being able to use Unsafe... - throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e); + throw new RuntimeException("exception while trying to get Unsafe", e); } } @@ -55,7 +48,7 @@ * terminated C string. The native memory buffer is allocated via * {@link Unsafe#allocateMemory(long)}. The caller is responsible for releasing the buffer when * it is no longer needed via {@link Unsafe#freeMemory(long)}. - * + * * @return the native memory pointer of the C string created from {@code s} */ public static long createCString(String s) { @@ -65,7 +58,7 @@ /** * Reads a {@code '\0'} terminated C string from native memory and converts it to a * {@link String}. - * + * * @return a Java string */ public static String readCString(long address) { @@ -88,7 +81,7 @@ * terminated C string. The caller is responsible for ensuring the buffer is at least * {@code s.length() + 1} bytes long. The caller is also responsible for releasing the buffer * when it is no longer. - * + * * @return the value of {@code buf} */ public static long writeCString(String s, long buf) { diff -r 62f295bdea36 -r 2f4487a0b588 graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java --- a/graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java Thu Jul 31 07:07:38 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java Thu Jul 31 07:29:13 2014 -0700 @@ -26,27 +26,29 @@ import java.net.*; /** - * Utility to create a separate class loader for loading classes in {@code graal.jar}. + * Utility to create a separate class loader for loading classes in {@code graal.jar} and + * {@code graal-truffle.jar}. */ public class Factory { /** - * Creates a new class loader for loading classes in {@code graal.jar}. + * Creates a new class loader for loading classes in {@code graal.jar} and + * {@code graal-truffle.jar} * * Called from the VM. */ @SuppressWarnings("unused") private static ClassLoader newClassLoader() throws MalformedURLException { - URL[] urls = {getGraalJarUrl()}; + URL[] urls = {getGraalJarUrl("graal"), getGraalJarUrl("graal-truffle")}; return URLClassLoader.newInstance(urls); } /** - * Gets the URL for {@code graal.jar}. + * Gets the URL for {@code base.jar}. */ - private static URL getGraalJarUrl() throws MalformedURLException { + private static URL getGraalJarUrl(String base) throws MalformedURLException { File file = new File(System.getProperty("java.home")); - for (String name : new String[]{"lib", "graal.jar"}) { + for (String name : new String[]{"lib", base + ".jar"}) { file = new File(file, name); } diff -r 62f295bdea36 -r 2f4487a0b588 graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java --- a/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Thu Jul 31 07:07:38 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Thu Jul 31 07:29:13 2014 -0700 @@ -37,26 +37,46 @@ */ public class GenGraalRuntimeInlineHpp { - private static final ZipFile graalJar; + public static class GraalJars implements Iterable { + private final List jars = new ArrayList<>(2); - static { - String path = null; - String classPath = System.getProperty("java.class.path"); - for (String e : classPath.split(File.pathSeparator)) { - if (e.endsWith("graal.jar")) { - path = e; - break; + public GraalJars() { + String classPath = System.getProperty("java.class.path"); + for (String e : classPath.split(File.pathSeparator)) { + if (e.endsWith(File.separatorChar + "graal.jar") || e.endsWith(File.separatorChar + "graal-truffle.jar")) { + try { + jars.add(new ZipFile(e)); + } catch (IOException ioe) { + throw new InternalError(ioe); + } + } + } + if (jars.size() != 2) { + throw new InternalError("Could not find graal.jar or graal-truffle.jar on class path: " + classPath); } } - ZipFile zipFile = null; - try { - zipFile = new ZipFile(Objects.requireNonNull(path, "Could not find graal.jar on class path: " + classPath)); - } catch (IOException e) { - throw new InternalError(e); + + public Iterator iterator() { + List entries = new ArrayList<>(); + for (ZipFile jar : jars) { + entries.addAll(Collections.list(jar.entries())); + } + return entries.iterator(); } - graalJar = zipFile; + + public InputStream getInputStream(String classFilePath) throws IOException { + for (ZipFile jar : jars) { + ZipEntry entry = jar.getEntry(classFilePath); + if (entry != null) { + return jar.getInputStream(entry); + } + } + return null; + } } + private static final GraalJars graalJars = new GraalJars(); + public static void main(String[] args) { PrintStream out = System.out; try { @@ -73,8 +93,7 @@ */ private static void genGetServiceImpls(PrintStream out) throws Exception { final List> services = new ArrayList<>(); - for (final Enumeration e = graalJar.entries(); e.hasMoreElements();) { - final ZipEntry zipEntry = e.nextElement(); + for (ZipEntry zipEntry : graalJars) { String name = zipEntry.getName(); if (name.startsWith("META-INF/services/")) { String serviceName = name.substring("META-INF/services/".length()); @@ -223,7 +242,7 @@ Set> checked = new HashSet<>(); for (final OptionDescriptor option : options.values()) { Class cls = option.getDeclaringClass(); - OptionsVerifier.checkClass(cls, option, checked, graalJar); + OptionsVerifier.checkClass(cls, option, checked, graalJars); } return options; } diff -r 62f295bdea36 -r 2f4487a0b588 graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/OptionsVerifier.java --- a/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/OptionsVerifier.java Thu Jul 31 07:07:38 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/OptionsVerifier.java Thu Jul 31 07:29:13 2014 -0700 @@ -27,11 +27,11 @@ import java.io.*; import java.lang.reflect.*; import java.util.*; -import java.util.zip.*; import jdk.internal.org.objectweb.asm.*; import jdk.internal.org.objectweb.asm.Type; +import com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp.GraalJars; import com.oracle.graal.options.*; /** @@ -42,17 +42,16 @@ */ final class OptionsVerifier extends ClassVisitor { - public static void checkClass(Class cls, OptionDescriptor option, Set> checked, ZipFile graalJar) throws IOException { + public static void checkClass(Class cls, OptionDescriptor option, Set> checked, GraalJars graalJars) throws IOException { if (!checked.contains(cls)) { checked.add(cls); Class superclass = cls.getSuperclass(); if (superclass != null && !superclass.equals(Object.class)) { - checkClass(superclass, option, checked, graalJar); + checkClass(superclass, option, checked, graalJars); } String classFilePath = cls.getName().replace('.', '/') + ".class"; - ZipEntry entry = Objects.requireNonNull(graalJar.getEntry(classFilePath), "Could not find class file for " + cls.getName()); - ClassReader cr = new ClassReader(graalJar.getInputStream(entry)); + ClassReader cr = new ClassReader(Objects.requireNonNull(graalJars.getInputStream(classFilePath), "Could not find class file for " + cls.getName())); ClassVisitor cv = new OptionsVerifier(cls, option); cr.accept(cv, 0); diff -r 62f295bdea36 -r 2f4487a0b588 mx/mx_graal.py --- a/mx/mx_graal.py Thu Jul 31 07:07:38 2014 -0700 +++ b/mx/mx_graal.py Thu Jul 31 07:29:13 2014 -0700 @@ -30,6 +30,7 @@ from os.path import join, exists, dirname, basename from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER from outputparser import OutputParser, ValuesMatcher +import hashlib import mx import xml.dom.minidom import sanitycheck @@ -82,7 +83,8 @@ _minVersion = mx.VersionSpec('1.8') -JDK_UNIX_PERMISSIONS = 0755 +JDK_UNIX_PERMISSIONS_DIR = 0755 +JDK_UNIX_PERMISSIONS_FILE = 0644 def isVMSupported(vm): if 'client' in vm and len(platform.mac_ver()[0]) != 0: @@ -138,13 +140,11 @@ _vm = self.previousVm _vmbuild = self.previousBuild -def _chmodDir(chmodFlags, dirname, fnames): - os.chmod(dirname, chmodFlags) - for name in fnames: - os.chmod(os.path.join(dirname, name), chmodFlags) +def chmodRecursive(dirname, chmodFlagsDir): + def _chmodDir(chmodFlags, dirname, fnames): + os.chmod(dirname, chmodFlagsDir) -def chmodRecursive(dirname, chmodFlags): - os.path.walk(dirname, _chmodDir, chmodFlags) + os.path.walk(dirname, _chmodDir, chmodFlagsDir) def clean(args): """clean the GraalVM source tree""" @@ -380,7 +380,7 @@ return mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') -def _jdk(build='product', vmToCheck=None, create=False, installGraalJar=True): +def _jdk(build='product', vmToCheck=None, create=False, installJars=True): """ Get the JDK into which Graal is installed, creating it first if necessary. """ @@ -416,7 +416,7 @@ assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg if mx.get_os() != 'windows': - chmodRecursive(jdk, JDK_UNIX_PERMISSIONS) + chmodRecursive(jdk, JDK_UNIX_PERMISSIONS_DIR) shutil.move(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), 'original')) @@ -457,9 +457,11 @@ mx.log("The selected JDK directory does not (yet) exist: " + jdk) _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') - if installGraalJar: - _installGraalJarInJdks(mx.distribution('GRAAL')) - _installGraalJarInJdks(mx.distribution('GRAAL_LOADER')) + if installJars: + _installDistInJdks(mx.distribution('GRAAL')) + _installDistInJdks(mx.distribution('GRAAL_LOADER')) + _installDistInJdks(mx.distribution('TRUFFLE')) + _installDistInJdks(mx.distribution('GRAAL_TRUFFLE')) if vmToCheck is not None: jvmCfg = _vmCfgInJdk(jdk) @@ -485,34 +487,71 @@ os.unlink(toDelete) def _makeHotspotGeneratedSourcesDir(): + """ + Gets the directory containing all the HotSpot sources generated from + Graal Java sources. This directory will be created if it doesn't yet exist. + """ hsSrcGenDir = join(mx.project('com.oracle.graal.hotspot').source_gen_dir(), 'hotspot') if not exists(hsSrcGenDir): os.makedirs(hsSrcGenDir) return hsSrcGenDir +def _update_graalRuntime_inline_hpp(dist): + """ + (Re)generates graalRuntime.inline.hpp based on a given distribution + that transitively represents all the input for the generation process. -def _update_graalRuntime_inline_hpp(graalJar): + A SHA1 digest is computed for all generated content and is written to + graalRuntime.inline.hpp as well as stored in a generated class + that is appended to the dist.path jar. At runtime, these two digests + are checked for consistency. + """ + p = mx.project('com.oracle.graal.hotspot.sourcegen') mainClass = 'com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp' if exists(join(p.output_dir(), mainClass.replace('.', os.sep) + '.class')): - graalRuntime_inline_hpp = join(_makeHotspotGeneratedSourcesDir(), 'graalRuntime.inline.hpp') + genSrcDir = _makeHotspotGeneratedSourcesDir() + graalRuntime_inline_hpp = join(genSrcDir, 'graalRuntime.inline.hpp') + cp = os.pathsep.join([mx.distribution(d).path for d in dist.distDependencies] + [dist.path, p.output_dir()]) tmp = StringIO.StringIO() - mx.run_java(['-cp', '{}{}{}'.format(graalJar, os.pathsep, p.output_dir()), mainClass], out=tmp.write) + mx.run_java(['-cp', cp, mainClass], out=tmp.write) + + # Compute SHA1 for currently generated graalRuntime.inline.hpp content + # and all other generated sources in genSrcDir + d = hashlib.sha1() + d.update(tmp.getvalue()) + for e in os.listdir(genSrcDir): + if e != 'graalRuntime.inline.hpp': + with open(join(genSrcDir, e)) as fp: + d.update(fp.read()) + sha1 = d.hexdigest() + + # Add SHA1 to end of graalRuntime.inline.hpp + print >> tmp, '' + print >> tmp, 'const char* GraalRuntime::_generated_sources_sha1 = "' + sha1 + '";' + mx.update_file(graalRuntime_inline_hpp, tmp.getvalue()) -def _checkVMIsNewerThanGeneratedSources(jdk, vm, bld): - if isGraalEnabled(vm) and (not _installed_jdks or _installed_jdks == _graal_home): - vmLib = mx.TimeStampFile(join(_vmLibDirInJdk(jdk), vm, mx.add_lib_prefix(mx.add_lib_suffix('jvm')))) - for name in ['graalRuntime.inline.hpp', 'HotSpotVMConfig.inline.hpp']: - genSrc = join(_makeHotspotGeneratedSourcesDir(), name) - if vmLib.isOlderThan(genSrc): - mx.log('The VM ' + vmLib.path + ' is older than ' + genSrc) - mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build"') + # Store SHA1 in generated Java class and append class to specified jar + javaSource = join(_graal_home, 'GeneratedSourcesSha1.java') + javaClass = join(_graal_home, 'GeneratedSourcesSha1.class') + with open(javaSource, 'w') as fp: + print >> fp, 'class GeneratedSourcesSha1 { private static final String value = "' + sha1 + '"; }' + subprocess.check_call([mx.java().javac, '-d', _graal_home, javaSource], stderr=subprocess.PIPE, stdout=subprocess.PIPE) + zf = zipfile.ZipFile(dist.path, 'a') + with open(javaClass, 'rb') as fp: + zf.writestr(os.path.basename(javaClass), fp.read()) + zf.close() + os.unlink(javaSource) + os.unlink(javaClass) -def _installGraalJarInJdks(graalDist): - graalJar = graalDist.path - if graalJar.endswith('graal.jar'): - _update_graalRuntime_inline_hpp(graalJar) +def _installDistInJdks(dist): + """ + Installs the jar(s) for a given Distribution into all existing Graal JDKs + """ + + if dist.name == 'GRAAL_TRUFFLE': + _update_graalRuntime_inline_hpp(dist) jdks = _jdksDir() if exists(jdks): @@ -524,7 +563,7 @@ dstJar = join(dstDir, name) if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true': # Using symlinks is much faster than copying but may - # cause issues if graal.jar is being updated while + # cause issues if the jar is being updated while # the VM is running. if not os.path.islink(dstJar) or not os.path.realpath(dstJar) == srcJar: if exists(dstJar): @@ -536,11 +575,11 @@ shutil.copyfile(srcJar, tmp) os.close(fd) shutil.move(tmp, dstJar) - os.chmod(dstJar, JDK_UNIX_PERMISSIONS) + os.chmod(dstJar, JDK_UNIX_PERMISSIONS_FILE) - install(graalJar, jreLibDir) - if graalDist.sourcesPath: - install(graalDist.sourcesPath, join(jdks, e)) + install(dist.path, jreLibDir) + if dist.sourcesPath: + install(dist.sourcesPath, join(jdks, e)) # run a command in the windows SDK Debug Shell def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): @@ -605,7 +644,7 @@ def jdkhome(vm=None): """return the JDK directory selected for the 'vm' command""" build = _vmbuild if _vmSourcesAvailable else 'product' - return _jdk(build, installGraalJar=False) + return _jdk(build, installJars=False) def print_jdkhome(args, vm=None): """print the JDK directory selected for the 'vm' command""" @@ -740,7 +779,7 @@ vmDir = join(_vmLibDirInJdk(jdk), vm) if not exists(vmDir): if mx.get_os() != 'windows': - chmodRecursive(jdk, JDK_UNIX_PERMISSIONS) + chmodRecursive(jdk, JDK_UNIX_PERMISSIONS_DIR) mx.log('Creating VM directory in JDK: ' + vmDir) os.makedirs(vmDir) @@ -874,7 +913,7 @@ if not found: mx.log('Appending "' + prefix + 'KNOWN" to ' + jvmCfg) if mx.get_os() != 'windows': - os.chmod(jvmCfg, JDK_UNIX_PERMISSIONS) + os.chmod(jvmCfg, JDK_UNIX_PERMISSIONS_FILE) with open(jvmCfg, 'w') as f: for line in lines: if line.startswith(prefix): @@ -912,9 +951,8 @@ mx.abort("conflicting working directories: do not set --vmcwd for this command") build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' - jdk = _jdk(build, vmToCheck=vm, installGraalJar=False) + jdk = _jdk(build, vmToCheck=vm, installJars=False) _updateInstalledGraalOptionsFile(jdk) - _checkVMIsNewerThanGeneratedSources(jdk, vm, build) mx.expand_project_in_args(args) if _make_eclipse_launch: mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) @@ -2234,5 +2272,7 @@ global _vm_prefix _vm_prefix = opts.vm_prefix - mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) - mx.distribution('GRAAL_LOADER').add_update_listener(_installGraalJarInJdks) + mx.distribution('GRAAL').add_update_listener(_installDistInJdks) + mx.distribution('GRAAL_LOADER').add_update_listener(_installDistInJdks) + mx.distribution('TRUFFLE').add_update_listener(_installDistInJdks) + mx.distribution('GRAAL_TRUFFLE').add_update_listener(_installDistInJdks) diff -r 62f295bdea36 -r 2f4487a0b588 mx/projects --- a/mx/projects Thu Jul 31 07:07:38 2014 -0700 +++ b/mx/projects Thu Jul 31 07:29:13 2014 -0700 @@ -88,8 +88,6 @@ distribution@GRAAL@dependencies=\ com.oracle.graal.hotspot.amd64,\ com.oracle.graal.hotspot.ptx,\ -com.oracle.graal.truffle,\ -com.oracle.graal.truffle.hotspot.amd64,\ com.oracle.graal.hotspot.sparc,\ com.oracle.graal.hotspot,\ com.oracle.graal.hotspot.jfr,\ @@ -107,6 +105,15 @@ distribution@TRUFFLE@dependencies=\ com.oracle.truffle.api.dsl +distribution@GRAAL_TRUFFLE@path=graal-truffle.jar +distribution@GRAAL_TRUFFLE@subDir=graal +distribution@GRAAL_TRUFFLE@sourcesPath=graal-truffle-sources.jar +distribution@GRAAL_TRUFFLE@dependencies=\ +com.oracle.graal.truffle,\ +com.oracle.graal.truffle.hotspot.amd64 +distribution@GRAAL_TRUFFLE@exclude=FINDBUGS +distribution@GRAAL_TRUFFLE@distDependencies=GRAAL,TRUFFLE + distribution@TRUFFLE-DSL-PROCESSOR@path=truffle-dsl-processor.jar distribution@TRUFFLE-DSL-PROCESSOR@subDir=graal distribution@TRUFFLE-DSL-PROCESSOR@sourcesPath=truffle-dsl-processor-sources.jar diff -r 62f295bdea36 -r 2f4487a0b588 mxtool/mx.py --- a/mxtool/mx.py Thu Jul 31 07:07:38 2014 -0700 +++ b/mxtool/mx.py Thu Jul 31 07:29:13 2014 -0700 @@ -1006,7 +1006,7 @@ logv('[omitting project {} as dependency {} is missing]'.format(d, name)) del _projects[d.name] self.projects.remove(d) - for dist in _dists.values(): + for dist in _dists.itervalues(): for name in list(dist.deps): if not dependency(name, fatalIfMissing=False): logv('[omitting {} from distribution {}]'.format(name, dist)) @@ -1315,6 +1315,23 @@ return sorted_project_deps(projects, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors) +def sorted_dists(): + """ + Gets distributions sorted such that each distribution comes after + any distributions it depends upon. + """ + dists = [] + def add_dist(dist): + if not dist in dists: + for depDist in [distribution(name) for name in dist.distDependencies]: + add_dist(depDist) + if not dist in dists: + dists.append(dist) + + for d in _dists.itervalues(): + add_dist(d) + return dists + def sorted_project_deps(projects, includeLibs=False, includeJreLibs=False, includeAnnotationProcessors=False): deps = [] for p in projects: @@ -2392,7 +2409,7 @@ log('Compiling {} failed'.format(t.proj.name)) abort('{} Java compilation tasks failed'.format(len(failed))) - for dist in _dists.values(): + for dist in sorted_dists(): archive(['@' + dist.name]) if suppliedParser: @@ -3457,12 +3474,6 @@ if buildProcessorJars: files += _processorjars_suite(suite) - projToDist = dict() - for dist in _dists.values(): - distDeps = dist.sorted_deps() - for p in distDeps: - projToDist[p.name] = (dist, [dep.name for dep in distDeps]) - for p in suite.projects: if p.native: continue @@ -3496,10 +3507,12 @@ out.open('projects') for p in distProjects: out.element('project', data=p.name) + for d in dist.distDependencies: + out.element('project', data=d) out.close('projects') out.open('buildSpec') dist.dir = projectDir - dist.javaCompliance = max([p.javaCompliance for p in distProjects]) + dist.javaCompliance = max([p.javaCompliance for p in distProjects] + [JavaCompliance('1.8')]) _genEclipseBuilder(out, dist, 'Create' + dist.name + 'Dist', 'archive @' + dist.name, relevantResources=relevantResources, logToFile=True, refresh=False, async=True) out.close('buildSpec') out.open('natures') diff -r 62f295bdea36 -r 2f4487a0b588 src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Thu Jul 31 07:07:38 2014 -0700 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Jul 31 07:29:13 2014 -0700 @@ -52,6 +52,7 @@ #ifdef GRAAL #include "graal/graalCompiler.hpp" #ifdef COMPILERGRAAL +#include "graal/graalRuntime.hpp" #include "runtime/vframe.hpp" #endif #endif @@ -1204,6 +1205,12 @@ break; } } + + // Don't allow blocking compilation requests to Graal + // if Graal itself is not yet initialized + if (!GraalRuntime::is_HotSpotGraalRuntime_initialized() && compiler(comp_level)->is_graal()) { + blocking = false; + } } // Don't allow blocking compiles #endif diff -r 62f295bdea36 -r 2f4487a0b588 src/share/vm/graal/graalGlobals.hpp --- a/src/share/vm/graal/graalGlobals.hpp Thu Jul 31 07:07:38 2014 -0700 +++ b/src/share/vm/graal/graalGlobals.hpp Thu Jul 31 07:29:13 2014 -0700 @@ -49,7 +49,7 @@ product(bool, DebugGraal, true, \ "Enable JVMTI for the compiler thread") \ \ - product(bool, UseGraalClassLoader, false, \ + product(bool, UseGraalClassLoader, true, \ "Load Graal classes with separate class loader") \ \ COMPILERGRAAL_PRESENT(product(bool, BootstrapGraal, true, \ diff -r 62f295bdea36 -r 2f4487a0b588 src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Thu Jul 31 07:07:38 2014 -0700 +++ b/src/share/vm/graal/graalRuntime.cpp Thu Jul 31 07:29:13 2014 -0700 @@ -663,9 +663,26 @@ return JNIHandles::make_local((oop) result.get_jobject()); JVM_END +void GraalRuntime::check_generated_sources_sha1(TRAPS) { + TempNewSymbol name = SymbolTable::new_symbol("GeneratedSourcesSha1", CHECK_ABORT); + KlassHandle klass = load_required_class(name); + fieldDescriptor fd; + if (!InstanceKlass::cast(klass())->find_field(vmSymbols::value_name(), vmSymbols::string_signature(), true, &fd)) { + THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), "GeneratedSourcesSha1.value"); + } + + Symbol* value = java_lang_String::as_symbol(klass->java_mirror()->obj_field(fd.offset()), CHECK); + if (!value->equals(_generated_sources_sha1)) { + char buf[200]; + jio_snprintf(buf, sizeof(buf), "Generated sources SHA1 check failed (%s != %s) - need to rebuild the VM", value->as_C_string(), _generated_sources_sha1); + THROW_MSG(vmSymbols::java_lang_InternalError(), buf); + } +} + Handle GraalRuntime::get_HotSpotGraalRuntime() { if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) { Thread* THREAD = Thread::current(); + check_generated_sources_sha1(CHECK_ABORT_(Handle())); TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT_(Handle())); KlassHandle klass = load_required_class(name); TempNewSymbol runtime = SymbolTable::new_symbol("runtime", CHECK_ABORT_(Handle())); diff -r 62f295bdea36 -r 2f4487a0b588 src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Thu Jul 31 07:07:38 2014 -0700 +++ b/src/share/vm/graal/graalRuntime.hpp Thu Jul 31 07:29:13 2014 -0700 @@ -33,6 +33,7 @@ static jobject _HotSpotGraalRuntime_instance; static address _external_deopt_i2c_entry; + static const char* _generated_sources_sha1; /** * Reads the OptionValue object from a specified static field. @@ -101,6 +102,11 @@ */ static Handle create_Service(const char* name, TRAPS); + /** + * Checks that _generated_sources_sha1 equals GeneratedSourcesSha1.value. + */ + static void check_generated_sources_sha1(TRAPS); + public: static void initialize_natives(JNIEnv *env, jclass c2vmClass); @@ -173,7 +179,7 @@ static Klass* load_required_class(Symbol* name); /** - * Creates a separate class loader for classes in graal.jar. + * Creates a separate class loader for classes in graal.jar and graal-truffle.jar. */ static oop compute_graal_class_loader(TRAPS); diff -r 62f295bdea36 -r 2f4487a0b588 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Thu Jul 31 07:07:38 2014 -0700 +++ b/src/share/vm/runtime/arguments.cpp Thu Jul 31 07:29:13 2014 -0700 @@ -3252,7 +3252,7 @@ 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", home, (int)strlen(home), os::file_separator()[0], os::path_separator()[0])); + 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; } #endif diff -r 62f295bdea36 -r 2f4487a0b588 src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Thu Jul 31 07:07:38 2014 -0700 +++ b/src/share/vm/runtime/os.cpp Thu Jul 31 07:29:13 2014 -0700 @@ -1269,6 +1269,7 @@ #endif #ifdef GRAAL "%/lib/graal-loader.jar:" + "%/lib/truffle.jar:" #endif "%/classes"; char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);