diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 1507696c4d35d..68f4af347449c 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -85,6 +85,7 @@ #include "runtime/javaCalls.hpp" #include "runtime/javaThread.inline.hpp" #include "runtime/jniHandles.inline.hpp" +#include "runtime/lightweightSynchronizer.hpp" #include "runtime/lockStack.hpp" #include "runtime/os.hpp" #include "runtime/stackFrameStream.inline.hpp" @@ -1902,6 +1903,20 @@ WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj)) return (jboolean) obj_oop->mark().has_monitor(); WB_END +WB_ENTRY(void, WB_ForceInflateMonitorLockedObject(JNIEnv* env, jobject wb, jobject obj)) + oop obj_oop = JNIHandles::resolve(obj); + if (obj_oop->mark().has_monitor()) { + return; // Already inflated + } + ObjectSynchronizer::InflateCause cause = ObjectSynchronizer::InflateCause::inflate_cause_vm_internal; + JavaThread* current = JavaThread::current(); + if (LockingMode == LM_LIGHTWEIGHT) { + LightweightSynchronizer::inflate_fast_locked_object(obj_oop, cause, current, current); + } else { + ObjectSynchronizer::inflate(current, obj_oop, cause); + } +WB_END + WB_ENTRY(jboolean, WB_IsAsanEnabled(JNIEnv* env)) return (jboolean) WhiteBox::is_asan_enabled(); WB_END @@ -2906,6 +2921,7 @@ static JNINativeMethod methods[] = { (void*)&WB_AddModuleExportsToAll }, {CC"deflateIdleMonitors", CC"()Z", (void*)&WB_DeflateIdleMonitors }, {CC"isMonitorInflated0", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated }, + {CC"forceInflateMonitorLockedObject0", CC"(Ljava/lang/Object;)V", (void*)&WB_ForceInflateMonitorLockedObject }, {CC"isAsanEnabled", CC"()Z", (void*)&WB_IsAsanEnabled }, {CC"isUbsanEnabled", CC"()Z", (void*)&WB_IsUbsanEnabled }, {CC"getInUseMonitorCount", CC"()J", (void*)&WB_getInUseMonitorCount }, diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index a49116fd91d57..93a8efbe34b20 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1836,7 +1836,7 @@ bool Arguments::check_vm_args_consistency() { #ifndef _LP64 if (LockingMode == LM_LEGACY) { - FLAG_SET_CMDLINE(LockingMode, LM_LIGHTWEIGHT); + LockingMode = LM_LIGHTWEIGHT; // Self-forwarding in bit 3 of the mark-word conflicts // with 4-byte-aligned stack-locks. warning("Legacy locking not supported on this platform"); diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 75736d0dc7d20..d6aee56499f23 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1953,13 +1953,6 @@ const int ObjectAlignmentInBytes = 8; "Mark all threads after a safepoint, and clear on a modify " \ "fence. Add cleanliness checks.") \ \ - product(int, LockingMode, LM_LIGHTWEIGHT, \ - "(Deprecated) Select locking mode: " \ - "0: (Deprecated) monitors only (LM_MONITOR), " \ - "1: (Deprecated) monitors & legacy stack-locking (LM_LEGACY), " \ - "2: monitors & new lightweight locking (LM_LIGHTWEIGHT, default)") \ - range(0, 2) \ - \ product(bool, UseObjectMonitorTable, false, DIAGNOSTIC, \ "With Lightweight Locking mode, use a table to record inflated " \ "monitors rather than the first word of the object.") \ diff --git a/src/hotspot/share/utilities/globalDefinitions.cpp b/src/hotspot/share/utilities/globalDefinitions.cpp index 8a111a1260797..afbe6845c7e19 100644 --- a/src/hotspot/share/utilities/globalDefinitions.cpp +++ b/src/hotspot/share/utilities/globalDefinitions.cpp @@ -56,6 +56,8 @@ int LogMinObjAlignmentInBytes = -1; // Oop encoding heap max uint64_t OopEncodingHeapMax = 0; +int LockingMode = LM_LIGHTWEIGHT; + // Something to help porters sleep at night #ifdef ASSERT diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 4ec61babec3d4..2e2efc6f70609 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1009,6 +1009,8 @@ enum LockingMode { LM_LIGHTWEIGHT = 2 }; +extern int LockingMode; + //---------------------------------------------------------------------------------------------------- // Special constants for debugging diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/LockingMode.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/LockingMode.java deleted file mode 100644 index 2046fd075ad8b..0000000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/LockingMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Amazon.com Inc. 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. - * - * 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 sun.jvm.hotspot.runtime; - -import sun.jvm.hotspot.types.TypeDataBase; - - -/** Encapsulates the LockingMode enum in globalDefinitions.hpp in - the VM. */ - -public class LockingMode { - private static int monitor; - private static int legacy; - private static int lightweight; - - static { - VM.registerVMInitializedObserver( - (o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - monitor = db.lookupIntConstant("LM_MONITOR").intValue(); - legacy = db.lookupIntConstant("LM_LEGACY").intValue(); - lightweight = db.lookupIntConstant("LM_LIGHTWEIGHT").intValue(); - } - - public static int getMonitor() { - return monitor; - } - - public static int getLegacy() { - return legacy; - } - - public static int getLightweight() { - return lightweight; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index dfc49d1a81fdf..1230bea184cd2 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -222,29 +222,18 @@ private JavaThread owningThreadFromMonitor(Address o) { public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) { if (monitor.isOwnedAnonymous()) { - if (VM.getVM().getCommandLineFlag("LockingMode").getInt() == LockingMode.getLightweight()) { - OopHandle object = monitor.object(); - for (int i = 0; i < getNumberOfThreads(); i++) { - JavaThread thread = getJavaThreadAt(i); - if (thread.isLockOwned(object)) { - return thread; - } - } - // We should have found the owner, however, as the VM could be in any state, including the middle - // of performing GC, it is not always possible to do so. Just return null if we can't locate it. - System.out.println("Warning: We failed to find a thread that owns an anonymous lock. This is likely"); - System.out.println("due to the JVM currently running a GC. Locking information may not be accurate."); - return null; - } else { - assert(VM.getVM().getCommandLineFlag("LockingMode").getInt() == LockingMode.getLegacy()); - Address o = (Address)monitor.stackLocker(); - for (int i = 0; i < getNumberOfThreads(); i++) { - JavaThread thread = getJavaThreadAt(i); - if (thread.isLockOwned(o)) - return thread; - } - return null; + OopHandle object = monitor.object(); + for (int i = 0; i < getNumberOfThreads(); i++) { + JavaThread thread = getJavaThreadAt(i); + if (thread.isLockOwned(object)) { + return thread; + } } + // We should have found the owner, however, as the VM could be in any state, including the middle + // of performing GC, it is not always possible to do so. Just return null if we can't locate it. + System.out.println("Warning: We failed to find a thread that owns an anonymous lock. This is likely"); + System.out.println("due to the JVM currently running a GC. Locking information may not be accurate."); + return null; } else { return owningThreadFromMonitor(monitor.owner()); } diff --git a/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java b/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java index 4165e6285b691..1f861f301e3b0 100644 --- a/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java +++ b/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -26,9 +26,6 @@ * @bug 8337660 * @summary Test that C2 does not remove blocks with BoxLock nodes that are * otherwise empty. - * @run main/othervm -Xbatch -XX:LockingMode=1 - * -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::* - * compiler.locks.TestSynchronizeWithEmptyBlock * @run main/othervm -Xbatch * -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::* * compiler.locks.TestSynchronizeWithEmptyBlock diff --git a/test/hotspot/jtreg/gtest/LockStackGtests.java b/test/hotspot/jtreg/gtest/LockStackGtests.java index e426b2c56f3b3..5766f5dbcbb86 100644 --- a/test/hotspot/jtreg/gtest/LockStackGtests.java +++ b/test/hotspot/jtreg/gtest/LockStackGtests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -23,10 +23,10 @@ */ /* @test - * @summary Run LockStack gtests with LockingMode=2 + * @summary Run LockStack gtests * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml * @requires vm.flagless - * @run main/native GTestWrapper --gtest_filter=LockStackTest* -XX:LockingMode=2 + * @run main/native GTestWrapper --gtest_filter=LockStackTest* */ diff --git a/test/hotspot/jtreg/runtime/Monitor/ConcurrentDeflation.java b/test/hotspot/jtreg/runtime/Monitor/ConcurrentDeflation.java index 9ceec3b9d8d17..f26d1c44f6817 100644 --- a/test/hotspot/jtreg/runtime/Monitor/ConcurrentDeflation.java +++ b/test/hotspot/jtreg/runtime/Monitor/ConcurrentDeflation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -24,6 +24,7 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; +import jdk.test.whitebox.WhiteBox; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; @@ -33,11 +34,14 @@ * @test * @bug 8318757 * @summary Test concurrent monitor deflation by MonitorDeflationThread and thread dumping - * @library /test/lib - * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:GuaranteedAsyncDeflationInterval=2000 -XX:LockingMode=0 ConcurrentDeflation + * @library /test/lib / + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:GuaranteedAsyncDeflationInterval=2000 -XX:+WhiteBoxAPI ConcurrentDeflation */ public class ConcurrentDeflation { + static final WhiteBox WB = WhiteBox.getWhiteBox(); public static final long TOTAL_RUN_TIME_NS = 10_000_000_000L; public static Object[] monitors = new Object[1000]; public static int monitorCount; @@ -73,6 +77,7 @@ static private void createMonitors() { index = index++ % 1000; monitors[index] = new Object(); synchronized (monitors[index]) { + WB.forceInflateMonitorLockedObject(monitors[index]); monitorCount++; } } diff --git a/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java index b12f0f007f843..0eeacabb82f89 100644 --- a/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java +++ b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java @@ -33,21 +33,6 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 */ @@ -63,21 +48,6 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 */ @@ -94,21 +64,6 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 */ @@ -125,21 +80,6 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 */ @@ -156,21 +96,6 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-EliminateNestedLocks - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-EliminateNestedLocks - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 */ @@ -182,25 +107,10 @@ * @summary Tests recursive locking in C2 in alternate A and B mode. * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox - * * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=0 - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=1 - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 * * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=2 * -XX:-EliminateNestedLocks * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 diff --git a/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java index eae845c48b1bb..f64019a14ecb1 100644 --- a/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java +++ b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java @@ -33,21 +33,6 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 */ @@ -63,21 +48,6 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 */ @@ -94,21 +64,6 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 */ @@ -125,21 +80,6 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 */ @@ -156,21 +96,6 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:LockingMode=0 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-EliminateNestedLocks - * -XX:LockingMode=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-EliminateNestedLocks - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 */ @@ -182,25 +107,10 @@ * @summary Tests recursive locking in C2 in alternate A and B mode. * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox - * * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=0 - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 * * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=1 - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=2 * -XX:-EliminateNestedLocks * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 @@ -212,11 +122,8 @@ public class TestRecursiveLocking { static final WhiteBox WB = WhiteBox.getWhiteBox(); - static final int flagLockingMode = WB.getIntVMFlag("LockingMode").intValue(); + static final boolean flagHeavyMonitors = WB.getBooleanVMFlag("VerifyHeavyMonitors"); static final int constLockStackCapacity = WB.getLockStackCapacity(); - static final int LM_MONITOR = 0; - static final int LM_LEGACY = 1; - static final int LM_LIGHTWEIGHT = 2; static final int def_mode = 2; static final int def_n_secs = 30; static final SyncThread syncThread = new SyncThread(); @@ -229,18 +136,14 @@ static class SynchronizedObject { synchronized void runInner(int depth, SynchronizedObject outer) { counter++; - // Legacy mode has no lock stack, i.e., there is no limit - // on recursion, so for legacy mode we can't say that - // "outer" must be inflated here, which we can say for all - // the other locking modes. - if (flagLockingMode != LM_LEGACY) { - outer.assertInflated(); - } + // There is limit on recursion, so "outer" must be + // inflated here. + outer.assertInflated(); // We haven't reached the stack lock capacity (recursion // level), so we shouldn't be inflated here. Except for // monitor mode, which is always inflated. - if (flagLockingMode != LM_MONITOR) { + if (!flagHeavyMonitors) { assertNotInflated(); } if (depth == 1) { @@ -248,7 +151,7 @@ synchronized void runInner(int depth, SynchronizedObject outer) { } else { runInner(depth - 1, outer); } - if (flagLockingMode != LM_MONITOR) { + if (!flagHeavyMonitors) { assertNotInflated(); } } @@ -256,7 +159,7 @@ synchronized void runInner(int depth, SynchronizedObject outer) { synchronized void runOuter(int depth, SynchronizedObject inner) { counter++; - if (flagLockingMode != LM_MONITOR) { + if (!flagHeavyMonitors) { assertNotInflated(); } if (depth == 1) { @@ -264,9 +167,7 @@ synchronized void runOuter(int depth, SynchronizedObject inner) { } else { runOuter(depth - 1, inner); } - if (flagLockingMode != LM_LEGACY) { - assertInflated(); - } + assertInflated(); } // This test nests x recursive locks of INNER, in x recursive @@ -283,16 +184,14 @@ public void runOuterInnerTest() { synchronized (OUTER) { OUTER.counter++; - if (flagLockingMode != LM_MONITOR) { + if (!flagHeavyMonitors) { OUTER.assertNotInflated(); } INNER.assertNotInflated(); OUTER.runOuter(constLockStackCapacity - 1, INNER); - if (flagLockingMode != LM_LEGACY) { - OUTER.assertInflated(); - } - if (flagLockingMode != LM_MONITOR) { + OUTER.assertInflated(); + if (!flagHeavyMonitors) { INNER.assertNotInflated(); } } @@ -308,7 +207,7 @@ public void runOuterInnerTest() { synchronized void runA(int depth, SynchronizedObject B) { counter++; - if (flagLockingMode == LM_LIGHTWEIGHT) { + if (!flagHeavyMonitors) { // First time we lock A, A is the only one on the lock // stack. if (counter == 1) { @@ -323,7 +222,7 @@ synchronized void runA(int depth, SynchronizedObject B) { // to [B, B ... B]. assertInflated(); } - } else if (flagLockingMode == LM_MONITOR) { + } else if (flagHeavyMonitors) { assertInflated(); } @@ -334,7 +233,7 @@ synchronized void runA(int depth, SynchronizedObject B) { synchronized void runB(int depth, SynchronizedObject A) { counter++; - if (flagLockingMode != LM_MONITOR) { + if (!flagHeavyMonitors) { // Legacy tolerates endless recursions. While testing // lightweight we don't go deeper than the size of the // lock stack, which in this test case will be filled @@ -370,14 +269,11 @@ public void runAlternateABTest() { Asserts.assertEquals(A.counter, constLockStackCapacity); Asserts.assertEquals(B.counter, constLockStackCapacity); - if (flagLockingMode == LM_LEGACY) { - A.assertNotInflated(); - } - // Implied else: for LM_MONITOR or LM_LIGHTWEIGHT it can be - // either inflated or not because A is not locked anymore - // and subject to deflation. - if (flagLockingMode != LM_MONITOR) { + // Here A can be either inflated or not because A is not + // locked anymore and subject to deflation. + + if (!flagHeavyMonitors) { B.assertNotInflated(); } } @@ -443,7 +339,7 @@ public static void main(String... argv) throws Exception { } } - System.out.println("INFO: LockingMode=" + flagLockingMode); + System.out.println("INFO: VerifyHeavyMonitors=" + flagHeavyMonitors); System.out.println("INFO: LockStackCapacity=" + constLockStackCapacity); System.out.println("INFO: n_secs=" + n_secs); System.out.println("INFO: mode=" + mode); diff --git a/test/hotspot/jtreg/runtime/lockStack/TestLockStackCapacity.java b/test/hotspot/jtreg/runtime/lockStack/TestLockStackCapacity.java index 01ba1f4f12c65..86eabc2b3e0e0 100644 --- a/test/hotspot/jtreg/runtime/lockStack/TestLockStackCapacity.java +++ b/test/hotspot/jtreg/runtime/lockStack/TestLockStackCapacity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -30,7 +30,7 @@ * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xint -XX:LockingMode=2 TestLockStackCapacity + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xint TestLockStackCapacity */ import jdk.test.lib.Asserts; @@ -39,8 +39,7 @@ public class TestLockStackCapacity { static final WhiteBox WB = WhiteBox.getWhiteBox(); - static final int LockingMode = WB.getIntVMFlag("LockingMode").intValue(); - static final int LM_LIGHTWEIGHT = 2; + static final boolean flagHeavyMonitors = WB.getBooleanVMFlag("VerifyHeavyMonitors"); static class SynchronizedObject { static final SynchronizedObject OUTER = new SynchronizedObject(); @@ -95,12 +94,12 @@ void assertInflated() { } public static void main(String... args) throws Exception { - if (LockingMode != LM_LIGHTWEIGHT) { - throw new SkippedException("Test only valid for LM_LIGHTWEIGHT"); + if (flagHeavyMonitors) { + throw new SkippedException("Test only valid for lightweight locking"); } if (!WB.supportsRecursiveLightweightLocking()) { - throw new SkippedException("Test only valid if LM_LIGHTWEIGHT supports recursion"); + throw new SkippedException("Test only valid if lightweight locking supports recursion"); } SynchronizedObject.runTest(); diff --git a/test/hotspot/jtreg/runtime/locking/TestRecursiveMonitorChurn.java b/test/hotspot/jtreg/runtime/locking/TestRecursiveMonitorChurn.java index 806f32aad882b..e92e947ecfa1e 100644 --- a/test/hotspot/jtreg/runtime/locking/TestRecursiveMonitorChurn.java +++ b/test/hotspot/jtreg/runtime/locking/TestRecursiveMonitorChurn.java @@ -49,13 +49,12 @@ synchronized void doSomethingElse() { } static final WhiteBox WB = WhiteBox.getWhiteBox(); - static final int LM_MONITOR = 0; static final int COUNT = 100000; public static volatile Monitor monitor; public static void main(String[] args) { - if (WB.getIntVMFlag("LockingMode") == LM_MONITOR) { - throw new SkippedException("LM_MONITOR always inflates. Invalid test."); + if (WB.getBooleanVMFlag("VerifyHeavyMonitors")) { + throw new SkippedException("VerifyHeavyMonitors always inflates. Invalid test."); } final long pre_monitor_count = WB.getInUseMonitorCount(); System.out.println(" Precount = " + pre_monitor_count); diff --git a/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java b/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java deleted file mode 100644 index 56bb705a0b2ab..0000000000000 --- a/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2021, 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. - * - * 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. - */ -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/* - * Tests that JNI monitors work correctly with virtual threads, - * There are multiple test scenarios that we check using unified logging output - * (both positive and negative tests). Each test case is handled by its own @-test - * definition so that we can run each sub-test independently. - * - * The original bug was only discovered because the ForkJoinPool worker thread terminated - * and trigerred an assertion failure. So we use a custom scheduler to give us control. - */ - -/** - * @test id=normal - * @bug 8327743 - * @summary Normal lock then unlock - * @library /test/lib - * @modules java.base/java.lang:+open - * @requires vm.continuations - * @run driver JNIMonitor Normal - */ - -/** - * @test id=multiNormal - * @bug 8327743 - * @summary Normal lock then unlock by multiple threads - * @library /test/lib - * @modules java.base/java.lang:+open - * @requires vm.continuations - * @run driver JNIMonitor MultiNormal - */ - -/** - * @test id=missingUnlock - * @bug 8327743 - * @summary Don't do the unlock and exit normally - * @library /test/lib - * @modules java.base/java.lang:+open - * @requires vm.continuations - * @run driver JNIMonitor MissingUnlock - */ - -/** - * @test id=multiMissingUnlock - * @bug 8327743 - * @summary Don't do the unlock and exit normally, by multiple threads - * @library /test/lib - * @modules java.base/java.lang:+open - * @requires vm.continuations - * @run driver JNIMonitor MultiMissingUnlock - */ - -/** - * @test id=missingUnlockWithThrow - * @bug 8327743 - * @summary Don't do the unlock and exit by throwing - * @library /test/lib - * @modules java.base/java.lang:+open - * @requires vm.continuations - * @run driver JNIMonitor MissingUnlockWithThrow - */ - -/** - * @test id=multiMissingUnlockWithThrow - * @bug 8327743 - * @summary Don't do the unlock and exit by throwing, by multiple threads - * @library /test/lib - * @modules java.base/java.lang:+open - * @requires vm.continuations - * @run driver JNIMonitor MultiMissingUnlockWithThrow - */ - -public class JNIMonitor { - - public static void main(String[] args) throws Exception { - String test = args[0]; - String[] cmdArgs = new String[] { - "-Djava.library.path=" + Utils.TEST_NATIVE_PATH, - // Grant access to ThreadBuilders$VirtualThreadBuilder - "--add-opens=java.base/java.lang=ALL-UNNAMED", - // Enable the JNI warning - "-Xcheck:jni", - "-Xlog:jni=debug", - // Enable thread termination logging as a visual cross-check - "-Xlog:thread+os=info", - // We only count monitors in LM_LEGACY mode - "-XX:LockingMode=1", - // Disable compact headers since that switches locking mode to LM_LIGHTWEIGHT - "-XX:-UseCompactObjectHeaders", - "JNIMonitor$" + test, - }; - OutputAnalyzer oa = ProcessTools.executeTestJava(cmdArgs); - oa.shouldHaveExitValue(0); - oa.stdoutShouldMatch(terminated); - - switch(test) { - case "Normal": - case "MultiNormal": - oa.stdoutShouldNotMatch(stillLocked); - break; - case "MissingUnlock": - oa.stdoutShouldMatch(stillLocked); - break; - case "MultiMissingUnlock": - parseOutputForPattern(oa.stdoutAsLines(), stillLocked, MULTI_THREAD_COUNT); - break; - case "MissingUnlockWithThrow": - oa.stdoutShouldMatch(stillLocked); - oa.stderrShouldContain(throwMsg); - break; - case "MultiMissingUnlockWithThrow": - parseOutputForPattern(oa.stdoutAsLines(), stillLocked, MULTI_THREAD_COUNT); - parseOutputForPattern(oa.stderrAsLines(), throwMsg, MULTI_THREAD_COUNT); - break; - - default: throw new Error("Unknown arg: " + args[0]); - } - oa.reportDiagnosticSummary(); - } - - // The number of threads for a multi tests. Arbitrarily chosen to be > 1 but small - // enough to not waste too much time. - static final int MULTI_THREAD_COUNT = 5; - - // The logging message for leaving a monitor JNI locked has the form - // [0.187s][debug][jni] VirtualThread (tid: 28, carrier id: 29) exiting with Objects still locked by JNI MonitorEnter. - // but if the test is run with other logging options then whitespace may get introduced in the - // log decorator sections, so ignore those. - static final String stillLocked = "VirtualThread \\(tid:.*exiting with Objects still locked by JNI MonitorEnter"; - // The carrier thread termination logging has the form: - // [1.394s][info][os,thread] JavaThread exiting (name: "pool-1-thread-1", tid: 3090592). - static final String terminated = "JavaThread exiting \\(name: \"pool-1-thread-1\""; - - static final String throwMsg = "Terminating via exception as requested"; - - // Check the process logging output for the given pattern to see if the expected number of - // lines are found. - private static void parseOutputForPattern(List lines, String pattern, int expected) { - Pattern p = Pattern.compile(pattern); - int found = 0; - for (String line : lines) { - Matcher m = p.matcher(line); - if (m.find()) { - found++; - } - } - if (found != expected) { - throw new RuntimeException("Checking for pattern \"" + pattern + "\": expected " - + expected + " but found " + found); - } - } - - - // straight-forward interface to JNI monitor functions - static native int monitorEnter(Object o); - static native int monitorExit(Object o); - - // Isolate the native library loading to the actual test cases, not the class that - // jtreg Driver will load and execute. - static class TestBase { - - static { - System.loadLibrary("JNIMonitor"); - } - - // This gives us a way to control the scheduler used for our virtual threads. The test - // only works as intended when the virtual threads run on the same carrier thread (as - // that carrier maintains ownership of the monitor if the virtual thread fails to unlock it). - // The original issue was also only discovered due to the carrier thread terminating - // unexpectedly, so we can force that condition too by shutting down our custom scheduler. - private static Thread.Builder.OfVirtual virtualThreadBuilder(Executor scheduler) { - Thread.Builder.OfVirtual builder = Thread.ofVirtual(); - try { - Class clazz = Class.forName("java.lang.ThreadBuilders$VirtualThreadBuilder"); - Constructor ctor = clazz.getDeclaredConstructor(Executor.class); - ctor.setAccessible(true); - return (Thread.Builder.OfVirtual) ctor.newInstance(scheduler); - } catch (InvocationTargetException e) { - Throwable cause = e.getCause(); - if (cause instanceof RuntimeException re) { - throw re; - } - throw new RuntimeException(e); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - static void runTest(int nThreads, boolean skipUnlock, boolean throwOnExit) throws Throwable { - final Object[] monitors = new Object[nThreads]; - for (int i = 0; i < nThreads; i++) { - monitors[i] = new Object(); - } - final AtomicReference exception = new AtomicReference(); - // Ensure all our VT's operate of the same carrier, sequentially. - ExecutorService scheduler = Executors.newSingleThreadExecutor(); - ThreadFactory factory = virtualThreadBuilder(scheduler).factory(); - for (int i = 0 ; i < nThreads; i++) { - Object monitor = skipUnlock ? monitors[i] : monitors[0]; - Thread th = factory.newThread(() -> { - try { - int res = monitorEnter(monitor); - Asserts.assertTrue(res == 0, "monitorEnter should return 0."); - Asserts.assertTrue(Thread.holdsLock(monitor), "monitor should be owned"); - Thread.yield(); - if (!skipUnlock) { - res = monitorExit(monitor); - Asserts.assertTrue(res == 0, "monitorExit should return 0."); - Asserts.assertFalse(Thread.holdsLock(monitor), "monitor should be unowned"); - } - } catch (Throwable t) { - exception.set(t); - } - if (throwOnExit) { - throw new RuntimeException(throwMsg); - } - }); - th.start(); - th.join(); - if (exception.get() != null) { - throw exception.get(); - } - } - // Now force carrier thread to shutdown. - scheduler.shutdown(); - } - } - - // These are the actual test case classes that get exec'd. - - static class Normal extends TestBase { - public static void main(String[] args) throws Throwable { - runTest(1, false, false); - } - } - - static class MultiNormal extends TestBase { - public static void main(String[] args) throws Throwable { - runTest(MULTI_THREAD_COUNT, false, false); - } - } - - static class MissingUnlock extends TestBase { - public static void main(String[] args) throws Throwable { - runTest(1, true, false); - } - } - - static class MultiMissingUnlock extends TestBase { - public static void main(String[] args) throws Throwable { - runTest(MULTI_THREAD_COUNT, true, false); - } - } - - static class MissingUnlockWithThrow extends TestBase { - public static void main(String[] args) throws Throwable { - runTest(1, true, true); - } - } - - static class MultiMissingUnlockWithThrow extends TestBase { - public static void main(String[] args) throws Throwable { - runTest(MULTI_THREAD_COUNT, true, true); - } - } - -} diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/StopThreadTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/StopThreadTest.java index d455a16c99849..a775ffa1037da 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/StopThreadTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/StopThreadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -277,8 +277,6 @@ static void C() { } static boolean preemptableVirtualThread() { - boolean legacyLockingMode = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) - .getVMOption("LockingMode").getValue().equals("1"); - return is_virtual && !isBoundVThread && !legacyLockingMode; + return is_virtual && !isBoundVThread; } } diff --git a/test/jdk/com/sun/jdi/EATests.java b/test/jdk/com/sun/jdi/EATests.java index b2a2cad49db7f..321855b496930 100644 --- a/test/jdk/com/sun/jdi/EATests.java +++ b/test/jdk/com/sun/jdi/EATests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024 SAP SE. All rights reserved. + * Copyright (c) 2020, 2025 SAP SE. 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 @@ -34,42 +34,6 @@ * @run build TestScaffold VMConnection TargetListener TargetAdapter jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run compile -g EATests.java - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:-EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:+DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 * * @run driver EATests * -XX:+UnlockDiagnosticVMOptions @@ -79,7 +43,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -88,7 +51,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:-EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -97,7 +59,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -106,7 +67,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * * @comment Excercise -XX:+DeoptimizeObjectsALot. Mostly to prevent bit-rot because the option is meant to stress object deoptimization * with non-synthetic workloads. @@ -124,16 +84,6 @@ * @comment Regression test for using the wrong thread when logging during re-locking from deoptimization. * * @comment DiagnoseSyncOnValueBasedClasses=2 will cause logging when locking on \@ValueBased objects. - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 - * -XX:DiagnoseSyncOnValueBasedClasses=2 * * @comment Re-lock may inflate monitors when re-locking, which cause monitorinflation trace logging. * @run driver EATests @@ -144,23 +94,10 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * -Xlog:monitorinflation=trace:file=monitorinflation.log * - * @comment Re-lock may race with deflation. - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=0 - * -XX:GuaranteedAsyncDeflationInterval=1000 - * * @bug 8341819 - * @comment Regression test for re-locking racing with deflation with LM_LIGHTWEIGHT. + * @comment Regression test for re-locking racing with deflation with lightweight locking. * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -169,7 +106,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * -XX:GuaranteedAsyncDeflationInterval=1 */ @@ -1815,8 +1751,8 @@ public void dontinline_testMethod() { /** * Like {@link EARelockingSimple}. The difference is that there are many * lightweight locked objects when the relocking is done. With - * -XX:LockingMode=2 the lock stack of the thread will be full - * because of this. + * lightweight the lock stack of the thread will be full because of + * this. */ class EARelockingWithManyLightweightLocks extends EATestCaseBaseDebugger { diff --git a/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java b/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java index 75ef0376a7e0e..6260c8e9bda09 100644 --- a/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java +++ b/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -31,30 +31,6 @@ * @run junit CarrierThreadInfo */ -/** - * @test id=LM_LIGHTWEIGHT - * @requires vm.continuations - * @modules java.base/java.lang:+open - * @library /test/lib - * @run junit/othervm -XX:LockingMode=2 CarrierThreadInfo - */ - -/** - * @test id=LM_LEGACY - * @requires vm.continuations - * @modules java.base/java.lang:+open - * @library /test/lib - * @run junit/othervm -XX:LockingMode=1 CarrierThreadInfo - */ - -/** - * @test id=LM_MONITOR - * @requires vm.continuations - * @modules java.base/java.lang:+open - * @library /test/lib - * @run junit/othervm -XX:LockingMode=0 CarrierThreadInfo - */ - import java.lang.management.LockInfo; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; diff --git a/test/jdk/java/lang/Thread/virtual/LockingMode.java b/test/jdk/java/lang/Thread/virtual/LockingMode.java deleted file mode 100644 index 59fde4a5f4928..0000000000000 --- a/test/jdk/java/lang/Thread/virtual/LockingMode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 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. - * - * 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. - */ - -import java.lang.management.ManagementFactory; -import com.sun.management.HotSpotDiagnosticMXBean; - -class LockingMode { - private LockingMode() { } - - /** - * Returns true if using legacy locking mode. - */ - static boolean isLegacy() { - return ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) - .getVMOption("LockingMode") - .getValue() - .equals("1"); - } -} \ No newline at end of file diff --git a/test/jdk/java/lang/Thread/virtual/MiscMonitorTests.java b/test/jdk/java/lang/Thread/virtual/MiscMonitorTests.java index 1f909b214c29c..b512aa7578935 100644 --- a/test/jdk/java/lang/Thread/virtual/MiscMonitorTests.java +++ b/test/jdk/java/lang/Thread/virtual/MiscMonitorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -25,7 +25,7 @@ * @test id=default * @summary Tests for object monitors that have been useful to find bugs * @library /test/lib - * @requires vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.continuations * @modules java.base/java.lang:+open * @run junit/othervm MiscMonitorTests */ @@ -33,7 +33,7 @@ /* * @test id=Xint * @library /test/lib - * @requires vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.continuations * @modules java.base/java.lang:+open * @run junit/othervm -Xint MiscMonitorTests */ @@ -41,7 +41,7 @@ /* * @test id=Xcomp * @library /test/lib - * @requires vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.continuations * @modules java.base/java.lang:+open * @run junit/othervm -Xcomp MiscMonitorTests */ @@ -49,7 +49,7 @@ /* * @test id=Xcomp-TieredStopAtLevel3 * @library /test/lib - * @requires vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.continuations * @modules java.base/java.lang:+open * @run junit/othervm -Xcomp -XX:TieredStopAtLevel=3 MiscMonitorTests */ @@ -58,14 +58,14 @@ * @test id=Xcomp-noTieredCompilation * @summary Test virtual threads using synchronized * @library /test/lib - * @requires vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.continuations * @modules java.base/java.lang:+open * @run junit/othervm -Xcomp -XX:-TieredCompilation MiscMonitorTests */ /* * @test id=gc - * @requires vm.debug == true & vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.debug == true & vm.continuations * @library /test/lib * @modules java.base/java.lang:+open * @run junit/othervm -XX:+UnlockDiagnosticVMOptions -XX:+FullGCALot -XX:FullGCALotInterval=1000 MiscMonitorTests diff --git a/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java b/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java index 858f76253869c..eb90093081953 100644 --- a/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java +++ b/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java @@ -26,88 +26,35 @@ * @summary Test virtual thread with monitor enter/exit * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm/native --enable-native-access=ALL-UNNAMED MonitorEnterExit */ /* - * @test id=LM_LEGACY + * @test id=Xint * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorEnterExit + * @run junit/othervm/native -Xint --enable-native-access=ALL-UNNAMED MonitorEnterExit */ /* - * @test id=LM_LIGHTWEIGHT + * @test id=Xcomp * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorEnterExit + * @run junit/othervm/native -Xcomp --enable-native-access=ALL-UNNAMED MonitorEnterExit */ /* - * @test id=Xint-LM_LEGACY + * @test id=Xcomp-TieredStopAtLevel1 * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xint -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorEnterExit + * @run junit/othervm/native -Xcomp -XX:TieredStopAtLevel=1 --enable-native-access=ALL-UNNAMED MonitorEnterExit */ /* - * @test id=Xint-LM_LIGHTWEIGHT + * @test id=Xcomp-noTieredCompilation * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xint -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorEnterExit - */ - -/* - * @test id=Xcomp-LM_LEGACY - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorEnterExit - */ - -/* - * @test id=Xcomp-LM_LIGHTWEIGHT - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorEnterExit - */ - -/* - * @test id=Xcomp-TieredStopAtLevel1-LM_LEGACY - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:TieredStopAtLevel=1 -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorEnterExit - */ - -/* - * @test id=Xcomp-TieredStopAtLevel1-LM_LIGHTWEIGHT - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:TieredStopAtLevel=1 -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorEnterExit - */ - -/* - * @test id=Xcomp-noTieredCompilation-LM_LEGACY - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:-TieredCompilation -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorEnterExit - */ - -/* - * @test id=Xcomp-noTieredCompilation-LM_LIGHTWEIGHT - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:-TieredCompilation -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorEnterExit + * @run junit/othervm/native -Xcomp -XX:-TieredCompilation --enable-native-access=ALL-UNNAMED MonitorEnterExit */ import java.time.Duration; @@ -234,7 +181,6 @@ private void testReenter(Object lock, int depth) { * Test monitor reenter when there are other threads blocked trying to enter. */ @Test - @DisabledIf("LockingMode#isLegacy") void testReenterWithContention() throws Exception { var lock = new Object(); VThreadRunner.run(() -> { @@ -359,7 +305,6 @@ private void testEnterWithContentionWhenPinned() throws Exception { * Test that blocking waiting to enter a monitor releases the carrier. */ @Test - @DisabledIf("LockingMode#isLegacy") void testReleaseWhenBlocked() throws Exception { assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers"); try (ExecutorService scheduler = Executors.newFixedThreadPool(1)) { @@ -403,7 +348,6 @@ void testReleaseWhenBlocked() throws Exception { * carriers aren't released. */ @Test - @DisabledIf("LockingMode#isLegacy") void testManyBlockedThreads() throws Exception { Thread[] vthreads = new Thread[MAX_VTHREAD_COUNT]; var lock = new Object(); diff --git a/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java b/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java index 0ec0adb0fafd4..2290622df9a48 100644 --- a/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java +++ b/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java @@ -26,88 +26,35 @@ * @summary Test virtual threads using Object.wait/notifyAll * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm/native --enable-native-access=ALL-UNNAMED MonitorWaitNotify */ /* - * @test id=LM_LEGACY + * @test id=Xint * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorWaitNotify + * @run junit/othervm/native -Xint --enable-native-access=ALL-UNNAMED MonitorWaitNotify */ /* - * @test id=LM_LIGHTWEIGHT + * @test id=Xcomp * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorWaitNotify + * @run junit/othervm/native -Xcomp --enable-native-access=ALL-UNNAMED MonitorWaitNotify */ /* - * @test id=Xint-LM_LEGACY + * @test id=Xcomp-TieredStopAtLevel1 * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xint -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorWaitNotify + * @run junit/othervm/native -Xcomp -XX:TieredStopAtLevel=1 --enable-native-access=ALL-UNNAMED MonitorWaitNotify */ /* - * @test id=Xint-LM_LIGHTWEIGHT + * @test id=Xcomp-noTieredCompilation * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xint -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorWaitNotify - */ - -/* - * @test id=Xcomp-LM_LEGACY - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorWaitNotify - */ - -/* - * @test id=Xcomp-LM_LIGHTWEIGHT - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorWaitNotify - */ - -/* - * @test id=Xcomp-TieredStopAtLevel1-LM_LEGACY - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:TieredStopAtLevel=1 -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorWaitNotify - */ - -/* - * @test id=Xcomp-TieredStopAtLevel1-LM_LIGHTWEIGHT - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:TieredStopAtLevel=1 -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorWaitNotify - */ - -/* - * @test id=Xcomp-noTieredCompilation-LM_LEGACY - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:-TieredCompilation -XX:LockingMode=1 --enable-native-access=ALL-UNNAMED MonitorWaitNotify - */ - -/* - * @test id=Xcomp-noTieredCompilation-LM_LIGHTWEIGHT - * @modules java.base/java.lang:+open jdk.management - * @library /test/lib - * @build LockingMode - * @run junit/othervm/native -Xcomp -XX:-TieredCompilation -XX:LockingMode=2 --enable-native-access=ALL-UNNAMED MonitorWaitNotify + * @run junit/othervm/native -Xcomp -XX:-TieredCompilation --enable-native-access=ALL-UNNAMED MonitorWaitNotify */ import java.util.ArrayList; @@ -306,7 +253,6 @@ static Stream threadCounts() { */ @ParameterizedTest @MethodSource("threadCounts") - @DisabledIf("LockingMode#isLegacy") void testNotifyOneThread(int nPlatformThreads, int nVirtualThreads) throws Exception { int nThreads = nPlatformThreads + nVirtualThreads; @@ -364,7 +310,6 @@ void testNotifyOneThread(int nPlatformThreads, int nVirtualThreads) throws Excep */ @ParameterizedTest @MethodSource("threadCounts") - @DisabledIf("LockingMode#isLegacy") void testNotifyAllThreads(int nPlatformThreads, int nVirtualThreads) throws Exception { int nThreads = nPlatformThreads + nVirtualThreads; @@ -702,7 +647,6 @@ void testParkingPermitNotOffered() throws Exception { */ @ParameterizedTest @ValueSource(ints = { 0, 30000, Integer.MAX_VALUE }) - @DisabledIf("LockingMode#isLegacy") void testReleaseWhenWaiting1(int timeout) throws Exception { assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers"); try (ExecutorService scheduler = Executors.newFixedThreadPool(1)) { @@ -759,7 +703,6 @@ void testReleaseWhenWaiting1(int timeout) throws Exception { */ @ParameterizedTest @ValueSource(ints = { 0, 10, 20, 100, 500, 30000, Integer.MAX_VALUE }) - @DisabledIf("LockingMode#isLegacy") void testReleaseWhenWaiting2(int timeout) throws Exception { int VTHREAD_COUNT = 4 * Runtime.getRuntime().availableProcessors(); CountDownLatch latch = new CountDownLatch(VTHREAD_COUNT); diff --git a/test/jdk/java/lang/Thread/virtual/Parking.java b/test/jdk/java/lang/Thread/virtual/Parking.java index 41f7f283bdd06..56ddc04f5cb0a 100644 --- a/test/jdk/java/lang/Thread/virtual/Parking.java +++ b/test/jdk/java/lang/Thread/virtual/Parking.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -26,7 +26,6 @@ * @summary Test virtual threads using park/unpark * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit Parking */ @@ -34,7 +33,6 @@ * @test id=Xint * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm -Xint Parking */ @@ -42,7 +40,6 @@ * @test id=Xcomp * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm -Xcomp Parking */ @@ -50,7 +47,6 @@ * @test id=Xcomp-noTieredCompilation * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm -Xcomp -XX:-TieredCompilation Parking */ @@ -385,7 +381,6 @@ void testParkNanos11() throws Exception { */ @ParameterizedTest @ValueSource(booleans = { true, false }) - @DisabledIf("LockingMode#isLegacy") void testParkWhenHoldingMonitor(boolean reenter) throws Exception { assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers"); try (ExecutorService scheduler = Executors.newFixedThreadPool(1)) { @@ -435,7 +430,6 @@ void testParkWhenHoldingMonitor(boolean reenter) throws Exception { * parking doesn't release the carrier. */ @Test - @DisabledIf("LockingMode#isLegacy") void testManyParkedWhenHoldingMonitor() throws Exception { Thread[] vthreads = new Thread[MAX_VTHREAD_COUNT]; var done = new AtomicBoolean(); diff --git a/test/jdk/java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java b/test/jdk/java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java index fa754a88b8084..1c7177d9f38dc 100644 --- a/test/jdk/java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java +++ b/test/jdk/java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java @@ -29,7 +29,6 @@ * can't continue because there are no carriers available. * @modules java.base/java.lang:+open * @library /test/lib - * @requires vm.opt.LockingMode != 1 * @run main/othervm/native --enable-native-access=ALL-UNNAMED RetryMonitorEnterWhenPinned */ diff --git a/test/jdk/java/lang/Thread/virtual/ThreadAPI.java b/test/jdk/java/lang/Thread/virtual/ThreadAPI.java index a3d85660b9928..91fb06b43946a 100644 --- a/test/jdk/java/lang/Thread/virtual/ThreadAPI.java +++ b/test/jdk/java/lang/Thread/virtual/ThreadAPI.java @@ -27,7 +27,6 @@ * @summary Test Thread API with virtual threads * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm/native --enable-native-access=ALL-UNNAMED ThreadAPI */ @@ -36,7 +35,6 @@ * @requires vm.continuations * @modules java.base/java.lang:+open jdk.management * @library /test/lib - * @build LockingMode * @run junit/othervm/native -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations * --enable-native-access=ALL-UNNAMED ThreadAPI */ @@ -1112,7 +1110,6 @@ void testYieldReleasesCarrier() throws Exception { * Test Thread.yield releases carrier thread when virtual thread holds a monitor. */ @Test - @DisabledIf("LockingMode#isLegacy") void testYieldReleasesCarrierWhenHoldingMonitor() throws Exception { assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers"); var list = new CopyOnWriteArrayList(); diff --git a/test/jdk/java/lang/Thread/virtual/stress/LotsOfContendedMonitorEnter.java b/test/jdk/java/lang/Thread/virtual/stress/LotsOfContendedMonitorEnter.java index c63a4b0c94742..da45c610e8238 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/LotsOfContendedMonitorEnter.java +++ b/test/jdk/java/lang/Thread/virtual/stress/LotsOfContendedMonitorEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -24,18 +24,10 @@ /* * @test id=default * @summary Test virtual threads entering a lot of monitors with contention - * @requires vm.opt.LockingMode != 1 * @library /test/lib * @run main LotsOfContendedMonitorEnter */ -/* - * @test id=LM_LIGHTWEIGHT - * @requires vm.opt.LockingMode != 1 - * @library /test/lib - * @run main/othervm -XX:LockingMode=2 LotsOfContendedMonitorEnter - */ - import java.util.concurrent.CountDownLatch; import jdk.test.lib.thread.VThreadRunner; diff --git a/test/jdk/java/lang/Thread/virtual/stress/LotsOfUncontendedMonitorEnter.java b/test/jdk/java/lang/Thread/virtual/stress/LotsOfUncontendedMonitorEnter.java index da5fdd1161d7c..e1a8fb82bd6e1 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/LotsOfUncontendedMonitorEnter.java +++ b/test/jdk/java/lang/Thread/virtual/stress/LotsOfUncontendedMonitorEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -28,18 +28,6 @@ * @run main LotsOfUncontendedMonitorEnter */ -/* - * @test id=LM_LEGACY - * @library /test/lib - * @run main/othervm -XX:LockingMode=1 LotsOfUncontendedMonitorEnter - */ - -/* - * @test id=LM_LIGHTWEIGHT - * @library /test/lib - * @run main/othervm -XX:LockingMode=2 LotsOfUncontendedMonitorEnter - */ - import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadLocalRandom; diff --git a/test/jdk/java/lang/Thread/virtual/stress/Skynet100kWithMonitors.java b/test/jdk/java/lang/Thread/virtual/stress/Skynet100kWithMonitors.java index 9487de6b862f9..7949529af60eb 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/Skynet100kWithMonitors.java +++ b/test/jdk/java/lang/Thread/virtual/stress/Skynet100kWithMonitors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -26,13 +26,13 @@ * @summary Stress test virtual threads with a variation of the Skynet 1M benchmark that uses * a channel implementation based on object monitors. This variant uses a reduced number of * 100k virtual threads at the final level. - * @requires vm.debug != true & vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.debug != true & vm.continuations * @run main/othervm/timeout=300 Skynet100kWithMonitors 50 */ /* * @test - * @requires vm.debug == true & vm.continuations & vm.opt.LockingMode != 1 + * @requires vm.debug == true & vm.continuations * @run main/othervm/timeout=300 Skynet100kWithMonitors 10 */ diff --git a/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java b/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java index b8e9a1736c405..0f52bc67f085a 100644 --- a/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java +++ b/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java @@ -45,15 +45,6 @@ * @run main/timeout=1600 MapLoops */ -/* - * @test - * @summary Exercise multithreaded maps, using only heavy monitors. - * @requires os.arch=="x86" | os.arch=="i386" | os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "riscv64" | os.arch == "s390x" - * @requires vm.debug - * @library /test/lib - * @run main/othervm/timeout=1600 -XX:LockingMode=0 -XX:+VerifyHeavyMonitors MapLoops - */ - import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.List; diff --git a/test/jdk/jdk/internal/vm/Continuation/Basic.java b/test/jdk/jdk/internal/vm/Continuation/Basic.java index e13fa175ad5a5..dd17255f8bfc7 100644 --- a/test/jdk/jdk/internal/vm/Continuation/Basic.java +++ b/test/jdk/jdk/internal/vm/Continuation/Basic.java @@ -1,5 +1,5 @@ /* -* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2018, 2025, 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 @@ -281,39 +281,6 @@ static String barMany(long b, return "" + r; } - @Test - public void testPinnedMonitor() { - if (!legacyLockingMode()) return; - - // Test pinning due to held monitor - final AtomicReference res = new AtomicReference<>(); - - Continuation cont = new Continuation(FOO, ()-> { - syncFoo(1); - }) { - @Override - protected void onPinned(Continuation.Pinned reason) { - assert Continuation.isPinned(FOO); - res.set(reason); - } - }; - - cont.run(); - assertEquals(res.get(), Continuation.Pinned.MONITOR); - boolean isDone = cont.isDone(); - assertEquals(isDone, true); - } - - static double syncFoo(int a) { - long x = 8; - String s = "yyy"; - String r; - synchronized(FOO) { - r = bar2(a + 1); - } - return Integer.parseInt(r)+1; - } - @Test public void testNotPinnedMonitor() { final AtomicReference res = new AtomicReference<>(); @@ -419,9 +386,4 @@ static int nativeBaz(int b) { static { System.loadLibrary("BasicJNI"); } - - static boolean legacyLockingMode() { - return ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) - .getVMOption("LockingMode").getValue().equals("1"); - } } diff --git a/test/jdk/jdk/internal/vm/Continuation/Fuzz.java b/test/jdk/jdk/internal/vm/Continuation/Fuzz.java index 52730c9523b10..5f4f8c85f61cd 100644 --- a/test/jdk/jdk/internal/vm/Continuation/Fuzz.java +++ b/test/jdk/jdk/internal/vm/Continuation/Fuzz.java @@ -1,5 +1,5 @@ /* -* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2018, 2025, 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 @@ -473,7 +473,8 @@ void verifyResult(int result) { } boolean shouldPin() { - return traceHas(Op.PIN::contains) && legacyLockingMode(); + // Returns false since we never pin after we removed legacy locking. + return traceHas(Op.PIN::contains) && false; } void verifyPin(boolean yieldResult) { @@ -1032,9 +1033,4 @@ int com_mny(int depth, return log((int)res); } - - static boolean legacyLockingMode() { - return ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) - .getVMOption("LockingMode").getValue().equals("1"); - } } diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 3c7a81cd2fa86..d57962f5c5c10 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -423,10 +423,11 @@ protected String vmHasDTrace() { */ protected String vmRTMCompiler() { boolean isRTMCompiler = false; + boolean lightweightLocking = true; // Lightweight locking is currently the only locking mode. if (Compiler.isC2Enabled() && (Platform.isX86() || Platform.isX64() || Platform.isPPC()) && - is_LM_LIGHTWEIGHT().equals("false")) { + lightweightLocking == false) { isRTMCompiler = true; } return "" + isRTMCompiler; @@ -532,34 +533,6 @@ protected String vmPageSize() { return "" + WB.getVMPageSize(); } - /** - * @return LockingMode. - */ - protected String vmLockingMode() { - return "" + WB.getIntVMFlag("LockingMode"); - } - - /** - * @return "true" if LockingMode == 0 (LM_MONITOR) - */ - protected String is_LM_MONITOR() { - return "" + vmLockingMode().equals("0"); - } - - /** - * @return "true" if LockingMode == 1 (LM_LEGACY) - */ - protected String is_LM_LEGACY() { - return "" + vmLockingMode().equals("1"); - } - - /** - * @return "true" if LockingMode == 2 (LM_LIGHTWEIGHT) - */ - protected String is_LM_LIGHTWEIGHT() { - return "" + vmLockingMode().equals("2"); - } - /** * Check if Graal is used as JIT compiler. * diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index f3d9ba7b6e9fe..4a97be61b04f9 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -118,6 +118,12 @@ public boolean isMonitorInflated(Object obj) { return isMonitorInflated0(obj); } + private native void forceInflateMonitorLockedObject0(Object obj); + public void forceInflateMonitorLockedObject(Object obj) { + Objects.requireNonNull(obj); + forceInflateMonitorLockedObject0(obj); + } + public native long getInUseMonitorCount(); public native int getLockStackCapacity();