Skip to content

Commit e39f0cc

Browse files
committed
[GR-50816] Sync HotSpot intrinsic ports.
PullRequest: graal/16350
2 parents 348b804 + b6ac363 commit e39f0cc

File tree

45 files changed

+422
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+422
-267
lines changed

compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/lir/processor/SyncPortProcessor.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.File;
3232
import java.io.FileInputStream;
3333
import java.io.FileNotFoundException;
34+
import java.io.FileOutputStream;
3435
import java.io.IOException;
3536
import java.io.InputStream;
3637
import java.io.InputStreamReader;
@@ -70,6 +71,10 @@ public class SyncPortProcessor extends AbstractProcessor {
7071
// Allows comparing against local files. E.g.,
7172
// HOTSPOT_PORT_SYNC_CHECK=true HOTSPOT_PORT_SYNC_OVERWRITE="file:///PATH/TO/JDK" mx build
7273
static final String SYNC_OVERWRITE_ENV_VAR = "HOTSPOT_PORT_SYNC_OVERWRITE";
74+
// Allows generating a file of bash commands to update changed line numbers. E.g.:
75+
// HOTSPOT_PORT_SYNC_CHECK=true HOTSPOT_PORT_SYNC_SHIFT_UPDATE_CMD_FILE="update.sh" mx build &&
76+
// bash update.sh
77+
static final String SYNC_SHIFT_UPDATE_COMMAND_DUMP_FILE_ENV_VAR = "HOTSPOT_PORT_SYNC_SHIFT_UPDATE_CMD_FILE";
7378

7479
static final String JDK_LATEST = "https://raw.githubusercontent.com/openjdk/jdk/master/";
7580
static final String JDK_LATEST_HUMAN = "https://github.com/openjdk/jdk/blob/master/";
@@ -104,7 +109,14 @@ private void compareDigest(MessageDigest md, AnnotationMirror annotationMirror,
104109
int lineStart = Integer.parseInt(matcher.group("lineStart"));
105110
int lineEnd = Integer.parseInt(matcher.group("lineEnd"));
106111

107-
try {
112+
String dumpUpdateCommandsEnvVar = System.getenv(SYNC_SHIFT_UPDATE_COMMAND_DUMP_FILE_ENV_VAR);
113+
PrintWriter dumpUpdateCommands;
114+
if (dumpUpdateCommandsEnvVar != null) {
115+
dumpUpdateCommands = new PrintWriter(new FileOutputStream(dumpUpdateCommandsEnvVar, true));
116+
} else {
117+
dumpUpdateCommands = null;
118+
}
119+
try (dumpUpdateCommands) {
108120
String overwriteURL = System.getenv(SYNC_OVERWRITE_ENV_VAR);
109121
boolean isURLOverwritten = overwriteURL != null && !"".equals(overwriteURL);
110122

@@ -120,23 +132,27 @@ private void compareDigest(MessageDigest md, AnnotationMirror annotationMirror,
120132
if (!isURLOverwritten) {
121133
String urlOld = String.format("https://raw.githubusercontent.com/openjdk/jdk/%s/%s", commit, path);
122134
String sha1Old = digest(proxy, md, urlOld, lineStart - 1, lineEnd);
123-
124135
if (sha1.equals(sha1Old)) {
125136
String latestCommit = getLatestCommit(proxy);
126137
int idx = find(proxy, urlOld, url, lineStart - 1, lineEnd, SEARCH_RANGE);
127138
if (idx != -1) {
128139
int idxInclusive = idx + 1;
129140
kind = NOTE;
141+
String urlFormat = "https://github.com/openjdk/jdk/blob/%s/%s#L%d-L%d";
142+
String newUrl = String.format(urlFormat, latestCommit, path, idxInclusive, idxInclusive + (lineEnd - lineStart));
130143
extraMessage = String.format("""
131144
The original code snippet is shifted. Update with:
132-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/%s/%s#L%d-L%d",
145+
@SyncPort(from = "%s",
133146
sha1 = "%s")
134147
""",
135-
latestCommit,
136-
path,
137-
idxInclusive,
138-
idxInclusive + (lineEnd - lineStart),
148+
newUrl,
139149
sha1);
150+
if (dumpUpdateCommands != null) {
151+
String oldUrl = String.format(urlFormat, commit, path, lineStart, lineEnd);
152+
assert !oldUrl.contains("+");
153+
assert !newUrl.contains("+");
154+
dumpUpdateCommands.printf("sed -i s+%s+%s+g $(git grep --files-with-matches %s)%n", oldUrl, newUrl, sha1);
155+
}
140156
} else {
141157
extraMessage = String.format("""
142158
See also:

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/StringCompressInflateTest.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@
2727
import static org.junit.Assume.assumeTrue;
2828

2929
import java.io.UnsupportedEncodingException;
30+
import java.util.Arrays;
31+
32+
import org.junit.Assert;
33+
import org.junit.Assume;
34+
import org.junit.Before;
35+
import org.junit.Test;
3036

3137
import jdk.graal.compiler.core.common.CompilationIdentifier;
32-
import jdk.graal.compiler.replacements.amd64.AMD64GraphBuilderPlugins;
3338
import jdk.graal.compiler.hotspot.test.HotSpotGraalCompilerTest;
3439
import jdk.graal.compiler.nodes.Invoke;
3540
import jdk.graal.compiler.nodes.StructuredGraph;
3641
import jdk.graal.compiler.nodes.StructuredGraph.AllowAssumptions;
3742
import jdk.graal.compiler.replacements.StringLatin1InflateNode;
3843
import jdk.graal.compiler.replacements.StringUTF16CompressNode;
44+
import jdk.graal.compiler.replacements.amd64.AMD64GraphBuilderPlugins;
3945
import jdk.graal.compiler.test.AddExports;
40-
import org.junit.Assume;
41-
import org.junit.Before;
42-
import org.junit.Test;
43-
4446
import jdk.vm.ci.code.InstalledCode;
4547
import jdk.vm.ci.code.InvalidInstalledCodeException;
4648
import jdk.vm.ci.meta.JavaConstant;
@@ -296,6 +298,27 @@ public void testStringUTF16CompressCharByte() throws ClassNotFoundException {
296298
}
297299
}
298300
}
301+
302+
// Exhaustively check compress returning the correct index of the non-latin1 char.
303+
final int size = 48;
304+
final byte fillByte = 'R';
305+
char[] chars = new char[size];
306+
final byte[] bytes = new byte[chars.length];
307+
Arrays.fill(bytes, fillByte);
308+
for (int i = 0; i < size; i++) { // Every starting index
309+
for (int j = i; j < size; j++) { // Every location of non-latin1
310+
Arrays.fill(chars, 'A');
311+
chars[j] = 0xFF21;
312+
byte[] dst = Arrays.copyOf(bytes, bytes.length);
313+
byte[] dst2 = Arrays.copyOf(bytes, bytes.length);
314+
int result = (int) invokeSafe(caller, null, chars, i, dst, 0, chars.length - i);
315+
int result2 = (int) executeVarargsSafe(code, chars, i, dst2, 0, chars.length - i);
316+
Assert.assertEquals(result, result2);
317+
Assert.assertArrayEquals(dst, dst2);
318+
Assert.assertEquals("compress found wrong index", j - i, result);
319+
Assert.assertEquals("extra character stored", fillByte, bytes[j]);
320+
}
321+
}
299322
}
300323

301324
public static void getCharsSnippet(String s, int srcBegin, int srcEnd, char[] dst, int dstBegin) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
671671
}
672672

673673
// @formatter:off
674-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0d4de8a71f063e44618f43ddd862a91aed647f48/src/hotspot/share/opto/library_call.cpp#L2868-L2923",
674+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/share/opto/library_call.cpp#L2873-L2928",
675675
sha1 = "5c117a305e90a48f0a6fe86ace2c15942393c0ab")
676676
// @formatter:on
677677
private static void inlineNativeNotifyJvmtiFunctions(GraalHotSpotVMConfig config, GraphBuilderContext b, ResolvedJavaMethod targetMethod, ForeignCallDescriptor descriptor,

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.graalvm.word.WordFactory;
4343

4444
// @formatter:off
45-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d4c904d81970bbe5b0afe1029eae705366779839/src/hotspot/share/opto/library_call.cpp#L4480-L4604",
45+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/share/opto/library_call.cpp#L4485-L4609",
4646
sha1 = "34281fb78c4f0657a704dbda3e3cc85ed56dd2ad")
4747
// @formatter:on
4848
public class HotSpotHashCodeSnippets extends IdentityHashCodeSnippets {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ private static boolean tryStackLocking(Object object, Word lock, Word mark, Word
329329
}
330330

331331
// @formatter:off
332-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0d4de8a71f063e44618f43ddd862a91aed647f48/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L9792-L9826",
332+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L9963-L9997",
333333
sha1 = "7a02d52b6b621959389e574984ca20b52100fe5e")
334334
// @formatter:on
335335
private static boolean tryLightweightLocking(Object object, Word lock, Word mark, Word thread, boolean trace, Counters counters, Register stackPointerRegister) {
@@ -431,7 +431,7 @@ private static boolean tryStackUnlocking(Object object, Word displacedMark, Word
431431
}
432432

433433
// @formatter:off
434-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0d4de8a71f063e44618f43ddd862a91aed647f48/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L9828-L9857",
434+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L9999-L10028",
435435
sha1 = "666343ea6d941f68ed863a396d9496cb3ce1b69b")
436436
// @formatter:on
437437
private static boolean tryLightweightUnlocking(Object object, Word thread, boolean trace, Counters counters) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/VirtualThreadUpdateJFRSnippets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* Snippet for updating JFR thread local data on {@code Thread#setCurrentThread} events.
6565
*/
6666
// @formatter:off
67-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0a3a925ad88921d387aa851157f54ac0054d347b/src/hotspot/share/opto/library_call.cpp#L3453-L3579",
67+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/share/opto/library_call.cpp#L3458-L3584",
6868
sha1 = "1f980401f5d7d9a363577635fd57fc1e24505d91")
6969
// @formatter:on
7070
public class VirtualThreadUpdateJFRSnippets implements Snippets {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64AESDecryptOp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import jdk.vm.ci.meta.Value;
5757

5858
// @formatter:off
59-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0a3a925ad88921d387aa851157f54ac0054d347b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L2703-L2734",
59+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L2719-L2750",
6060
sha1 = "69b7e01dbc601afd660d5dcef88917a43613e00c")
6161
@SyncPort(from = "https://github.com/openjdk/jdk/blob/12358e6c94bc96e618efc3ec5299a2cfe1b4669d/src/hotspot/cpu/aarch64/macroAssembler_aarch64_aes.cpp#L34-L110",
6262
sha1 = "4916141cba98c26e4d98edb457161f88a8c66ffa")

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64AESEncryptOp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
import jdk.vm.ci.meta.Value;
6767

6868
// @formatter:off
69-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0a3a925ad88921d387aa851157f54ac0054d347b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L2671-L2701",
69+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L2687-L2717",
7070
sha1 = "e1333c6ab2d693fa9231a7365c568d81db63fae7")
7171
@SyncPort(from = "https://github.com/openjdk/jdk/blob/12358e6c94bc96e618efc3ec5299a2cfe1b4669d/src/hotspot/cpu/aarch64/macroAssembler_aarch64_aes.cpp#L112-L283",
7272
sha1 = "41ef4f49f68c0e08ff4d698c8cc962e392cc16ec")

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64ArrayRegionCompareToOp.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,9 @@ private static void loadAndExtend(AArch64MacroAssembler asm, Stride strideDst, S
291291
private static void calcReturnValue(AArch64MacroAssembler asm, Register ret, Register vecArrayA, Register vecArrayB, Register vecTmp, Register vecIndex, Register vecMask, Stride strideMax) {
292292
// set all equal bytes to 0xff, others to 0x00
293293
asm.neon.cmeqVVV(FullReg, fromStride(strideMax), vecTmp, vecArrayA, vecArrayB);
294-
// BIC with the ascending index mask, this will replace all non-equal bytes with their
295-
// corresponding byte index
296-
asm.neon.bicVVV(FullReg, vecIndex, vecMask, vecTmp);
297-
// OR with the result of CMEQ, replacing all equal bytes with 0xff again
298-
asm.neon.orrVVV(FullReg, vecIndex, vecIndex, vecTmp);
294+
// OR with the ascending index mask, this will replace all non-equal bytes with their
295+
// corresponding byte index, and all equal bytes with 0xff
296+
asm.neon.orrVVV(FullReg, vecIndex, vecMask, vecTmp);
299297
// Get the unsigned minimum. This will yield the index of the first non-equal bytes, since
300298
// all equal ones are filled with 0xff
301299
asm.neon.uminvSV(FullReg, fromStride(strideMax), vecIndex, vecIndex);

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64BigIntegerMulAddOp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
// @formatter:off
5050

51-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0a3a925ad88921d387aa851157f54ac0054d347b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L4702-L4721",
51+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/ce8399fd6071766114f5f201b6e44a7abdba9f5a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L4718-L4737",
5252
sha1 = "57f40186d75104a5e607d6fc047bbd50ef246590")
5353
@SyncPort(from = "https://github.com/openjdk/jdk/blob/0a3a925ad88921d387aa851157f54ac0054d347b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L3622-L3658",
5454
sha1 = "33649be9177daf5f0b4817d807458a5ff8c00365")

0 commit comments

Comments
 (0)