Skip to content

Commit 1e8adf8

Browse files
committed
[GR-59439] Adapt JDK-8340796: Use a consistent order when loading cxq and EntryList
PullRequest: graal/19161
2 parents 606cff1 + 6363502 commit 1e8adf8

10 files changed

+30
-25
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/z/AMD64HotSpotZBarrierSetLIRGenerator.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static void zUncolor(CompilationResultBuilder crb, AMD64MacroAssembler ma
137137
* slow path call to the runtime.
138138
*/
139139
@SyncPort(from = "https://github.com/openjdk/jdk/blob/4acafb809c66589fbbfee9c9a4ba7820f848f0e4/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L304-L321", sha1 = "9a628c1771df79ae8b4cee89d2863fbd4a4964bc")
140-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/4acafb809c66589fbbfee9c9a4ba7820f848f0e4/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L370-L414", sha1 = "7688e7aeab5f1aa413690066355a17c18a4273fa")
140+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L374-L418", sha1 = "7688e7aeab5f1aa413690066355a17c18a4273fa")
141141
public static void emitPreWriteBarrier(CompilationResultBuilder crb,
142142
AMD64MacroAssembler masm,
143143
LIRInstruction op,
@@ -213,7 +213,7 @@ public static void emitPreWriteBarrier(CompilationResultBuilder crb,
213213
/**
214214
* Try to perform any local store barrier fixups or dispatch to the slow path.
215215
*/
216-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/4acafb809c66589fbbfee9c9a4ba7820f848f0e4/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L450-L505", sha1 = "4b729acf92e6a297229b7f1e957601708c315f4f")
216+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L454-L509", sha1 = "4b729acf92e6a297229b7f1e957601708c315f4f")
217217
static void storeBarrierMedium(CompilationResultBuilder crb,
218218
AMD64MacroAssembler masm,
219219
AMD64Address address,
@@ -278,7 +278,7 @@ static void storeBarrierMedium(CompilationResultBuilder crb,
278278
/**
279279
* Add a value to the store buffer.
280280
*/
281-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/4acafb809c66589fbbfee9c9a4ba7820f848f0e4/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L416-L448", sha1 = "638b10c65bb14fa4b254efa4d5bbb1751fdbb6bf")
281+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L420-L452", sha1 = "638b10c65bb14fa4b254efa4d5bbb1751fdbb6bf")
282282
static void storeBarrierBufferAdd(AMD64MacroAssembler masm,
283283
AMD64Address address,
284284
Register tmp1,

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

+17-12
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@
189189
* appropriately to comply with the layouts above.
190190
*/
191191
// @formatter:off
192-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/180affc5718c9bf2f009d6a7aa129cc36335384a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L175-L532",
193-
sha1 = "6269b3e841e4a6be49042270f3489eae292fc05f")
192+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L175-L532",
193+
sha1 = "042c4a5c1730525a53c24ee194a182dfd34bf754")
194194
// @formatter:on
195195
public class MonitorSnippets implements Snippets {
196196

@@ -515,8 +515,8 @@ private static boolean tryStackUnlocking(Object object, Word thread, Word lock,
515515
}
516516

517517
// @formatter:off
518-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/dcac4b0a532f2ca6cb374da7ece331e8266ab351/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L694-L855",
519-
sha1 = "410864d3b17fd0e3f1026b9c06e4d383446896ba")
518+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L694-L858",
519+
sha1 = "57536f7432c20e2e785059b464948f9aeee3804b")
520520
// @formatter:on
521521
private static boolean tryLightweightUnlocking(Object object, Word thread, Word lock, boolean trace, Counters counters) {
522522
// Load top
@@ -597,12 +597,10 @@ private static boolean tryExitInflated(Object object, Word thread, Word lock, bo
597597
if (probability(FAST_PATH_PROBABILITY, recursions.equal(0))) {
598598
if (JavaVersionUtil.JAVA_SPEC == 21) {
599599
// recursions == 0
600-
int cxqOffset = objectMonitorCxqOffset(INJECTED_VMCONFIG);
601-
Word cxq = monitor.readWord(cxqOffset, OBJECT_MONITOR_CXQ_LOCATION);
602-
int entryListOffset = objectMonitorEntryListOffset(INJECTED_VMCONFIG);
603-
Word entryList = monitor.readWord(entryListOffset, OBJECT_MONITOR_ENTRY_LIST_LOCATION);
604-
if (probability(FREQUENT_PROBABILITY, cxq.or(entryList).equal(0))) {
605-
// cxq == 0 && entryList == 0
600+
Word entryList = monitor.readWord(objectMonitorEntryListOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_ENTRY_LIST_LOCATION);
601+
Word cxq = monitor.readWord(objectMonitorCxqOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_CXQ_LOCATION);
602+
if (probability(FREQUENT_PROBABILITY, entryList.or(cxq).equal(0))) {
603+
// entryList == 0 && cxq == 0
606604
// Nobody is waiting, success
607605
// release_store
608606
memoryBarrier(MembarNode.FenceKind.STORE_RELEASE);
@@ -641,10 +639,17 @@ private static boolean tryExitInflated(Object object, Word thread, Word lock, bo
641639
memoryBarrier(MembarNode.FenceKind.STORE_RELEASE);
642640
monitor.writeWord(ownerOffset, zero());
643641
memoryBarrier(MembarNode.FenceKind.STORE_LOAD);
644-
Word cxq = monitor.readWord(objectMonitorCxqOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_CXQ_LOCATION);
642+
// Note that we read the EntryList and then the cxq after dropping the
643+
// lock, so the values need not form a stable snapshot. In particular,
644+
// after reading the (empty) EntryList, another thread could acquire
645+
// and release the lock, moving any entries in the cxq to the
646+
// EntryList, causing the current thread to see an empty cxq and
647+
// conclude there are no waiters. But this is okay as the thread that
648+
// moved the cxq is responsible for waking the successor.
645649
Word entryList = monitor.readWord(objectMonitorEntryListOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_ENTRY_LIST_LOCATION);
650+
Word cxq = monitor.readWord(objectMonitorCxqOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_CXQ_LOCATION);
646651
// Check if the entry lists are empty.
647-
if (probability(FREQUENT_PROBABILITY, cxq.or(entryList).equal(0))) {
652+
if (probability(FREQUENT_PROBABILITY, entryList.or(cxq).equal(0))) {
648653
traceObject(trace, "-lock{heavyweight:simple}", object, false);
649654
counters.unlockHeavySimple.inc();
650655
return true;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
* Returns the number of positive bytes.
7070
*/
7171
// @formatter:off
72-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/dcac4b0a532f2ca6cb374da7ece331e8266ab351/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L5484-L5553",
72+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L5467-L5536",
7373
sha1 = "ce54a7cf2fcfe7ccb8f6604c038887fc1c4ebce1")
7474
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7131f053b0d26b62cbf0d8376ec117d6e8d79f9e/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp#L4975-L5141",
7575
sha1 = "3b4e6edb4372e8babb009763c2d05961348dd723")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import jdk.vm.ci.meta.Value;
5252

5353
// @formatter:off
54-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/dcac4b0a532f2ca6cb374da7ece331e8266ab351/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L6087-L6200",
54+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L6070-L6183",
5555
sha1 = "80e6323172af5e8a33625b4eb14629cdad500a0f")
5656
// @formatter:on
5757
@Opcode("AArch64_ENCODE_ARRAY")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* {@link Math#round} algorithm for details.
4646
*/
4747
// @formatter:off
48-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/dcac4b0a532f2ca6cb374da7ece331e8266ab351/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L6320-L6368",
48+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L6303-L6351",
4949
sha1 = "76d47473bf8d1408bf6e7bf6b8a3d93c19dab9c6")
5050
// @formatter:on
5151
@Opcode("AARCH64_ROUND_FLOAT_TO_INTEGER")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import jdk.vm.ci.meta.Value;
4545

4646
// @formatter:off
47-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/dcac4b0a532f2ca6cb374da7ece331e8266ab351/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L6308-L6318",
47+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L6291-L6301",
4848
sha1 = "857dc6f9a492da6c8e20afb2139ae393efd228ac")
4949
// @formatter:on
5050
@Opcode("AArch64_STRING_COMPRESS")

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64BitSwapOp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import jdk.vm.ci.meta.Value;
4141

4242
// @formatter:off
43-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7fa2f229fbee68112cbdd18b811d95721adfe2ec/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L6256-L6338",
43+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L6457-L6539",
4444
sha1 = "34c6e1ee7916fc7190cbcbc237eaf2b510f7dd0e")
4545
// @formatter:on
4646
public final class AMD64BitSwapOp extends AMD64LIRInstruction {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64CountPositivesOp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import jdk.vm.ci.meta.Value;
5656

5757
// @formatter:off
58-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7fa2f229fbee68112cbdd18b811d95721adfe2ec/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L4012-L4282",
58+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L4084-L4354",
5959
sha1 = "684b5353c58bbf92e4403aa985113a78a1f38930")
6060
// @formatter:on
6161
@Opcode("AMD64_COUNT_POSITIVES")

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64RoundFloatToIntegerOp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* {@link Math#round} algorithm for details.
4747
*/
4848
// @formatter:off
49-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7131f053b0d26b62cbf0d8376ec117d6e8d79f9e/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L10054-L10150",
49+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L10138-L10234",
5050
sha1 = "9e13c7375bbb35809ad79ebd6a9cc19e66f57aa1")
5151
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7fa2f229fbee68112cbdd18b811d95721adfe2ec/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp#L596-L763",
5252
sha1 = "312f16a0551887f78cc567638477bbbcbc3765c5")

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64VectorizedHashCodeOp.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@
7575
import jdk.vm.ci.meta.Value;
7676

7777
// @formatter:off
78-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7fa2f229fbee68112cbdd18b811d95721adfe2ec/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L1769-L1878",
78+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L1838-L1947",
7979
sha1 = "1cc5a10b19e7746105493d8f430f628cc7f89c51")
80-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7fa2f229fbee68112cbdd18b811d95721adfe2ec/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L2069-L2115",
80+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L2138-L2184",
8181
sha1 = "9cbba8bd6c4037427fa46f067abb722b15aca90c")
82-
@SyncPort(from = "https://github.com/openjdk/jdk/blob/7fa2f229fbee68112cbdd18b811d95721adfe2ec/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L3427-L3614",
82+
@SyncPort(from = "https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L3499-L3686",
8383
sha1 = "2457cf3f9d3ff89c1515fa5d95cc7c8437a5318b")
8484
// @formatter:on
8585
@Opcode("VECTORIZED_HASHCODE")

0 commit comments

Comments
 (0)