Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gluon-bot committed Sep 14, 2023
2 parents a8b88e4 + 5623fe6 commit fac73de
Show file tree
Hide file tree
Showing 44 changed files with 565 additions and 619 deletions.
4 changes: 4 additions & 0 deletions ci/ci_common/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ common + common.frequencies + {
labsjdk21Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-21Debug"],
labsjdk21LLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-21-llvm"],

labsjdkLatest:: self["labsjdk-" + repo_config.graalvm_edition + "-22"],
labsjdkLatestDebug:: self["labsjdk-" + repo_config.graalvm_edition + "-22Debug"],
labsjdkLatestLLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-22-llvm"],

// Hardware definitions
// ********************
local graal_common_extras = common.deps.pylint + {
Expand Down
4 changes: 2 additions & 2 deletions ci/ci_common/run-spec-examples.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ local r = import "run-spec.libsonnet";
"jdk21": r.task_spec({
"target": "gate",
}),
"jdk22": r.task_spec({
"jdk-latest": r.task_spec({
"target": "gate",
}),
},
Expand All @@ -109,7 +109,7 @@ local r = import "run-spec.libsonnet";
"jdk19": {},
"jdk20": {},
"jdk21": {},
"jdk22": {},
"jdk-latest": {},
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion ci/ci_common/run-spec.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local examples = (import "run-spec-examples.libsonnet").examples;
// Supported platforms
supported_oss_names:: ["linux", "darwin", "windows"],
supported_archs_names:: ["amd64", "aarch64"],
supported_jdks_names:: ["jdk17", "jdk19", "jdk20", "jdk21", "jdk22"],
supported_jdks_names:: ["jdk17", "jdk19", "jdk20", "jdk21", "jdk-latest"],

// This will turn a task dictionary into a list of build objects.
process(task_dict)::
Expand Down
4 changes: 2 additions & 2 deletions ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local common_json = import "../common.json";
for name in ["oraclejdk21"] + variants("labsjdk-ce-21") + variants("labsjdk-ee-21")
} + {
[name]: common_json.jdks[name] + { jdk_version:: 22 }
for name in ["oraclejdk22"]
for name in variants("labsjdk-ce-22") + variants("labsjdk-ee-22")
},
assert std.assertEqual(std.objectFields(common_json.jdks), std.objectFields(jdks_data)),

Expand Down Expand Up @@ -59,7 +59,7 @@ local common_json = import "../common.json";
"windows-jdk19": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk20": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk21": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"windows-jdk22": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"windows-jdkLatest": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"linux-jdk17": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
"linux-jdk19": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
"linux-jdk20": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
Expand Down
7 changes: 6 additions & 1 deletion common.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },

"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "11", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
"labsjdk-ce-22": {"name": "labsjdk", "version": "ce-22+13-jvmci-b01", "platformspecific": true },
"labsjdk-ce-22Debug": {"name": "labsjdk", "version": "ce-22+13-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-22-llvm": {"name": "labsjdk", "version": "ce-22+13-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-22": {"name": "labsjdk", "version": "ee-22+13-jvmci-b01", "platformspecific": true },
"labsjdk-ee-22Debug": {"name": "labsjdk", "version": "ee-22+13-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-22-llvm": {"name": "labsjdk", "version": "ee-22+13-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
17 changes: 15 additions & 2 deletions compiler/ci/ci_common/gate.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"gate-compiler-test_zgc-labsjdk-21-darwin-aarch64": t("1:00:00"),

"gate-compiler-style-labsjdk-21-linux-amd64": t("45:00"),
"gate-compiler-build-labsjdk-latest-linux-amd64": t("25:00"),

"gate-compiler-ctw-labsjdk-21-linux-amd64": c.mach5_target,
"gate-compiler-ctw-labsjdk-21-windows-amd64": t("1:50:00"),
Expand Down Expand Up @@ -295,7 +296,7 @@
dailies_manifest=dailies,
weeklies_manifest=weeklies,
monthlies_manifest=monthlies):: {
local base_name = "%s-%s-%s-%s-%s" % [suite, task, jdk_name, jdk, os_arch],
local base_name = "%s-%s-%s-%s-%s" % [suite, task, jdk_name, if std.startsWith(jdk, "Latest") then "l" + jdk[1:] else jdk, os_arch],
local gate_name = "gate-" + base_name,
local daily_name = "daily-" + base_name,
local weekly_name = "weekly-" + base_name,
Expand Down Expand Up @@ -435,7 +436,18 @@
]
],

local style_builds = [self.make_build("21", "linux-amd64", "style").build],
local style_builds = [self.make_build("21", "linux-amd64", "style").build + {
environment+: {
# Run the strict JVMCI version check, i.e., that JVMCIVersionCheck.JVMCI_MIN_VERSION matches the versions in common.json.
JVMCI_VERSION_CHECK: "strict",
},
}],
local jdk_latest_version_check_builds = [self.make_build("Latest", "linux-amd64", "build", extra_tasks={build:: s.base("build"),}).build + {
environment+: {
# Run the strict JVMCI version check, i.e., that JVMCIVersionCheck.JVMCI_MIN_VERSION matches the versions in common.json.
JVMCI_VERSION_CHECK: "strict",
},
}],

# Builds run on only on linux-amd64-jdk21Debug
local linux_amd64_jdk21Debug_builds = [self.make_build("21Debug", "linux-amd64", task).build
Expand All @@ -450,6 +462,7 @@
all_zgc_builds +
all_serialgc_builds +
style_builds +
jdk_latest_version_check_builds +
linux_amd64_jdk21_builds +
linux_amd64_jdk21Debug_builds,

Expand Down
161 changes: 128 additions & 33 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,92 @@ def get_vm_prefix(asList=True):
#: The JDK used to build and run Graal.
jdk = mx.get_jdk(tag='default')

#: 3-tuple (major, minor, build) of JVMCI version, if any, denoted by `jdk`

class JavaLangRuntimeVersion(mx.Comparable):
"""Wrapper for by java.lang.Runtime.Version"""

_cmp_cache = {}
_feature_re = re.compile('[1-9][0-9]*')

def __init__(self, version, jdk=None):
self.version = version
self.jdk = jdk or mx.get_jdk()

def __str__(self):
return self.version

def __cmp__(self, other):
if not isinstance(other, JavaLangRuntimeVersion):
raise TypeError(f'Cannot compare {JavaLangRuntimeVersion.__name__} to {type(other).__name__}')
this_version = self.version
other_version = other.version
if this_version == other_version:
return 0
if self.feature() == 21 and other.feature() == 21:
# JDK 21 uses the legacy version scheme where the jdkVersion is irrelevant (and imprecise).
# Thus, we do not perform a full version check.
return 0
return JavaLangRuntimeVersion.compare(this_version, other_version, jdk)

@staticmethod
def compare(this_version, other_version, jdk):
key = (this_version, other_version)
cached = JavaLangRuntimeVersion._cmp_cache.get(key, None)
if cached is not None:
return cached
source_path = join(_suite.dir, 'src', 'jdk.internal.vm.compiler', 'src', 'org', 'graalvm', 'compiler',
'hotspot',
'JVMCIVersionCompare.java')
out = mx.OutputCapture()
mx.run([jdk.java, '-Xlog:disable', source_path, this_version, other_version], out=out)
ret = int(out.data)
JavaLangRuntimeVersion._cmp_cache[key] = ret
return ret

def feature(self):
if not hasattr(self, '_feature'):
self._feature = int(JavaLangRuntimeVersion._feature_re.match(self.version).group(0))
return self._feature


#: 4-tuple (jdk_version, jvmci_major, jvmci_minor, jvmci_build) of JVMCI version, if any, denoted by `jdk`
# jdk_version is a JavaLangRuntimeVersion
# jvmci_major and jvmci_minor might be 0 if not needed (JDK 22+)
_jdk_jvmci_version = None
_jdk_min_jvmci_version = None

if os.environ.get('JDK_VERSION_CHECK', None) != 'ignore' and jdk.javaCompliance < '17':
mx.abort('Graal requires JDK17 or later, got ' + str(jdk) +
if os.environ.get('JDK_VERSION_CHECK', None) != 'ignore' and jdk.javaCompliance < '21':
mx.abort('Graal requires JDK21 or later, got ' + str(jdk) +
'. This check can be bypassed by setting env var JDK_VERSION_CHECK=ignore')

def _check_jvmci_version(jdk):
"""
Runs a Java utility to check that `jdk` supports the minimum JVMCI API required by Graal.
"""
source_path = join(_suite.dir, 'src', 'jdk.internal.vm.compiler', 'src', 'org', 'graalvm', 'compiler', 'hotspot', 'JVMCIVersionCheck.java')
out = mx.OutputCapture()
mx.run([jdk.java, '-Xlog:disable', source_path], out=out)
def _capture_jvmci_version(args=None):
out = mx.OutputCapture()
_run_jvmci_version_check(args, jdk=jdk, out=out)
if out.data:
try:
(jdk_version, jvmci_major, jvmci_minor, jvmci_build) = out.data.split(',')
return (JavaLangRuntimeVersion(jdk_version), int(jvmci_major), int(jvmci_minor), int(jvmci_build))
except ValueError:
mx.warn(f'Could not parse jvmci version from JVMCIVersionCheck output:\n{out.data}')
return None

global _jdk_jvmci_version
if out.data:
try:
_jdk_jvmci_version = tuple((int(n) for n in out.data.split(',')))
except ValueError:
mx.warn(f'Could not parse jvmci version from JVMCIVersionCheck output:\n{out.data}')
_jdk_jvmci_version = _capture_jvmci_version()
global _jdk_min_jvmci_version
_jdk_min_jvmci_version = _capture_jvmci_version(['--min-version'])



@mx.command(_suite.name, 'jvmci-version-check')
def _run_jvmci_version_check(args=None, jdk=jdk, **kwargs):
source_path = join(_suite.dir, 'src', 'jdk.internal.vm.compiler', 'src', 'org', 'graalvm', 'compiler', 'hotspot',
'JVMCIVersionCheck.java')
return mx.run([jdk.java, '-Xlog:disable', source_path] + (args or []), **kwargs)


if os.environ.get('JVMCI_VERSION_CHECK', None) != 'ignore':
_check_jvmci_version(jdk)
Expand Down Expand Up @@ -1085,7 +1151,7 @@ def _check_latest_jvmci_version():
the JVMCI version of the JVMCI JDKs in the "jdks" section of the
``common.json`` file and issues a warning if not.
"""
jvmci_re = re.compile(r'.*-jvmci-(\d+)\.(\d+)-b(\d+)')
jvmci_re = re.compile(r'(?:ce|ee)-(?P<jdk_version>.+)-jvmci(?:-(?P<jvmci_major>\d+)\.(?P<jvmci_minor>\d+))?-b(?P<jvmci_build>\d+)')
common_path = join(_suite.dir, '..', 'common.json')

if _jdk_jvmci_version is None:
Expand All @@ -1096,35 +1162,64 @@ def get_latest_jvmci_version():
with open(common_path) as common_file:
common_cfg = json.load(common_file)

latest = None
latest = 'not found'
for distribution in common_cfg['jdks']:
version = common_cfg['jdks'][distribution].get('version', None)
if version and '-jvmci-' in version:
current = tuple(int(n) for n in jvmci_re.match(version).group(1, 2, 3))
if latest is None:
latest = current
elif latest != current:
# All JVMCI JDKs in common.json are expected to have the same JVMCI version.
# If they don't then the repo is in some transitionary state
# (e.g. making a JVMCI release) so skip the check.
return None
return latest
match = jvmci_re.match(version)
if not match:
mx.abort(f'Cannot parse version {version}')
(jdk_version, jvmci_major, jvmci_minor, jvmci_build) = match.groups(default=0)
current = (JavaLangRuntimeVersion(jdk_version), int(jvmci_major), int(jvmci_minor), int(jvmci_build))
if current[0].feature() == _jdk_jvmci_version[0].feature():
# only compare the same major versions
if latest == 'not found':
latest = current
elif latest != current:
# All JVMCI JDKs in common.json with the same major version
# are expected to have the same JVMCI version.
# If they don't then the repo is in some transitionary state
# (e.g. making a JVMCI release) so skip the check.
return False, distribution
return not isinstance(latest, str), latest

def jvmci_version_str(version):
major, minor, build = version
return 'jvmci-{}.{}-b{:02d}'.format(major, minor, build)
jdk_version, jvmci_major, jvmci_minor, jvmci_build = version
if jvmci_major == 0:
return f'labsjdk-(ce|ee)-{jdk_version}-jvmci-b{jvmci_build:02d}'
else:
return f'labsjdk-(ce|ee)-{jdk_version}-jvmci-{jvmci_major}.{jvmci_minor}-b{jvmci_build:02d}'

version_check_setting = os.environ.get('JVMCI_VERSION_CHECK', None)

success, latest = get_latest_jvmci_version()

if version_check_setting == 'strict' and _jdk_jvmci_version != _jdk_min_jvmci_version:
msg = f'JVMCI_MIN_VERSION specified in JVMCIVersionCheck.java is older than in {common_path}:'
msg += os.linesep + f'{jvmci_version_str(_jdk_min_jvmci_version)} < {jvmci_version_str(_jdk_jvmci_version)} '
msg += os.linesep + f'Did you forget to update JVMCI_MIN_VERSION after updating {common_path}?'
msg += os.linesep + 'Set the JVMCI_VERSION_CHECK environment variable to something else then "strict" to'
msg += ' suppress this error.'
mx.abort(msg)

if version_check_setting == 'strict' and not success:
if latest == 'not found':
msg = f'No JVMCI JDK found in {common_path} that matches {jvmci_version_str(_jdk_jvmci_version)}.'
msg += os.linesep + f'Check that {latest} matches the versions of the other JVMCI JDKs.'
else:
msg = f'Version mismatch in {common_path}:'
msg += os.linesep + f'Check that {latest} matches the versions of the other JVMCI JDKs.'
msg += os.linesep + 'Set the JVMCI_VERSION_CHECK environment variable to something else then "strict" to'
msg += ' suppress this error.'
mx.abort(msg)

latest = get_latest_jvmci_version()
if latest is not None and _jdk_jvmci_version < latest:
if success and _jdk_jvmci_version < latest:
common_path = os.path.normpath(common_path)
msg = 'JVMCI version of JAVA_HOME is older than in {}: {} < {} '.format(
common_path,
jvmci_version_str(_jdk_jvmci_version),
jvmci_version_str(latest))
msg = f'JVMCI version of JAVA_HOME is older than in {common_path}: {jvmci_version_str(_jdk_jvmci_version)} < {jvmci_version_str(latest)} '
msg += os.linesep + 'This poses the risk of hitting JVMCI bugs that have already been fixed.'
msg += os.linesep + 'Consider using {}, which you can get via:'.format(jvmci_version_str(latest))
msg += os.linesep + 'mx fetch-jdk --configuration {}'.format(common_path)
mx.warn(msg)
msg += os.linesep + f'Consider using {jvmci_version_str(latest)}, which you can get via:'
msg += os.linesep + f'mx fetch-jdk --configuration {common_path}'
mx.abort_or_warn(msg, version_check_setting == 'strict')

class GraalArchiveParticipant:
providersRE = re.compile(r'(?:META-INF/versions/([1-9][0-9]*)/)?META-INF/providers/(.+)')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2019, 2023, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 org.graalvm.compiler.hotspot.test;

import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.graalvm.compiler.hotspot.JVMCIVersionCheck;
import org.junit.Assert;
import org.junit.Test;

/**
* Test handling of version components bigger than Integer.MAX_VALUE.
*/
public class JVMCIVersionCheckMaxValueTest extends GraalCompilerTest {

public static final String EXPECTED_MSG = "Cannot read JVMCI version from java.vm.version property";

@Test
public void testLegacyVersion() {
for (String version : new String[]{"20.0-b" + Long.MAX_VALUE, "20." + Long.MAX_VALUE + "-b1", Long.MAX_VALUE + ".0-b1"}) {
testVersion(String.format("prefix-jvmci-%s-suffix", version));
}
}

@Test
public void testNewVersion() {
// We only want to test jvmciBuild, not Runtime.Version, so we use a fixed jdkVersion string
testVersion(String.format("99.0.1-jvmci-b%s-suffix", Long.MAX_VALUE));
}

private static void testVersion(String javaVmVersion) {
try {
JVMCIVersionCheck.Version minVersion = new JVMCIVersionCheck.Version(20, 0, 1);
// Use a javaSpecVersion that will likely not fail in the near future
JVMCIVersionCheck.check(JVMCIVersionCheckTest.props, minVersion, "99", javaVmVersion, false);
Assert.fail("expected to fail checking " + javaVmVersion + " against " + minVersion);
} catch (InternalError e) {
if (!e.getMessage().contains(EXPECTED_MSG)) {
throw new AssertionError("Unexpected exception message. Expected: " + EXPECTED_MSG, e);
}
}
}
}
Loading

0 comments on commit fac73de

Please sign in to comment.