Skip to content

Commit

Permalink
[JDK-8333292] Fix libgraal build broken by JDK-8331189.
Browse files Browse the repository at this point in the history
PullRequest: graal/17878
  • Loading branch information
zapster authored and liufengyun committed May 31, 2024
2 parents e1771d1 + 268aa8d commit 3bd8754
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 37 deletions.
2 changes: 1 addition & 1 deletion common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25-2038", "platformspecific": true, "extrabundles": ["static-libs"]},
"galahad-jdk": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25-2108", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk11": {"name": "jpg-jdk", "version": "11.0.11", "build_id": "jdk-11.0.11+9", "platformspecific": true, "extrabundles": ["static-libs"] },

Expand Down
10 changes: 5 additions & 5 deletions compiler/ci/ci_common/gate.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
bootstrap_full_zgc:: s.base("build,bootstrapfullverify", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC -XX:-ZGenerational"),
bootstrap_economy:: s.base("build,bootstrapeconomy", no_warning_as_error=true, extra_vm_args="-Djdk.graal.CompilerConfiguration=economy"),

style:: c.deps.eclipse + c.deps.jdt + s.base("style,fullbuild,javadoc") + galahad.include,
style:: c.deps.eclipse + c.deps.jdt + s.base("style,fullbuild,javadoc") + galahad.exclude,

avx3:: {
capabilities+: ["avx512"],
Expand Down Expand Up @@ -396,7 +396,7 @@
],

# Builds run on all platforms (platform = JDK + OS + ARCH)
local all_platforms_builds = [self.make_build(jdk, os_arch, task).build
local all_platforms_builds = [self.make_build(jdk, os_arch, task).build + galahad.exclude
for task in [
"test",
"truffle_xcomp",
Expand All @@ -417,7 +417,7 @@

# Coverage builds run on all platforms (platform = JDK + OS + ARCH)
# that support JaCoCo (GR-46676)
local all_coverage_builds = [self.make_build(jdk, os_arch, task).build
local all_coverage_builds = [self.make_build(jdk, os_arch, task).build + galahad.exclude
for task in [
"coverage",
"coverage_ctw",
Expand All @@ -433,7 +433,7 @@

# Test ZGC on support platforms. Windows requires version 1083 or later which will
# probably require adding some capabilities.
local all_zgc_builds = [self.make_build(jdk, os_arch, task).build
local all_zgc_builds = [self.make_build(jdk, os_arch, task).build + galahad.exclude
for jdk in [
self.jdk_latest
]
Expand All @@ -453,7 +453,7 @@
],

# Run unittests with SerialGC.
local all_serialgc_builds = [self.make_build(self.jdk_latest, os_arch, task).build
local all_serialgc_builds = [self.make_build(self.jdk_latest, os_arch, task).build + galahad.exclude
for os_arch in [
"linux-amd64",
"linux-aarch64",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package jdk.graal.compiler.replacements.test;

import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -40,13 +41,24 @@
@AddExports({"java.base/jdk.internal.util"})
public class VectorizedHashCodeTest extends GraalCompilerTest {

private static int getField(String name) {
try {
var arraysSupport = Class.forName("jdk.internal.util.ArraysSupport");
Field f = arraysSupport.getDeclaredField(name);
f.setAccessible(true);
return f.getInt(null);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}

@Test
public void testJDKConstantValue() {
Assert.assertEquals(ArraysSupport.T_BOOLEAN, VectorizedHashCodeInvocationPlugin.T_BOOLEAN);
Assert.assertEquals(ArraysSupport.T_CHAR, VectorizedHashCodeInvocationPlugin.T_CHAR);
Assert.assertEquals(ArraysSupport.T_BYTE, VectorizedHashCodeInvocationPlugin.T_BYTE);
Assert.assertEquals(ArraysSupport.T_SHORT, VectorizedHashCodeInvocationPlugin.T_SHORT);
Assert.assertEquals(ArraysSupport.T_INT, VectorizedHashCodeInvocationPlugin.T_INT);
Assert.assertEquals(getField("T_BOOLEAN"), VectorizedHashCodeInvocationPlugin.T_BOOLEAN);
Assert.assertEquals(getField("T_CHAR"), VectorizedHashCodeInvocationPlugin.T_CHAR);
Assert.assertEquals(getField("T_BYTE"), VectorizedHashCodeInvocationPlugin.T_BYTE);
Assert.assertEquals(getField("T_SHORT"), VectorizedHashCodeInvocationPlugin.T_SHORT);
Assert.assertEquals(getField("T_INT"), VectorizedHashCodeInvocationPlugin.T_INT);
}

// @formatter:off
Expand Down Expand Up @@ -89,7 +101,7 @@ private void testHash(String method, Function<byte[], Object> f, Function<byte[]
}

public static int hashByteArray(byte[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_BYTE);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -98,16 +110,16 @@ public void testHashByteArray() {
}

public static int hashByteArrayCharElement(byte[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_CHAR);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
public void testHashByteArrayCharElement() {
testHash("hashByteArrayCharElement", a -> a, a -> a.length / 2);
}

public static int hashBooleanArray(Object array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_BOOLEAN);
public static int hashBooleanArray(byte[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -124,7 +136,7 @@ public void testHashBooleanArray() {
}

public static int hashCharArray(char[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_CHAR);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -139,7 +151,7 @@ public void testHashCharArray() {
}

public static int hashShortArray(short[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_SHORT);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -154,7 +166,7 @@ public void testHashShortArray() {
}

public static int hashIntArray(int[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_INT);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion graal-common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"README": "This file contains definitions that are useful for the jsonnet CI files of the graal and graal-enterprise repositories.",
"ci": {
"overlay": "d434751247c43b1ccb1c4e07dfc9f8731fbb93e4"
"overlay": "0fb9c2f58b07cc9b370baf3d6f5230aadb0aaf9a"
}
}
7 changes: 4 additions & 3 deletions regex/ci/ci.jsonnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
local utils = (import '../../ci/ci_common/common-utils.libsonnet'),
local common = import '../../ci/ci_common/common.jsonnet',

local galahad = import "../../ci/ci_common/galahad-common.libsonnet",

local regex_common = {
setup+: [
["cd", "./regex"],
Expand All @@ -15,8 +16,8 @@
targets: ["gate"],
},

local regex_gate_lite = regex_common + {
name: 'gate-regex-mac-lite-' + self.jdk_name,
local regex_gate_lite = regex_common + galahad.exclude {
name: 'weekly-regex-mac-lite-' + self.jdk_name,
run: [
["mx", "build"],
["mx", "unittest", "--verbose", "com.oracle.truffle.regex"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import java.util.concurrent.Callable;
import java.util.function.BooleanSupplier;

import com.oracle.svm.core.annotate.TargetElement;
import com.oracle.svm.core.jdk.JDK21OrEarlier;
import com.oracle.svm.core.jdk.JDK23OrLater;
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand All @@ -37,15 +40,7 @@
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.ModuleNative;

@Platforms(Platform.HOSTED_ONLY.class)
final class ScopedValuesEnabled implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return JavaVersionUtil.JAVA_SPEC >= 21 || (JavaVersionUtil.JAVA_SPEC >= 20 && ModuleNative.bootLayerContainsModule("jdk.incubator.concurrent"));
}
}

@TargetClass(className = "java.lang.ScopedValue", onlyWith = ScopedValuesEnabled.class)
@TargetClass(className = "java.lang.ScopedValue")
final class Target_java_lang_ScopedValue {
@Substitute
static Target_java_lang_ScopedValue_Snapshot scopedValueBindings() {
Expand All @@ -58,15 +53,20 @@ static Target_java_lang_ScopedValue_Snapshot scopedValueBindings() {
}
}

@TargetClass(className = "java.lang.ScopedValue", innerClass = "CallableOp", onlyWith = JDK23OrLater.class)
final class Target_java_lang_ScopedValue_CallableOp {
}

/**
* Substituted to directly call {@link Target_java_lang_Thread#setScopedValueBindings} for forced
* inlining.
*/
@TargetClass(className = "java.lang.ScopedValue", innerClass = "Carrier", onlyWith = ScopedValuesEnabled.class)
@TargetClass(className = "java.lang.ScopedValue", innerClass = "Carrier")
final class Target_java_lang_ScopedValue_Carrier {
@Alias int bitmask;

@Substitute
@TargetElement(onlyWith = JDK21OrEarlier.class)
@Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false)
private <R> R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Callable<R> op) throws Exception {
Target_java_lang_Thread.setScopedValueBindings(newSnapshot);
Expand All @@ -78,6 +78,19 @@ private <R> R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Callabl
}
}

@Substitute
@TargetElement(onlyWith = JDK23OrLater.class)
@Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false)
private <R> R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Target_java_lang_ScopedValue_CallableOp op) throws Exception {
Target_java_lang_Thread.setScopedValueBindings(newSnapshot);
try {
return Target_jdk_internal_vm_ScopedValueContainer.call(op);
} finally {
Target_java_lang_Thread.setScopedValueBindings(newSnapshot.prev);
Target_java_lang_ScopedValue_Cache.invalidate(bitmask);
}
}

@Substitute
@Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false)
private void runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Runnable op) {
Expand All @@ -91,16 +104,21 @@ private void runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Runnable
}
}

@TargetClass(className = "jdk.internal.vm.ScopedValueContainer", onlyWith = ScopedValuesEnabled.class)
@TargetClass(className = "jdk.internal.vm.ScopedValueContainer")
final class Target_jdk_internal_vm_ScopedValueContainer {
@Alias
@TargetElement(onlyWith = JDK21OrEarlier.class)
static native <V> V call(Callable<V> op) throws Exception;

@Alias
@TargetElement(onlyWith = JDK23OrLater.class)
static native <V> V call(Target_java_lang_ScopedValue_CallableOp op) throws Exception;

@Alias
static native void run(Runnable op);
}

@TargetClass(className = "java.lang.ScopedValue", innerClass = "Snapshot", onlyWith = ScopedValuesEnabled.class)
@TargetClass(className = "java.lang.ScopedValue", innerClass = "Snapshot")
final class Target_java_lang_ScopedValue_Snapshot {
// Checkstyle: stop
@Alias //
Expand All @@ -111,7 +129,7 @@ final class Target_java_lang_ScopedValue_Snapshot {
Target_java_lang_ScopedValue_Snapshot prev;
}

@TargetClass(className = "java.lang.ScopedValue", innerClass = "Cache", onlyWith = ScopedValuesEnabled.class)
@TargetClass(className = "java.lang.ScopedValue", innerClass = "Cache")
final class Target_java_lang_ScopedValue_Cache {
@Alias
static native void invalidate(int toClearBits);
Expand Down
2 changes: 1 addition & 1 deletion vm/ci/ci_common/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ local devkits = graal_common.devkits;
#
# Gates
#
vm.vm_java_21 + graal_common.deps.eclipse + graal_common.deps.jdt + self.vm_base('linux', 'amd64', 'gate') + galahad.include + {
vm.vm_java_21 + graal_common.deps.eclipse + graal_common.deps.jdt + self.vm_base('linux', 'amd64', 'gate') + galahad.exclude + {
run: [
['mx', 'gate', '-B=--force-deprecation-as-warning', '--tags', 'style,fullbuild'],
],
Expand Down
3 changes: 2 additions & 1 deletion vm/ci/ci_common/libgraal.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local devkits = graal_common.devkits;
local c = import 'common.jsonnet';
local g = vm.compiler_gate;
local utils = import '../../../ci/ci_common/common-utils.libsonnet';
local galahad = import '../../../ci/ci_common/galahad-common.libsonnet';

{
local underscore(s) = std.strReplace(s, "-", "_"),
Expand Down Expand Up @@ -79,7 +80,7 @@ local utils = import '../../../ci/ci_common/common-utils.libsonnet';
# See definition of `gates` local variable in ../../compiler/ci_common/gate.jsonnet
local gate_jobs = {
"gate-vm-libgraal_compiler-labsjdk-latest-linux-amd64": {},
"gate-vm-libgraal_truffle-labsjdk-latest-linux-amd64": {},
"gate-vm-libgraal_truffle-labsjdk-latest-linux-amd64": {} + galahad.exclude,
"gate-vm-libgraal_compiler_zgc-labsjdk-latest-linux-amd64": {},
"gate-vm-libgraal_compiler_quickbuild-labsjdk-latest-linux-amd64": {},

Expand Down

0 comments on commit 3bd8754

Please sign in to comment.