changeset 23311:54b4e75c6088

added get_jvmci_hotspot_version and get_jdk_hotspot_version to respectively query the HotSpot version JVMCI is based on and the version in the bootstrap JDK
author Doug Simon <doug.simon@oracle.com>
date Mon, 22 Feb 2016 14:14:37 +0100
parents e5b5170606a2
children fb20e2d4f0bc
files mx.jvmci/mx_jvmci.py
diffstat 1 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mx.jvmci/mx_jvmci.py	Thu Feb 11 12:29:40 2016 -1000
+++ b/mx.jvmci/mx_jvmci.py	Mon Feb 22 14:14:37 2016 +0100
@@ -869,6 +869,49 @@
     variant = {'client': 'compiler1', 'server': 'compiler2', 'client-nojvmci': 'compiler1', 'server-nojvmci': 'compiler2'}.get(vm, vm)
     return variant
 
+"""
+Represents a JDK HotSpot version derived from a build tag such as "jdk8u66-b16".
+"""
+class JDKHotSpotVersion:
+    def __init__(self, javaCompliance, update, build):
+        self.javaCompliance = javaCompliance
+        self.update = update
+        self.build = build
+
+    @staticmethod
+    def parse_tag(tag):
+        m = re.match(r'jdk8u(\d+)-b(\d+)', tag)
+        assert m, 'unrecognized jdk8 build tag: ' + tag
+        return JDKHotSpotVersion(mx.JavaCompliance('8'), m.group(1), m.group(2))
+
+    def __str__(self):
+        return '{}_{}_{}'.format(self.javaCompliance.value, self.update, self.build)
+
+    def __cmp__(self, other):
+        assert isinstance(other, JDKHotSpotVersion), 'cannot compare a JDKHotSpotVersion object with ' + type(other)
+        return cmp(str(self), str(other))
+
+def get_jvmci_hotspot_version():
+    """
+    Gets the upstream HotSpot version JVMCI is based on.
+    """
+    vc = mx.VC.get_vc(_suite.dir, abortOnError=False)
+    assert vc, 'expected jvmci-8 to be version controlled'
+    assert isinstance(vc, mx.HgConfig), 'expected jvmci-8 VC to be Mercurial, not ' + vc.proper_name
+    lines = vc.hg_command(_suite.dir, ['log', '-r', 'keyword("Added tag jdk8u")', '--template', '{desc}\\n'], quiet=True).strip().split('\n')
+    assert lines, 'no hg commits found that match "Added tag jdk8u..."'
+    versions = [line.split()[2] for line in lines]
+    return JDKHotSpotVersion.parse_tag(sorted(versions)[-1])
+
+def get_jdk_hotspot_version(tag=mx.DEFAULT_JDK_TAG):
+    """
+    Gets the HotSpot version in the JDK selected by `tag`.
+    """
+    jdk = mx.get_jdk(tag=tag)
+    output = subprocess.check_output([jdk.java, '-version'], stderr=subprocess.STDOUT)
+    m = re.search(r'Java\(TM\) SE Runtime Environment \(build 1.8.0_(\d+)-b(\d+)\)', output)
+    return JDKHotSpotVersion(jdk.javaCompliance, m.group(1), m.group(2))
+
 class HotSpotBuildTask(mx.NativeBuildTask):
     def __init__(self, project, args, vmbuild, vm):
         mx.NativeBuildTask.__init__(self, args, project)