From d0d547e0f53d7cb4c8f452a9b692987e3b29d749 Mon Sep 17 00:00:00 2001 From: Fredrik Bredberg Date: Thu, 5 Jun 2025 13:15:24 +0200 Subject: [PATCH 1/2] First try. --- .../cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 4 +- src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 4 +- src/hotspot/share/prims/whitebox.cpp | 16 ++ src/hotspot/share/runtime/arguments.cpp | 10 +- .../share/runtime/continuationFreezeThaw.cpp | 4 +- src/hotspot/share/runtime/globals.hpp | 12 +- src/hotspot/share/runtime/javaThread.cpp | 4 +- .../share/utilities/globalDefinitions.cpp | 2 + .../share/utilities/globalDefinitions.hpp | 2 + .../sun/jvm/hotspot/runtime/LockingMode.java | 60 ------- .../sun/jvm/hotspot/runtime/Threads.java | 33 ++-- test/hotspot/gtest/runtime/test_lockStack.cpp | 8 +- .../locks/TestSynchronizeWithEmptyBlock.java | 6 +- test/hotspot/jtreg/gtest/LockStackGtests.java | 6 +- .../CommandLine/VMDeprecatedOptions.java | 3 +- .../runtime/Monitor/ConcurrentDeflation.java | 11 +- ...tressWrapper_TestRecursiveLocking_36M.java | 110 +++++++++--- .../runtime/Monitor/TestRecursiveLocking.java | 160 +++++++++++------- .../lockStack/TestLockStackCapacity.java | 13 +- .../locking/TestRecursiveMonitorChurn.java | 5 +- .../vthread/JNIMonitor/JNIMonitor.java | 10 +- .../StopThreadTest/StopThreadTest.java | 6 +- test/jdk/com/sun/jdi/EATests.java | 36 +--- .../Thread/virtual/CarrierThreadInfo.java | 19 +-- .../java/lang/Thread/virtual/LockingMode.java | 39 ----- .../lang/Thread/virtual/MiscMonitorTests.java | 14 +- .../lang/Thread/virtual/MonitorEnterExit.java | 72 +------- .../Thread/virtual/MonitorWaitNotify.java | 73 +------- .../jdk/java/lang/Thread/virtual/Parking.java | 8 +- .../virtual/RetryMonitorEnterWhenPinned.java | 1 - .../java/lang/Thread/virtual/ThreadAPI.java | 3 - .../stress/LotsOfContendedMonitorEnter.java | 10 +- .../stress/LotsOfUncontendedMonitorEnter.java | 14 +- .../stress/Skynet100kWithMonitors.java | 6 +- .../ConcurrentHashMap/MapLoops.java | 2 +- .../jdk/internal/vm/Continuation/Basic.java | 40 +---- .../jdk/internal/vm/Continuation/Fuzz.java | 7 +- test/jtreg-ext/requires/VMProps.java | 29 +--- test/lib/jdk/test/whitebox/WhiteBox.java | 6 + 39 files changed, 336 insertions(+), 532 deletions(-) delete mode 100644 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/LockingMode.java delete mode 100644 test/jdk/java/lang/Thread/virtual/LockingMode.java diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 914967e40097d..3585fa3c67e99 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -239,7 +239,7 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, Register br(Assembler::NE, no_count); bind(count); - if (LockingMode == LM_LEGACY) { + if (LockingMode != LM_LIGHTWEIGHT) { inc_held_monitor_count(rscratch1); } @@ -346,7 +346,7 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe br(Assembler::NE, no_count); bind(count); - if (LockingMode == LM_LEGACY) { + if (LockingMode != LM_LIGHTWEIGHT) { dec_held_monitor_count(rscratch1); } diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 177be6e59f74a..547aeba1bdcf6 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -317,7 +317,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp jccb(Assembler::notZero, NO_COUNT); // jump if ZFlag == 0 bind(COUNT); - if (LockingMode == LM_LEGACY) { + if (LockingMode != LM_LIGHTWEIGHT) { // Count monitors in fast path increment(Address(thread, JavaThread::held_monitor_count_offset())); } @@ -452,7 +452,7 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t bind(COUNT); - if (LockingMode == LM_LEGACY) { + if (LockingMode != LM_LIGHTWEIGHT) { // Count monitors in fast path decrementq(Address(r15_thread, JavaThread::held_monitor_count_offset())); } diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index f14c5efc65d3c..69dd4584d8372 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" @@ -1908,6 +1909,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(jlong, WB_getInUseMonitorCount(JNIEnv* env, jobject wb)) return (jlong) WhiteBox::get_in_use_monitor_count(); WB_END @@ -2908,6 +2923,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"getInUseMonitorCount", CC"()J", (void*)&WB_getInUseMonitorCount }, {CC"getLockStackCapacity", CC"()I", (void*)&WB_getLockStackCapacity }, {CC"supportsRecursiveLightweightLocking", CC"()Z", (void*)&WB_supportsRecursiveLightweightLocking }, diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 7592d233f0c2f..d8bb80e36584d 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1845,6 +1845,10 @@ bool Arguments::check_vm_args_consistency() { } #endif + if (UseHeavyMonitors) { + LockingMode = LM_MONITOR; + } + if (UseObjectMonitorTable && LockingMode != LM_LIGHTWEIGHT) { // ObjectMonitorTable requires lightweight locking. FLAG_SET_CMDLINE(UseObjectMonitorTable, false); @@ -1854,13 +1858,13 @@ bool Arguments::check_vm_args_consistency() { #if !defined(X86) && !defined(AARCH64) && !defined(PPC64) && !defined(RISCV64) && !defined(S390) if (LockingMode == LM_MONITOR) { jio_fprintf(defaultStream::error_stream(), - "LockingMode == 0 (LM_MONITOR) is not fully implemented on this architecture\n"); + "-XX:+UseHeavyMonitors is not fully implemented on this architecture\n"); return false; } #endif - if (VerifyHeavyMonitors && LockingMode != LM_MONITOR) { + if (VerifyHeavyMonitors && !UseHeavyMonitors) { jio_fprintf(defaultStream::error_stream(), - "-XX:+VerifyHeavyMonitors requires LockingMode == 0 (LM_MONITOR)\n"); + "-XX:+VerifyHeavyMonitors requires -XX:+UseHeavyMonitors\n"); return false; } return status; diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index a928b0443eef4..ad7e45813bdb0 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -612,7 +612,7 @@ void FreezeBase::unwind_frames() { entry->flush_stack_processing(_thread); assert_frames_in_continuation_are_safe(_thread); JFR_ONLY(Jfr::check_and_process_sample_request(_thread);) - assert(LockingMode != LM_LEGACY || !monitors_on_stack(_thread), "unexpected monitors on stack"); + assert(LockingMode == LM_LIGHTWEIGHT || !monitors_on_stack(_thread), "unexpected monitors on stack"); set_anchor_to_entry(_thread, entry); } @@ -1741,7 +1741,7 @@ static inline freeze_result freeze_internal(JavaThread* current, intptr_t* const assert(entry->is_virtual_thread() == (entry->scope(current) == java_lang_VirtualThread::vthread_scope()), ""); - assert(LockingMode == LM_LEGACY || (current->held_monitor_count() == 0 && current->jni_monitor_count() == 0), + assert(LockingMode != LM_LIGHTWEIGHT || (current->held_monitor_count() == 0 && current->jni_monitor_count() == 0), "Held monitor count should only be used for LM_LEGACY: " INT64_FORMAT " JNI: " INT64_FORMAT, (int64_t)current->held_monitor_count(), (int64_t)current->jni_monitor_count()); if (entry->is_pinned() || current->held_monitor_count() > 0) { diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 290ce0d3cba2d..79e3528b1c3c3 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1052,9 +1052,12 @@ const int ObjectAlignmentInBytes = 8; product(bool, ErrorFileToStdout, false, \ "If true, error data is printed to stdout instead of a file") \ \ + develop(bool, UseHeavyMonitors, false, \ + "Use heavyweight instead of lightweight Java monitors") \ + \ develop(bool, VerifyHeavyMonitors, false, \ "Checks that no stack locking happens when using " \ - "-XX:LockingMode=0 (LM_MONITOR)") \ + "heavy monitors") \ \ product(bool, PrintStringTableStatistics, false, \ "print statistics about the StringTable and SymbolTable") \ @@ -1953,13 +1956,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/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index 57f93f87d4798..41b5c915c6dde 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -1998,7 +1998,7 @@ void JavaThread::trace_stack() { void JavaThread::inc_held_monitor_count(intx i, bool jni) { #ifdef SUPPORT_MONITOR_COUNT - if (LockingMode != LM_LEGACY) { + if (LockingMode == LM_LIGHTWEIGHT) { // Nothing to do. Just do some sanity check. assert(_held_monitor_count == 0, "counter should not be used"); assert(_jni_monitor_count == 0, "counter should not be used"); @@ -2021,7 +2021,7 @@ void JavaThread::inc_held_monitor_count(intx i, bool jni) { void JavaThread::dec_held_monitor_count(intx i, bool jni) { #ifdef SUPPORT_MONITOR_COUNT - if (LockingMode != LM_LEGACY) { + if (LockingMode == LM_LIGHTWEIGHT) { // Nothing to do. Just do some sanity check. assert(_held_monitor_count == 0, "counter should not be used"); assert(_jni_monitor_count == 0, "counter should not be used"); 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/gtest/runtime/test_lockStack.cpp b/test/hotspot/gtest/runtime/test_lockStack.cpp index 3163898e17dd6..a424b369dfa1c 100644 --- a/test/hotspot/gtest/runtime/test_lockStack.cpp +++ b/test/hotspot/gtest/runtime/test_lockStack.cpp @@ -63,7 +63,7 @@ class LockStackTest : public ::testing::Test { } while (false) TEST_VM_F(LockStackTest, is_recursive) { - if (LockingMode != LM_LIGHTWEIGHT || !VM_Version::supports_recursive_lightweight_locking()) { + if (UseHeavyMonitors || !VM_Version::supports_recursive_lightweight_locking()) { return; } @@ -130,7 +130,7 @@ TEST_VM_F(LockStackTest, is_recursive) { } TEST_VM_F(LockStackTest, try_recursive_enter) { - if (LockingMode != LM_LIGHTWEIGHT || !VM_Version::supports_recursive_lightweight_locking()) { + if (UseHeavyMonitors || !VM_Version::supports_recursive_lightweight_locking()) { return; } @@ -197,7 +197,7 @@ TEST_VM_F(LockStackTest, try_recursive_enter) { } TEST_VM_F(LockStackTest, contains) { - if (LockingMode != LM_LIGHTWEIGHT) { + if (UseHeavyMonitors) { return; } @@ -263,7 +263,7 @@ TEST_VM_F(LockStackTest, contains) { } TEST_VM_F(LockStackTest, remove) { - if (LockingMode != LM_LIGHTWEIGHT) { + if (UseHeavyMonitors) { return; } diff --git a/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java b/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java index 4165e6285b691..7cf40d669f6ec 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,10 +26,10 @@ * @bug 8337660 * @summary Test that C2 does not remove blocks with BoxLock nodes that are * otherwise empty. - * @run main/othervm -Xbatch -XX:LockingMode=1 + * @run main/othervm -Xbatch * -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::* * compiler.locks.TestSynchronizeWithEmptyBlock - * @run main/othervm -Xbatch + * @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+UseObjectMonitorTable * -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/CommandLine/VMDeprecatedOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java index 5456f560fa128..776d87d4a7f17 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -58,7 +58,6 @@ public class VMDeprecatedOptions { // { , } // deprecated non-alias flags: {"AllowRedefinitionToAddDeleteMethods", "true"}, - {"LockingMode", "1"}, // deprecated alias flags (see also aliased_jvm_flags): {"CreateMinidumpOnCrash", "false"} 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..6f3227f2b8ab1 100644 --- a/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java +++ b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java @@ -23,8 +23,9 @@ */ /* - * @test id=Xint_outer_inner + * @test id=Xint_outer_inner_debug_monitor * @requires vm.flagless + * @requires vm.debug * @summary Tests recursive locking in -Xint in outer then inner mode. * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox @@ -33,28 +34,37 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 + */ + +/* + * @test id=Xint_outer_inner + * @requires vm.flagless + * @summary Tests recursive locking in -Xint in outer then inner 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 * -Xint - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ /* - * @test id=Xint_alternate_AB + * @test id=Xint_alternate_AB_debug_monitor * @requires vm.flagless + * @requires vm.debug * @summary Tests recursive locking in -Xint in alternate A and B mode. * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox @@ -63,28 +73,37 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 + */ + +/* + * @test id=Xint_alternate_AB + * @requires vm.flagless + * @summary Tests recursive locking in -Xint 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 * -Xint - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ /* - * @test id=C1_outer_inner + * @test id=C1_outer_inner_debug_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler1.enabled * @summary Tests recursive locking in C1 in outer then inner mode. * @library /testlibrary /test/lib @@ -94,28 +113,38 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 + */ + +/* + * @test id=C1_outer_inner + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 in outer then inner 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:TieredStopAtLevel=1 - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ /* - * @test id=C1_alternate_AB + * @test id=C1_alternate_AB_debg_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler1.enabled * @summary Tests recursive locking in C1 in alternate A and B mode. * @library /testlibrary /test/lib @@ -125,28 +154,38 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 + */ + +/* + * @test id=C1_alternate_AB + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 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:TieredStopAtLevel=1 - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ /* - * @test id=C2_outer_inner + * @test id=C2_outer_inner_debug_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler2.enabled * @summary Tests recursive locking in C2 in outer then inner mode. * @library /testlibrary /test/lib @@ -156,25 +195,51 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 + */ + +/* + * @test id=C2_outer_inner + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @summary Tests recursive locking in C2 in outer then inner 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:-EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ +/* + * @test id=C2_alternate_AB_debug_monitor + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @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:+UseHeavyMonitors + * -XX:-EliminateNestedLocks + * -Xms256m -Xmx256m + * TestRecursiveLocking 120 2 + */ + /* * @test id=C2_alternate_AB * @requires vm.flagless @@ -186,21 +251,20 @@ * @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:+UseHeavyMonitors * -XX:-EliminateNestedLocks * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 * * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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..ac1d9ddb02e27 100644 --- a/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java +++ b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java @@ -23,8 +23,9 @@ */ /* - * @test id=Xint_outer_inner + * @test id=Xint_outer_inner_debug_monitor * @requires vm.flagless + * @requires vm.debug * @summary Tests recursive locking in -Xint in outer then inner mode. * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox @@ -33,28 +34,37 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 + */ + +/* + * @test id=Xint_outer_inner + * @requires vm.flagless + * @summary Tests recursive locking in -Xint in outer then inner 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 * -Xint - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 * * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 */ /* - * @test id=Xint_alternate_AB + * @test id=Xint_alternate_AB_debug_monitor * @requires vm.flagless + * @requires vm.debug * @summary Tests recursive locking in -Xint in alternate A and B mode. * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox @@ -63,28 +73,37 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 + */ + +/* + * @test id=Xint_alternate_AB + * @requires vm.flagless + * @summary Tests recursive locking in -Xint 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 * -Xint - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 * * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 */ /* - * @test id=C1_outer_inner + * @test id=C1_outer_inner_debug_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler1.enabled * @summary Tests recursive locking in C1 in outer then inner mode. * @library /testlibrary /test/lib @@ -94,28 +113,38 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 + */ + +/* + * @test id=C1_outer_inner + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 in outer then inner 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:TieredStopAtLevel=1 - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ /* - * @test id=C1_alternate_AB + * @test id=C1_alternate_AB_debug_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler1.enabled * @summary Tests recursive locking in C1 in alternate A and B mode. * @library /testlibrary /test/lib @@ -125,28 +154,38 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 + */ + +/* + * @test id=C1_alternate_AB + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 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:TieredStopAtLevel=1 - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -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 */ /* - * @test id=C2_outer_inner + * @test id=C2_outer_inner_debug_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler2.enabled * @summary Tests recursive locking in C2 in outer then inner mode. * @library /testlibrary /test/lib @@ -156,51 +195,70 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:LockingMode=0 + * -XX:+UseHeavyMonitors * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 + */ + +/* + * @test id=C2_outer_inner + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @summary Tests recursive locking in C2 in outer then inner 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:-EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 * * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:LockingMode=2 * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 */ /* - * @test id=C2_alternate_AB + * @test id=C2_alternate_AB_debug_monitor * @requires vm.flagless + * @requires vm.debug * @requires vm.compiler2.enabled * @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:+UseHeavyMonitors * -XX:-EliminateNestedLocks * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 + */ + +/* + * @test id=C2_alternate_AB + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @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=1 + * -XX:+UseObjectMonitorTable * -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 +270,8 @@ public class TestRecursiveLocking { static final WhiteBox WB = WhiteBox.getWhiteBox(); - static final int flagLockingMode = WB.getIntVMFlag("LockingMode").intValue(); + static final boolean flagHeavyMonitors = WB.getBooleanVMFlag("UseHeavyMonitors"); 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 +284,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 +299,7 @@ synchronized void runInner(int depth, SynchronizedObject outer) { } else { runInner(depth - 1, outer); } - if (flagLockingMode != LM_MONITOR) { + if (!flagHeavyMonitors) { assertNotInflated(); } } @@ -256,7 +307,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 +315,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 +332,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 +355,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 +370,7 @@ synchronized void runA(int depth, SynchronizedObject B) { // to [B, B ... B]. assertInflated(); } - } else if (flagLockingMode == LM_MONITOR) { + } else if (flagHeavyMonitors) { assertInflated(); } @@ -334,7 +381,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 +417,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 +487,7 @@ public static void main(String... argv) throws Exception { } } - System.out.println("INFO: LockingMode=" + flagLockingMode); + System.out.println("INFO: UseHeavyMonitors=" + 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 index 56bb705a0b2ab..ee1e9b946f297 100644 --- a/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java +++ b/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -52,6 +52,7 @@ * @summary Normal lock then unlock * @library /test/lib * @modules java.base/java.lang:+open + * @requires vm.debug * @requires vm.continuations * @run driver JNIMonitor Normal */ @@ -62,6 +63,7 @@ * @summary Normal lock then unlock by multiple threads * @library /test/lib * @modules java.base/java.lang:+open + * @requires vm.debug * @requires vm.continuations * @run driver JNIMonitor MultiNormal */ @@ -72,6 +74,7 @@ * @summary Don't do the unlock and exit normally * @library /test/lib * @modules java.base/java.lang:+open + * @requires vm.debug * @requires vm.continuations * @run driver JNIMonitor MissingUnlock */ @@ -82,6 +85,7 @@ * @summary Don't do the unlock and exit normally, by multiple threads * @library /test/lib * @modules java.base/java.lang:+open + * @requires vm.debug * @requires vm.continuations * @run driver JNIMonitor MultiMissingUnlock */ @@ -92,6 +96,7 @@ * @summary Don't do the unlock and exit by throwing * @library /test/lib * @modules java.base/java.lang:+open + * @requires vm.debug * @requires vm.continuations * @run driver JNIMonitor MissingUnlockWithThrow */ @@ -102,6 +107,7 @@ * @summary Don't do the unlock and exit by throwing, by multiple threads * @library /test/lib * @modules java.base/java.lang:+open + * @requires vm.debug * @requires vm.continuations * @run driver JNIMonitor MultiMissingUnlockWithThrow */ @@ -120,7 +126,7 @@ public static void main(String[] args) throws Exception { // Enable thread termination logging as a visual cross-check "-Xlog:thread+os=info", // We only count monitors in LM_LEGACY mode - "-XX:LockingMode=1", + "-XX:+UseHeavyMonitors", // Disable compact headers since that switches locking mode to LM_LIGHTWEIGHT "-XX:-UseCompactObjectHeaders", "JNIMonitor$" + test, 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..02598ea04295d 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 @@ -42,7 +42,7 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -51,7 +51,7 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:-EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -60,7 +60,7 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -69,7 +69,7 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * * @run driver EATests * -XX:+UnlockDiagnosticVMOptions @@ -79,7 +79,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -88,7 +87,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:-EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -97,7 +95,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * @run driver EATests * -XX:+UnlockDiagnosticVMOptions * -Xms256m -Xmx256m @@ -106,7 +103,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. @@ -132,7 +128,7 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=1 + * -XX:+UseObjectMonitorTable * -XX:DiagnoseSyncOnValueBasedClasses=2 * * @comment Re-lock may inflate monitors when re-locking, which cause monitorinflation trace logging. @@ -144,23 +140,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 +152,6 @@ * -XX:+WhiteBoxAPI * -Xbatch * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks - * -XX:LockingMode=2 * -XX:GuaranteedAsyncDeflationInterval=1 */ @@ -1815,8 +1797,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..df09a0f9dbb95 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 @@ -32,27 +32,20 @@ */ /** - * @test id=LM_LIGHTWEIGHT + * @test id=table * @requires vm.continuations * @modules java.base/java.lang:+open * @library /test/lib - * @run junit/othervm -XX:LockingMode=2 CarrierThreadInfo + * @run junit/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UseObjectMonitorTable CarrierThreadInfo */ /** - * @test id=LM_LEGACY + * @test id=monitor + * @requires vm.debug * @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 + * @run junit/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UseHeavyMonitors CarrierThreadInfo */ import java.lang.management.LockInfo; 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..eacfaeb07854d 100644 --- a/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java +++ b/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java @@ -51,7 +51,7 @@ * @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 + * @run main/othervm/timeout=1600 -XX:+UseHeavyMonitors -XX:+VerifyHeavyMonitors MapLoops */ import static java.util.concurrent.TimeUnit.MILLISECONDS; 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..85c5ff66366e0 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 @@ -1034,7 +1034,8 @@ int com_mny(int depth, } static boolean legacyLockingMode() { - return ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) - .getVMOption("LockingMode").getValue().equals("1"); + // return ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) + // .getVMOption("LockingMode").getValue().equals("1"); + return false; } } diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 360c96c74ef0d..6dfd877200450 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -424,7 +424,7 @@ protected String vmRTMCompiler() { if (Compiler.isC2Enabled() && (Platform.isX86() || Platform.isX64() || Platform.isPPC()) && - is_LM_LIGHTWEIGHT().equals("false")) { + vmUseHeavyMonitors().equals("true")) { isRTMCompiler = true; } return "" + isRTMCompiler; @@ -531,31 +531,10 @@ protected String vmPageSize() { } /** - * @return LockingMode. + * @return UseHeavyMonitors. */ - 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"); + protected String vmUseHeavyMonitors() { + return "" + WB.getBooleanVMFlag("UseHeavyMonitors"); } /** diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index 10fad866ca316..5d6e2ffc858b2 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(); From 775c30a41c16d4146c5c8162b4bb41187b802ac8 Mon Sep 17 00:00:00 2001 From: Fredrik Bredberg Date: Fri, 13 Jun 2025 10:46:36 +0200 Subject: [PATCH 2/2] Update after pre-review --- .../cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 4 +- src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 4 +- src/hotspot/share/runtime/arguments.cpp | 12 +- .../share/runtime/continuationFreezeThaw.cpp | 4 +- src/hotspot/share/runtime/globals.hpp | 5 +- src/hotspot/share/runtime/javaThread.cpp | 4 +- test/hotspot/gtest/runtime/test_lockStack.cpp | 8 +- .../locks/TestSynchronizeWithEmptyBlock.java | 3 - ...tressWrapper_TestRecursiveLocking_36M.java | 154 --------- .../runtime/Monitor/TestRecursiveLocking.java | 152 +-------- .../vthread/JNIMonitor/JNIMonitor.java | 309 ------------------ test/jdk/com/sun/jdi/EATests.java | 46 --- .../Thread/virtual/CarrierThreadInfo.java | 17 - .../ConcurrentHashMap/MapLoops.java | 9 - .../jdk/internal/vm/Continuation/Fuzz.java | 9 +- test/jtreg-ext/requires/VMProps.java | 10 +- 16 files changed, 23 insertions(+), 727 deletions(-) delete mode 100644 test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 3585fa3c67e99..914967e40097d 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -239,7 +239,7 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, Register br(Assembler::NE, no_count); bind(count); - if (LockingMode != LM_LIGHTWEIGHT) { + if (LockingMode == LM_LEGACY) { inc_held_monitor_count(rscratch1); } @@ -346,7 +346,7 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe br(Assembler::NE, no_count); bind(count); - if (LockingMode != LM_LIGHTWEIGHT) { + if (LockingMode == LM_LEGACY) { dec_held_monitor_count(rscratch1); } diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 547aeba1bdcf6..177be6e59f74a 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -317,7 +317,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp jccb(Assembler::notZero, NO_COUNT); // jump if ZFlag == 0 bind(COUNT); - if (LockingMode != LM_LIGHTWEIGHT) { + if (LockingMode == LM_LEGACY) { // Count monitors in fast path increment(Address(thread, JavaThread::held_monitor_count_offset())); } @@ -452,7 +452,7 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t bind(COUNT); - if (LockingMode != LM_LIGHTWEIGHT) { + if (LockingMode == LM_LEGACY) { // Count monitors in fast path decrementq(Address(r15_thread, JavaThread::held_monitor_count_offset())); } diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index d8bb80e36584d..1e01d3209d634 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1838,17 +1838,13 @@ 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"); } #endif - if (UseHeavyMonitors) { - LockingMode = LM_MONITOR; - } - if (UseObjectMonitorTable && LockingMode != LM_LIGHTWEIGHT) { // ObjectMonitorTable requires lightweight locking. FLAG_SET_CMDLINE(UseObjectMonitorTable, false); @@ -1858,13 +1854,13 @@ bool Arguments::check_vm_args_consistency() { #if !defined(X86) && !defined(AARCH64) && !defined(PPC64) && !defined(RISCV64) && !defined(S390) if (LockingMode == LM_MONITOR) { jio_fprintf(defaultStream::error_stream(), - "-XX:+UseHeavyMonitors is not fully implemented on this architecture\n"); + "LockingMode == 0 (LM_MONITOR) is not fully implemented on this architecture\n"); return false; } #endif - if (VerifyHeavyMonitors && !UseHeavyMonitors) { + if (VerifyHeavyMonitors && LockingMode != LM_MONITOR) { jio_fprintf(defaultStream::error_stream(), - "-XX:+VerifyHeavyMonitors requires -XX:+UseHeavyMonitors\n"); + "-XX:+VerifyHeavyMonitors requires LockingMode == 0 (LM_MONITOR)\n"); return false; } return status; diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index ad7e45813bdb0..a928b0443eef4 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -612,7 +612,7 @@ void FreezeBase::unwind_frames() { entry->flush_stack_processing(_thread); assert_frames_in_continuation_are_safe(_thread); JFR_ONLY(Jfr::check_and_process_sample_request(_thread);) - assert(LockingMode == LM_LIGHTWEIGHT || !monitors_on_stack(_thread), "unexpected monitors on stack"); + assert(LockingMode != LM_LEGACY || !monitors_on_stack(_thread), "unexpected monitors on stack"); set_anchor_to_entry(_thread, entry); } @@ -1741,7 +1741,7 @@ static inline freeze_result freeze_internal(JavaThread* current, intptr_t* const assert(entry->is_virtual_thread() == (entry->scope(current) == java_lang_VirtualThread::vthread_scope()), ""); - assert(LockingMode != LM_LIGHTWEIGHT || (current->held_monitor_count() == 0 && current->jni_monitor_count() == 0), + assert(LockingMode == LM_LEGACY || (current->held_monitor_count() == 0 && current->jni_monitor_count() == 0), "Held monitor count should only be used for LM_LEGACY: " INT64_FORMAT " JNI: " INT64_FORMAT, (int64_t)current->held_monitor_count(), (int64_t)current->jni_monitor_count()); if (entry->is_pinned() || current->held_monitor_count() > 0) { diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 79e3528b1c3c3..0457d353a3e47 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1052,12 +1052,9 @@ const int ObjectAlignmentInBytes = 8; product(bool, ErrorFileToStdout, false, \ "If true, error data is printed to stdout instead of a file") \ \ - develop(bool, UseHeavyMonitors, false, \ - "Use heavyweight instead of lightweight Java monitors") \ - \ develop(bool, VerifyHeavyMonitors, false, \ "Checks that no stack locking happens when using " \ - "heavy monitors") \ + "-XX:LockingMode=0 (LM_MONITOR)") \ \ product(bool, PrintStringTableStatistics, false, \ "print statistics about the StringTable and SymbolTable") \ diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index 41b5c915c6dde..57f93f87d4798 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -1998,7 +1998,7 @@ void JavaThread::trace_stack() { void JavaThread::inc_held_monitor_count(intx i, bool jni) { #ifdef SUPPORT_MONITOR_COUNT - if (LockingMode == LM_LIGHTWEIGHT) { + if (LockingMode != LM_LEGACY) { // Nothing to do. Just do some sanity check. assert(_held_monitor_count == 0, "counter should not be used"); assert(_jni_monitor_count == 0, "counter should not be used"); @@ -2021,7 +2021,7 @@ void JavaThread::inc_held_monitor_count(intx i, bool jni) { void JavaThread::dec_held_monitor_count(intx i, bool jni) { #ifdef SUPPORT_MONITOR_COUNT - if (LockingMode == LM_LIGHTWEIGHT) { + if (LockingMode != LM_LEGACY) { // Nothing to do. Just do some sanity check. assert(_held_monitor_count == 0, "counter should not be used"); assert(_jni_monitor_count == 0, "counter should not be used"); diff --git a/test/hotspot/gtest/runtime/test_lockStack.cpp b/test/hotspot/gtest/runtime/test_lockStack.cpp index a424b369dfa1c..3163898e17dd6 100644 --- a/test/hotspot/gtest/runtime/test_lockStack.cpp +++ b/test/hotspot/gtest/runtime/test_lockStack.cpp @@ -63,7 +63,7 @@ class LockStackTest : public ::testing::Test { } while (false) TEST_VM_F(LockStackTest, is_recursive) { - if (UseHeavyMonitors || !VM_Version::supports_recursive_lightweight_locking()) { + if (LockingMode != LM_LIGHTWEIGHT || !VM_Version::supports_recursive_lightweight_locking()) { return; } @@ -130,7 +130,7 @@ TEST_VM_F(LockStackTest, is_recursive) { } TEST_VM_F(LockStackTest, try_recursive_enter) { - if (UseHeavyMonitors || !VM_Version::supports_recursive_lightweight_locking()) { + if (LockingMode != LM_LIGHTWEIGHT || !VM_Version::supports_recursive_lightweight_locking()) { return; } @@ -197,7 +197,7 @@ TEST_VM_F(LockStackTest, try_recursive_enter) { } TEST_VM_F(LockStackTest, contains) { - if (UseHeavyMonitors) { + if (LockingMode != LM_LIGHTWEIGHT) { return; } @@ -263,7 +263,7 @@ TEST_VM_F(LockStackTest, contains) { } TEST_VM_F(LockStackTest, remove) { - if (UseHeavyMonitors) { + if (LockingMode != LM_LIGHTWEIGHT) { return; } diff --git a/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java b/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java index 7cf40d669f6ec..1f861f301e3b0 100644 --- a/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java +++ b/test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java @@ -29,9 +29,6 @@ * @run main/othervm -Xbatch * -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::* * compiler.locks.TestSynchronizeWithEmptyBlock - * @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+UseObjectMonitorTable - * -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::* - * compiler.locks.TestSynchronizeWithEmptyBlock */ package compiler.locks; diff --git a/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java index 6f3227f2b8ab1..0eeacabb82f89 100644 --- a/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java +++ b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java @@ -22,23 +22,6 @@ * */ -/* - * @test id=Xint_outer_inner_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @summary Tests recursive locking in -Xint in outer then inner 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 - * -Xint - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - */ - /* * @test id=Xint_outer_inner * @requires vm.flagless @@ -50,34 +33,10 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:+UseObjectMonitorTable - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 */ -/* - * @test id=Xint_alternate_AB_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @summary Tests recursive locking in -Xint 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 - * -Xint - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - */ - /* * @test id=Xint_alternate_AB * @requires vm.flagless @@ -89,35 +48,10 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:+UseObjectMonitorTable - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 */ -/* - * @test id=C1_outer_inner_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler1.enabled - * @summary Tests recursive locking in C1 in outer then inner 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:TieredStopAtLevel=1 - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - */ - /* * @test id=C1_outer_inner * @requires vm.flagless @@ -130,35 +64,10 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:+UseObjectMonitorTable - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 */ -/* - * @test id=C1_alternate_AB_debg_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler1.enabled - * @summary Tests recursive locking in C1 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:TieredStopAtLevel=1 - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - */ - /* * @test id=C1_alternate_AB * @requires vm.flagless @@ -171,35 +80,10 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:+UseObjectMonitorTable - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 * -Xms256m -Xmx256m * TestRecursiveLocking 120 2 */ -/* - * @test id=C2_outer_inner_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler2.enabled - * @summary Tests recursive locking in C2 in outer then inner 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:-EliminateNestedLocks - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - */ - /* * @test id=C2_outer_inner * @requires vm.flagless @@ -212,32 +96,8 @@ * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 120 1 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 1 - */ - -/* - * @test id=C2_alternate_AB_debug_monitor - * @requires vm.flagless - * @requires vm.compiler2.enabled - * @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:+UseHeavyMonitors - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 */ /* @@ -247,21 +107,7 @@ * @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:+UseHeavyMonitors - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 - * - * @run main/othervm/timeout=240 -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UseObjectMonitorTable - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 120 2 * * @run main/othervm/timeout=240 -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI diff --git a/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java index ac1d9ddb02e27..f64019a14ecb1 100644 --- a/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java +++ b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java @@ -22,23 +22,6 @@ * */ -/* - * @test id=Xint_outer_inner_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @summary Tests recursive locking in -Xint in outer then inner 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 - * -Xint - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - */ - /* * @test id=Xint_outer_inner * @requires vm.flagless @@ -50,32 +33,8 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - */ - -/* - * @test id=Xint_alternate_AB_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @summary Tests recursive locking in -Xint 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 - * -Xint - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 */ /* @@ -89,35 +48,10 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -Xint - * -XX:+UseObjectMonitorTable - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xint * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 */ -/* - * @test id=C1_outer_inner_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler1.enabled - * @summary Tests recursive locking in C1 in outer then inner 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:TieredStopAtLevel=1 - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - */ - /* * @test id=C1_outer_inner * @requires vm.flagless @@ -130,33 +64,8 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - */ - -/* - * @test id=C1_alternate_AB_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler1.enabled - * @summary Tests recursive locking in C1 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:TieredStopAtLevel=1 - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 */ /* @@ -171,33 +80,8 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:TieredStopAtLevel=1 - * -XX:+UseObjectMonitorTable * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:TieredStopAtLevel=1 - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - */ - -/* - * @test id=C2_outer_inner_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler2.enabled - * @summary Tests recursive locking in C2 in outer then inner 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:-EliminateNestedLocks - * -XX:+UseHeavyMonitors - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 */ /* @@ -212,35 +96,10 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks - * -XX:+UseObjectMonitorTable - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 1 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-EliminateNestedLocks * -Xms256m -Xmx256m * TestRecursiveLocking 5 1 */ -/* - * @test id=C2_alternate_AB_debug_monitor - * @requires vm.flagless - * @requires vm.debug - * @requires vm.compiler2.enabled - * @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:+UseHeavyMonitors - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - */ - /* * @test id=C2_alternate_AB * @requires vm.flagless @@ -252,13 +111,6 @@ * * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UseObjectMonitorTable - * -XX:-EliminateNestedLocks - * -Xms256m -Xmx256m - * TestRecursiveLocking 5 2 - * - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-EliminateNestedLocks * -Xms256m -Xmx256m * TestRecursiveLocking 5 2 @@ -270,7 +122,7 @@ public class TestRecursiveLocking { static final WhiteBox WB = WhiteBox.getWhiteBox(); - static final boolean flagHeavyMonitors = WB.getBooleanVMFlag("UseHeavyMonitors"); + static final boolean flagHeavyMonitors = WB.getBooleanVMFlag("VerifyHeavyMonitors"); static final int constLockStackCapacity = WB.getLockStackCapacity(); static final int def_mode = 2; static final int def_n_secs = 30; @@ -487,7 +339,7 @@ public static void main(String... argv) throws Exception { } } - System.out.println("INFO: UseHeavyMonitors=" + flagHeavyMonitors); + 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/vthread/JNIMonitor/JNIMonitor.java b/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java deleted file mode 100644 index ee1e9b946f297..0000000000000 --- a/test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2021, 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 - * 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.debug - * @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.debug - * @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.debug - * @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.debug - * @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.debug - * @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.debug - * @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:+UseHeavyMonitors", - // 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/jdk/com/sun/jdi/EATests.java b/test/jdk/com/sun/jdi/EATests.java index 02598ea04295d..321855b496930 100644 --- a/test/jdk/com/sun/jdi/EATests.java +++ b/test/jdk/com/sun/jdi/EATests.java @@ -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:+UseObjectMonitorTable - * @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:+UseObjectMonitorTable - * @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:+UseObjectMonitorTable - * @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:+UseObjectMonitorTable * * @run driver EATests * -XX:+UnlockDiagnosticVMOptions @@ -120,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:+UseObjectMonitorTable - * -XX:DiagnoseSyncOnValueBasedClasses=2 * * @comment Re-lock may inflate monitors when re-locking, which cause monitorinflation trace logging. * @run driver EATests diff --git a/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java b/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java index df09a0f9dbb95..6260c8e9bda09 100644 --- a/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java +++ b/test/jdk/java/lang/Thread/virtual/CarrierThreadInfo.java @@ -31,23 +31,6 @@ * @run junit CarrierThreadInfo */ -/** - * @test id=table - * @requires vm.continuations - * @modules java.base/java.lang:+open - * @library /test/lib - * @run junit/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UseObjectMonitorTable CarrierThreadInfo - */ - -/** - * @test id=monitor - * @requires vm.debug - * @requires vm.continuations - * @modules java.base/java.lang:+open - * @library /test/lib - * @run junit/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UseHeavyMonitors CarrierThreadInfo - */ - import java.lang.management.LockInfo; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; diff --git a/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java b/test/jdk/java/util/concurrent/ConcurrentHashMap/MapLoops.java index eacfaeb07854d..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:+UseHeavyMonitors -XX:+VerifyHeavyMonitors MapLoops - */ - import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.List; diff --git a/test/jdk/jdk/internal/vm/Continuation/Fuzz.java b/test/jdk/jdk/internal/vm/Continuation/Fuzz.java index 85c5ff66366e0..5f4f8c85f61cd 100644 --- a/test/jdk/jdk/internal/vm/Continuation/Fuzz.java +++ b/test/jdk/jdk/internal/vm/Continuation/Fuzz.java @@ -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,10 +1033,4 @@ int com_mny(int depth, return log((int)res); } - - static boolean legacyLockingMode() { - // return ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class) - // .getVMOption("LockingMode").getValue().equals("1"); - return false; - } } diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 6dfd877200450..c82ae1c1e7301 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -421,10 +421,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()) && - vmUseHeavyMonitors().equals("true")) { + lightweightLocking == false) { isRTMCompiler = true; } return "" + isRTMCompiler; @@ -530,13 +531,6 @@ protected String vmPageSize() { return "" + WB.getVMPageSize(); } - /** - * @return UseHeavyMonitors. - */ - protected String vmUseHeavyMonitors() { - return "" + WB.getBooleanVMFlag("UseHeavyMonitors"); - } - /** * Check if Graal is used as JIT compiler. *