changeset 35598:8d7bc466f490

8147470: update JVMCI mx extensions Reviewed-by: twisti
author dnsimon
date Mon, 25 Jan 2016 14:09:28 -1000
parents 0174e7c4489f
children cc774aa3d2fe 26de15de8faa
files hotspot/.mx.jvmci/mx_jvmci.py hotspot/.mx.jvmci/suite.py
diffstat 2 files changed, 72 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/.mx.jvmci/mx_jvmci.py	Tue Jan 26 00:25:20 2016 +0300
+++ b/hotspot/.mx.jvmci/mx_jvmci.py	Mon Jan 25 14:09:28 2016 -1000
@@ -40,6 +40,8 @@
 
 _suite = mx.suite('jvmci')
 
+JVMCI_VERSION = 9
+
 """
 Top level directory of the JDK source workspace.
 """
@@ -164,7 +166,6 @@
     def __init__(self, name):
         JvmciJDKDeployedDist.__init__(self, name)
 
-
 """
 The monolithic JVMCI distribution is deployed through use of -Xbootclasspath/p
 so that it's not necessary to run JDK make after editing JVMCI sources.
@@ -193,7 +194,7 @@
         # JDK9 must be bootstrapped with a JDK8
         compliance = mx.JavaCompliance('8')
         jdk8 = mx.get_jdk(compliance.exactMatch, versionDescription=compliance.value)
-        cmd = ['sh', 'configure', '--with-debug-level=' + _vm.debugLevel, '--disable-debug-symbols', '--disable-precompiled-headers',
+        cmd = ['sh', 'configure', '--with-debug-level=' + _vm.debugLevel, '--with-native-debug-symbols=none', '--disable-precompiled-headers',
                '--with-jvm-variants=' + _vm.jvmVariant, '--disable-warnings-as-errors', '--with-boot-jdk=' + jdk8.home]
         mx.run(cmd, cwd=_jdkSourceRoot)
     cmd = [mx.gmake_cmd(), 'CONF=' + _vm.debugLevel]
@@ -212,7 +213,15 @@
     mx.run(cmd, cwd=_jdkSourceRoot)
 
     if 'images' in cmd:
-        _create_jdk_bundle(jdkBuildDir)
+        jdkImageDir = join(jdkBuildDir, 'images', 'jdk')
+
+        # The OpenJDK build creates an empty cacerts file so copy one from
+        # the default JDK (which is assumed to be an OracleJDK)
+        srcCerts = join(mx.get_jdk(tag='default').home, 'jre', 'lib', 'security', 'cacerts')
+        dstCerts = join(jdkImageDir, 'lib', 'security', 'cacerts')
+        shutil.copyfile(srcCerts, dstCerts)
+
+        _create_jdk_bundle(jdkBuildDir, _vm.debugLevel, jdkImageDir)
 
 def _get_jdk_bundle_arches():
     """
@@ -227,15 +236,14 @@
         return ['sparcv9']
     mx.abort('Unsupported JDK bundle arch: ' + cpu)
 
-def _create_jdk_bundle(jdkBuildDir):
+def _create_jdk_bundle(jdkBuildDir, debugLevel, jdkImageDir):
     """
     Creates a tar.gz JDK archive, an accompanying tar.gz.sha1 file with its
     SHA1 signature plus symlinks to the archive for non-canonical architecture names.
     """
-    jdkImageDir = join(jdkBuildDir, 'images', 'jdk')
 
     arches = _get_jdk_bundle_arches()
-    jdkTgzPath = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}.tar.gz'.format(_get_openjdk_os(), arches[0]))
+    jdkTgzPath = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arches[0]))
     with mx.Archiver(jdkTgzPath, kind='tgz') as arc:
         mx.log('Creating ' + jdkTgzPath)
         for root, _, filenames in os.walk(jdkImageDir):
@@ -243,10 +251,6 @@
                 f = join(root, name)
                 arcname = 'jdk1.9.0/' + os.path.relpath(f, jdkImageDir)
                 arc.zf.add(name=f, arcname=arcname, recursive=False)
-        # The OpenJDK build creates an empty cacerts file so grab one from
-        # the default JDK which is assumed to be an OracleJDK
-        cacerts = join(mx.get_jdk(tag='default').home, 'jre', 'lib', 'security', 'cacerts')
-        arc.zf.add(name=cacerts, arcname='jdk1.9.0/lib/security/cacerts')
 
     with open(jdkTgzPath + '.sha1', 'w') as fp:
         mx.log('Creating ' + jdkTgzPath + '.sha1')
@@ -259,7 +263,7 @@
         os.symlink(source, link_name)
 
     for arch in arches[1:]:
-        link_name = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}.tar.gz'.format(_get_openjdk_os(), arch))
+        link_name = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arch))
         jdkTgzName = os.path.basename(jdkTgzPath)
         _create_link(jdkTgzName, link_name)
         _create_link(jdkTgzName + '.sha1', link_name + '.sha1')
@@ -759,6 +763,14 @@
 
         args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args
 
+        # Remove JVMCI jars from class path. They are only necessary when
+        # compiling with a javac from JDK8 or earlier.
+        cpIndex, cp = mx.find_classpath_arg(args)
+        if cp:
+            excluded = frozenset([dist.path for dist in _suite.dists])
+            cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded])
+            args[cpIndex] = cp
+
         jvmciModeArgs = _jvmciModes[_vm.jvmciMode]
         if jvmciModeArgs:
             bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists]
@@ -814,7 +826,7 @@
         _jvmci_jdks[debugLevel] = jdk
     return jdk
 
-class JVMCIJDKFactory(mx.JDKFactory):
+class JVMCI9JDKFactory(mx.JDKFactory):
     def getJDKConfig(self):
         jdk = get_jvmci_jdk(_vm.debugLevel)
         return jdk
@@ -838,8 +850,9 @@
 mx.add_argument('--jdk-debug-level', '--vmbuild', action='store', choices=_jdkDebugLevels + sorted(_legacyVmbuilds.viewkeys()), help='the JDK debug level to build/run (default: ' + _vm.debugLevel + ')')
 mx.add_argument('-I', '--use-jdk-image', action='store_true', help='build/run JDK image instead of exploded JDK')
 
+mx.addJDKFactory(_JVMCI_JDK_TAG, mx.JavaCompliance('9'), JVMCI9JDKFactory())
+
 def mx_post_parse_cmd_line(opts):
-    mx.addJDKFactory(_JVMCI_JDK_TAG, mx.JavaCompliance('9'), JVMCIJDKFactory())
     mx.set_java_command_default_jdk_tag(_JVMCI_JDK_TAG)
 
     jdkTag = mx.get_jdk_option().tag
@@ -867,3 +880,38 @@
 
     for jdkDist in jdkDeployedDists:
         jdkDist.post_parse_cmd_line()
+
+def _update_JDK9_STUBS_library():
+    """
+    Sets the "path" and "sha1" attributes of the "JDK9_STUBS" library.
+    """
+    jdk9InternalLib = _suite.suiteDict['libraries']['JDK9_STUBS']
+    jarInputDir = join(_suite.get_output_root(), 'jdk9-stubs')
+    jarPath = join(_suite.get_output_root(), 'jdk9-stubs.jar')
+
+    stubs = [
+        ('jdk.internal.misc', 'VM', """package jdk.internal.misc;
+public class VM {
+    public static String getSavedProperty(String key) {
+        throw new InternalError("should not reach here");
+    }
+}
+""")
+    ]
+
+    if not exists(jarPath):
+        sourceFiles = []
+        for (package, className, source) in stubs:
+            sourceFile = join(jarInputDir, package.replace('.', os.sep), className + '.java')
+            mx.ensure_dir_exists(os.path.dirname(sourceFile))
+            with open(sourceFile, 'w') as fp:
+                fp.write(source)
+            sourceFiles.append(sourceFile)
+        jdk = mx.get_jdk(tag='default')
+        mx.run([jdk.javac, '-d', jarInputDir] + sourceFiles)
+        mx.run([jdk.jar, 'cf', jarPath, '.'], cwd=jarInputDir)
+
+    jdk9InternalLib['path'] = jarPath
+    jdk9InternalLib['sha1'] = mx.sha1OfFile(jarPath)
+
+_update_JDK9_STUBS_library()
--- a/hotspot/.mx.jvmci/suite.py	Tue Jan 26 00:25:20 2016 +0300
+++ b/hotspot/.mx.jvmci/suite.py	Mon Jan 25 14:09:28 2016 -1000
@@ -1,5 +1,5 @@
 suite = {
-  "mxversion" : "5.5.12",
+  "mxversion" : "5.6.11",
   "name" : "jvmci",
   "url" : "http://openjdk.java.net/projects/graal",
   "developer" : {
@@ -24,7 +24,7 @@
 
   "defaultLicense" : "GPLv2-CPE",
 
-  # This puts mx/ as a sibiling of the JDK build configuration directories
+  # This puts mx/ as a sibling of the JDK build configuration directories
   # (e.g., macosx-x86_64-normal-server-release).
   "outputRoot" : "../build/mx/hotspot",
 
@@ -32,8 +32,6 @@
 
   "libraries" : {
 
-    # ------------- Libraries -------------
-
     "HCFDIS" : {
       "urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/hcfdis-3.jar"],
       "sha1" : "a71247c6ddb90aad4abf7c77e501acc60674ef57",
@@ -53,6 +51,13 @@
       "sha1" : "122b87ca88e41a415cf8b523fd3d03b4325134a3",
       "urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/batik-all-1.7.jar"],
     },
+
+    # Stubs for classes introduced in JDK9 that allow compilation with a JDK8 javac and Eclipse.
+    # The "path" and "sha1" attributes are added when mx_jvmci is loaded
+    # (see mx_jvmci._update_JDK9_STUBS_library()).
+    "JDK9_STUBS" : {
+        "license" : "GPLv2-CPE",
+     },
   },
 
   "projects" : {
@@ -163,6 +168,7 @@
         "jdk.vm.ci.inittimer",
         "jdk.vm.ci.runtime",
         "jdk.vm.ci.services",
+        "JDK9_STUBS",
       ],
       "checkstyle" : "jdk.vm.ci.services",
       "javaCompliance" : "1.8",
@@ -298,6 +304,7 @@
         "jdk.vm.ci.hotspot.amd64",
         "jdk.vm.ci.hotspot.sparc",
       ],
+      "exclude" : ["JDK9_STUBS"]
     },
   },
 }