|
60 | 60 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.klassAccessFlagsOffset;
|
61 | 61 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.klassMiscFlagsOffset;
|
62 | 62 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadWordFromObject;
|
63 |
| -import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.markWordLockMaskInPlace; |
64 | 63 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.lockMetadataOffset;
|
65 | 64 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.markOffset;
|
| 65 | +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.markWordLockMaskInPlace; |
66 | 66 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.monitorValue;
|
67 | 67 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorCxqOffset;
|
68 | 68 | import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorEntryListOffset;
|
|
205 | 205 | // @formatter:on
|
206 | 206 | public class MonitorSnippets implements Snippets {
|
207 | 207 |
|
| 208 | + /** |
| 209 | + * This helper method is for bypassing the mandatory branch probabilities for snippets. |
| 210 | + * |
| 211 | + * See also {@code jdk.graal.compiler.core.test.VerifySnippetProbabilities} |
| 212 | + */ |
| 213 | + @Fold |
| 214 | + public static boolean isJDK21() { |
| 215 | + return JavaVersionUtil.JAVA_SPEC == 21; |
| 216 | + } |
| 217 | + |
208 | 218 | /**
|
209 | 219 | * The monitorenter snippet is slightly different from the HotSpot code:
|
210 | 220 | *
|
@@ -240,7 +250,7 @@ public static void monitorenter(Object object, KlassPointer hub, @ConstantParame
|
240 | 250 | }
|
241 | 251 |
|
242 | 252 | if (tryFastPathLocking(object, stackPointerRegister, trace, counters, mark, lock, thread)) {
|
243 |
| - if (JavaVersionUtil.JAVA_SPEC == 21 || useStackLocking(INJECTED_VMCONFIG)) { |
| 253 | + if (isJDK21() || useStackLocking(INJECTED_VMCONFIG)) { |
244 | 254 | incrementHeldMonitorCount(thread);
|
245 | 255 | }
|
246 | 256 | } else {
|
@@ -313,7 +323,7 @@ private static boolean tryEnterInflated(Object object, Word lock, Word mark, Wor
|
313 | 323 |
|
314 | 324 | int ownerOffset = objectMonitorOwnerOffset(INJECTED_VMCONFIG);
|
315 | 325 | Word owner = monitor.readWord(ownerOffset, OBJECT_MONITOR_OWNER_LOCATION);
|
316 |
| - Word newOwner = JavaVersionUtil.JAVA_SPEC == 21 ? thread : thread.readWord(javaThreadLockIDOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_ID_LOCATION); |
| 326 | + Word newOwner = isJDK21() ? thread : thread.readWord(javaThreadLockIDOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_ID_LOCATION); |
317 | 327 |
|
318 | 328 | // The following owner null check is essential. In the case where the null check fails, it
|
319 | 329 | // avoids the subsequent bound-to-fail CAS operation, which would have caused the
|
@@ -480,7 +490,7 @@ public static void monitorexit(Object object, @ConstantParameter int lockDepth,
|
480 | 490 | trace(trace, " lock: 0x%016lx\n", lock);
|
481 | 491 |
|
482 | 492 | if (tryFastPathUnlocking(object, trace, counters, thread, lock)) {
|
483 |
| - if (JavaVersionUtil.JAVA_SPEC == 21 || useStackLocking(INJECTED_VMCONFIG)) { |
| 493 | + if (isJDK21() || useStackLocking(INJECTED_VMCONFIG)) { |
484 | 494 | decrementHeldMonitorCount(thread);
|
485 | 495 | }
|
486 | 496 | } else {
|
@@ -614,7 +624,7 @@ private static boolean tryExitInflated(Object object, Word mark, Word thread, Wo
|
614 | 624 | int recursionsOffset = objectMonitorRecursionsOffset(INJECTED_VMCONFIG);
|
615 | 625 | Word recursions = monitor.readWord(recursionsOffset, OBJECT_MONITOR_RECURSION_LOCATION);
|
616 | 626 | if (probability(FAST_PATH_PROBABILITY, recursions.equal(0))) {
|
617 |
| - if (JavaVersionUtil.JAVA_SPEC == 21) { |
| 627 | + if (isJDK21()) { |
618 | 628 | // recursions == 0
|
619 | 629 | Word entryList = monitor.readWord(objectMonitorEntryListOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_ENTRY_LIST_LOCATION);
|
620 | 630 | Word cxq = monitor.readWord(objectMonitorCxqOffset(INJECTED_VMCONFIG), OBJECT_MONITOR_CXQ_LOCATION);
|
|
0 commit comments