Skip to content

Commit

Permalink
Backport oracle#9078
Browse files Browse the repository at this point in the history
Backports the following commits:

ceaac5f Automatic merge of master into galahad
f1a2d95 Automatic merge of master into galahad
59a170e compiler: adopt "JDK-8332826: Make hashCode methods in ArraysSupport friendlier"
2b2754d svm: adopt "JDK-8331189: Implementation of Scoped Values (Third Preview)"
07d3bc2 update galahad-jdk
90def08 compiler: no more JDK 21 style gate in galahad
2a04dde Automatic merge of master into galahad
d2f6535 Automatic merge of master into galahad
e1771d1 Automatic merge of master into galahad
268aa8d reduce galahad gate to bare minimum
3bd8754 [JDK-8333292] Fix libgraal build broken by JDK-8331189.
188f35a Fix libgraal build broken by JDK-8331877.
95415ad [JDK-8333362] Fix libgraal build broken by JDK-8331877.
3fbd87a Automatic merge of master into galahad
93923e4 Automatic merge of master into galahad
a29b4da Automatic merge of master into galahad
ee5cef4 Automatic merge of master into galahad
8b40a6a Automatic merge of master into galahad
4d34880 Merge master into galahad
414d874 [GR-54472] Resolve merge conflits.
78ec64e Automatic merge of master into galahad
768bab8 Automatic merge of master into galahad
ca7c3ca Automatic merge of master into galahad
4ce7fe8 Automatic merge of master into galahad
02a83e9 Automatic merge of master into galahad
b6f3365 Automatic merge of master into galahad
859ea9d Fix incorrect resolution of merge conflicts for VectorizedHashCodeTest
8f4c214 Automatic merge of master into galahad
bdedb09 Automatic merge of master into galahad
103dbca Automatic merge of master into galahad
  • Loading branch information
jerboaa authored and zakkak committed Jun 27, 2024
1 parent 519c85c commit fdd6b77
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 54 deletions.
16 changes: 8 additions & 8 deletions 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+26-2139", "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 Expand Up @@ -45,13 +45,13 @@
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+26", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+26-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+26-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+26-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+26-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+26-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+26-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package jdk.graal.compiler.hotspot.jdk23.test;

import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -40,20 +41,31 @@
@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
private static String[] tests = {"", " ", "a", "abcdefg",
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities",
"C'était le meilleur des temps, c'était le pire des temps, c'était l'âge de la sagesse, c'était l'âge de la folie, c'était l'époque de la croyance, c'était l'époque de l'incrédulité, c'était la saison de la Lumière, c'était C'était la saison des Ténèbres, c'était le printemps de l'espoir, c'était l'hiver du désespoir, nous avions tout devant nous, nous n'avions rien devant nous, nous allions tous directement au Ciel, nous allions tous directement dans l'autre sens bref, la période ressemblait tellement à la période actuelle, que certaines de ses autorités les plus bruyantes ont insisté pour qu'elle soit reçue, pour le bien ou pour le mal, au degré superlatif de la comparaison seulement. -- Charles Dickens, Tale of Two Cities (in French)",
"禅道修行を志した雲水は、一般に参禅のしきたりを踏んだうえで一人の師につき、各地にある専門道場と呼ばれる養成寺院に入門し、与えられた公案に取り組むことになる。公案は、師家(老師)から雲水が悟りの境地へと進んで行くために手助けとして課す問題であり、悟りの境地に達していない人には容易に理解し難い難問だが、屁理屈や詭弁が述べられているわけではなく、頓知や謎かけとも異なる。"
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities",
"C'était le meilleur des temps, c'était le pire des temps, c'était l'âge de la sagesse, c'était l'âge de la folie, c'était l'époque de la croyance, c'était l'époque de l'incrédulité, c'était la saison de la Lumière, c'était C'était la saison des Ténèbres, c'était le printemps de l'espoir, c'était l'hiver du désespoir, nous avions tout devant nous, nous n'avions rien devant nous, nous allions tous directement au Ciel, nous allions tous directement dans l'autre sens bref, la période ressemblait tellement à la période actuelle, que certaines de ses autorités les plus bruyantes ont insisté pour qu'elle soit reçue, pour le bien ou pour le mal, au degré superlatif de la comparaison seulement. -- Charles Dickens, Tale of Two Cities (in French)",
"禅道修行を志した雲水は、一般に参禅のしきたりを踏んだうえで一人の師につき、各地にある専門道場と呼ばれる養成寺院に入門し、与えられた公案に取り組むことになる。公案は、師家(老師)から雲水が悟りの境地へと進んで行くために手助けとして課す問題であり、悟りの境地に達していない人には容易に理解し難い難問だが、屁理屈や詭弁が述べられているわけではなく、頓知や謎かけとも異なる。"
};
// @formatter:on

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
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public final class JVMCIVersionCheck {
private static final Map<String, Map<String, Version>> JVMCI_MIN_VERSIONS = Map.of(
"21", Map.of(DEFAULT_VENDOR_ENTRY, createLegacyVersion(23, 1, 33)),
"23", Map.of(
"Oracle Corporation", createLabsJDKVersion("23+25", 1),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+25", 1)));
"Oracle Corporation", createLabsJDKVersion("23+26", 1),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+26", 1)));
private static final int NA = 0;
/**
* Minimum Java release supported by Graal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected void reset() {
}

@Override
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/windows/os_windows.cpp#L5457-L5499")
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L5672-L5714")
protected void park(boolean isAbsolute, long time) {
assert time >= 0 && !(isAbsolute && time == 0) : "must not be called otherwise";

Expand Down Expand Up @@ -256,7 +256,7 @@ private static int toDword(long value) {
}

@Override
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/windows/os_windows.cpp#L5501-L5504")
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L5716-L5719")
protected void unpark() {
StackOverflowCheck.singleton().makeYellowZoneAvailable();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public long getThreadCpuTime(IsolateThread isolateThread, boolean includeSystemT
return getThreadCpuTime(hThread, includeSystemTime);
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/windows/os_windows.cpp#L4722-L4738")
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L4960-L4976")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
private static long getThreadCpuTime(HANDLE hThread, boolean includeSystemTime) {
FILETIME create = StackValue.get(FILETIME.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ static void writeBytes(FileDescriptor descriptor, byte[] bytes, int off, int len

/** Retrieve a nanosecond counter for elapsed time measurement. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-22+22/src/hotspot/os/windows/os_windows.cpp#L976-L983")
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-22+22/src/hotspot/os/windows/os_windows.cpp#L1081-L1087")
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L1089-L1096")
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L1194-L1200")
public static long getNanoCounter() {
if (performanceFrequency == 0L) {
CLongPointer count = StackValue.get(CLongPointer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jfr.Name_jdk_jfr_internal_JDKEvents_helper;

@TargetClass(className = "jdk.jfr.internal.instrument.JDKEvents")
@TargetClass(classNameProvider = Name_jdk_jfr_internal_JDKEvents_helper.class)
@Platforms(LINUX.class)
final class Target_jdk_jfr_internal_instrument_JDKEvents {
final class Target_jdk_jfr_internal_JDKEvents {
@Alias //
@RecomputeFieldValue(kind = Kind.Reset) //
private static Target_jdk_internal_platform_Metrics containerMetrics;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024, 2024, 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 com.oracle.svm.core.jfr;

import java.util.function.Function;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.annotate.TargetClass;

import jdk.graal.compiler.serviceprovider.JavaVersionUtil;

@Platforms(Platform.HOSTED_ONLY.class)
public final class Name_jdk_jfr_internal_JDKEvents_helper implements Function<TargetClass, String> {

@Override
public String apply(TargetClass annotation) {
if (JavaVersionUtil.JAVA_SPEC >= 23) {
return "jdk.jfr.internal.JDKEvents";
} else {
return "jdk.jfr.internal.instrument.JDKEvents";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@
import jdk.jfr.events.ActiveRecordingEvent;
import jdk.jfr.events.ActiveSettingEvent;

@TargetClass(className = "jdk.jfr.internal.instrument.JDKEvents", onlyWith = HasJfrSupport.class)
@TargetClass(classNameProvider = Name_jdk_jfr_internal_JDKEvents_helper.class, onlyWith = HasJfrSupport.class)
final class Target_jdk_jfr_internal_instrument_JDKEvents {

@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) private static Class<?>[] eventClasses = {
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) //
private static Class<?>[] eventClasses = {
ActiveSettingEvent.class,
ActiveRecordingEvent.class
};

// This is a list of the classes with instrumentation code that should be applied.
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) private static Class<?>[] instrumentationClasses = new Class<?>[]{};
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) //
@TargetElement(onlyWith = JDK21OrEarlier.class) private static Class<?>[] instrumentationClasses = new Class<?>[]{};

@Alias //
@TargetElement(onlyWith = JDK21OrEarlier.class) //
Expand Down
Loading

0 comments on commit fdd6b77

Please sign in to comment.