Skip to content

Commit 5039b42

Browse files
toxaartFredrik Bredberg
authored andcommitted
8359437: Make users and test suite not able to set LockingMode flag
8358542: Remove RTM test VMProps Co-authored-by: Fredrik Bredberg <[email protected]> Reviewed-by: coleenp, lmesnik, fbredberg, alanb, dholmes
1 parent 1ca008f commit 5039b42

34 files changed

+110
-1130
lines changed

src/hotspot/share/prims/whitebox.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#include "runtime/javaCalls.hpp"
8686
#include "runtime/javaThread.inline.hpp"
8787
#include "runtime/jniHandles.inline.hpp"
88+
#include "runtime/lightweightSynchronizer.hpp"
8889
#include "runtime/lockStack.hpp"
8990
#include "runtime/os.hpp"
9091
#include "runtime/stackFrameStream.inline.hpp"

src/hotspot/share/runtime/arguments.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,15 +1836,6 @@ bool Arguments::check_vm_args_consistency() {
18361836
}
18371837
#endif
18381838

1839-
#ifndef _LP64
1840-
if (LockingMode == LM_LEGACY) {
1841-
FLAG_SET_CMDLINE(LockingMode, LM_LIGHTWEIGHT);
1842-
// Self-forwarding in bit 3 of the mark-word conflicts
1843-
// with 4-byte-aligned stack-locks.
1844-
warning("Legacy locking not supported on this platform");
1845-
}
1846-
#endif
1847-
18481839
if (UseObjectMonitorTable && LockingMode != LM_LIGHTWEIGHT) {
18491840
// ObjectMonitorTable requires lightweight locking.
18501841
FLAG_SET_CMDLINE(UseObjectMonitorTable, false);
@@ -3770,9 +3761,6 @@ void Arguments::set_compact_headers_flags() {
37703761
FLAG_SET_DEFAULT(UseObjectMonitorTable, true);
37713762
}
37723763
}
3773-
if (UseCompactObjectHeaders && LockingMode != LM_LIGHTWEIGHT) {
3774-
FLAG_SET_DEFAULT(LockingMode, LM_LIGHTWEIGHT);
3775-
}
37763764
if (UseCompactObjectHeaders && !UseCompressedClassPointers) {
37773765
FLAG_SET_DEFAULT(UseCompressedClassPointers, true);
37783766
}

src/hotspot/share/runtime/globals.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,13 +1957,6 @@ const int ObjectAlignmentInBytes = 8;
19571957
"Mark all threads after a safepoint, and clear on a modify " \
19581958
"fence. Add cleanliness checks.") \
19591959
\
1960-
product(int, LockingMode, LM_LIGHTWEIGHT, \
1961-
"(Deprecated) Select locking mode: " \
1962-
"0: (Deprecated) monitors only (LM_MONITOR), " \
1963-
"1: (Deprecated) monitors & legacy stack-locking (LM_LEGACY), " \
1964-
"2: monitors & new lightweight locking (LM_LIGHTWEIGHT, default)") \
1965-
range(0, 2) \
1966-
\
19671960
product(bool, UseObjectMonitorTable, false, DIAGNOSTIC, \
19681961
"With Lightweight Locking mode, use a table to record inflated " \
19691962
"monitors rather than the first word of the object.") \

src/hotspot/share/utilities/globalDefinitions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ int LogMinObjAlignmentInBytes = -1;
5656
// Oop encoding heap max
5757
uint64_t OopEncodingHeapMax = 0;
5858

59+
const int LockingMode = LM_LIGHTWEIGHT;
60+
5961
// Something to help porters sleep at night
6062

6163
#ifdef ASSERT

src/hotspot/share/utilities/globalDefinitions.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,8 @@ enum LockingMode {
10091009
LM_LIGHTWEIGHT = 2
10101010
};
10111011

1012+
extern const int LockingMode;
1013+
10121014
//----------------------------------------------------------------------------------------------------
10131015
// Special constants for debugging
10141016

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/LockingMode.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,18 @@ private JavaThread owningThreadFromMonitor(Address o) {
222222

223223
public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) {
224224
if (monitor.isOwnedAnonymous()) {
225-
if (VM.getVM().getCommandLineFlag("LockingMode").getInt() == LockingMode.getLightweight()) {
226-
OopHandle object = monitor.object();
227-
for (int i = 0; i < getNumberOfThreads(); i++) {
228-
JavaThread thread = getJavaThreadAt(i);
229-
if (thread.isLockOwned(object)) {
230-
return thread;
231-
}
232-
}
233-
// We should have found the owner, however, as the VM could be in any state, including the middle
234-
// of performing GC, it is not always possible to do so. Just return null if we can't locate it.
235-
System.out.println("Warning: We failed to find a thread that owns an anonymous lock. This is likely");
236-
System.out.println("due to the JVM currently running a GC. Locking information may not be accurate.");
237-
return null;
238-
} else {
239-
assert(VM.getVM().getCommandLineFlag("LockingMode").getInt() == LockingMode.getLegacy());
240-
Address o = (Address)monitor.stackLocker();
241-
for (int i = 0; i < getNumberOfThreads(); i++) {
242-
JavaThread thread = getJavaThreadAt(i);
243-
if (thread.isLockOwned(o))
244-
return thread;
245-
}
246-
return null;
225+
OopHandle object = monitor.object();
226+
for (int i = 0; i < getNumberOfThreads(); i++) {
227+
JavaThread thread = getJavaThreadAt(i);
228+
if (thread.isLockOwned(object)) {
229+
return thread;
230+
}
247231
}
232+
// We should have found the owner, however, as the VM could be in any state, including the middle
233+
// of performing GC, it is not always possible to do so. Just return null if we can't locate it.
234+
System.out.println("Warning: We failed to find a thread that owns an anonymous lock. This is likely");
235+
System.out.println("due to the JVM currently running a GC. Locking information may not be accurate.");
236+
return null;
248237
} else {
249238
return owningThreadFromMonitor(monitor.owner());
250239
}

test/hotspot/jtreg/ProblemList-StaticJdk.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ serviceability/sa/ClhsdbPstack.java#core 8346719 generic-all
3737
gtest/GTestWrapper.java 8356201 generic-all
3838
gtest/LargePageGtests.java#use-large-pages 8356201 generic-all
3939
gtest/LargePageGtests.java#use-large-pages-1G 8356201 generic-all
40-
gtest/LockStackGtests.java 8356201 generic-all
4140
gtest/MetaspaceGtests.java#no-ccs 8356201 generic-all
4241
gtest/NMTGtests.java#nmt-detail 8356201 generic-all
4342
gtest/NMTGtests.java#nmt-off 8356201 generic-all

test/hotspot/jtreg/TEST.groups

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ tier1_common = \
142142
sources \
143143
sanity/BasicVMTest.java \
144144
gtest/GTestWrapper.java \
145-
gtest/LockStackGtests.java \
146145
gtest/MetaspaceGtests.java \
147146
gtest/LargePageGtests.java \
148147
gtest/NMTGtests.java \

test/hotspot/jtreg/compiler/locks/TestSynchronizeWithEmptyBlock.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,9 +26,6 @@
2626
* @bug 8337660
2727
* @summary Test that C2 does not remove blocks with BoxLock nodes that are
2828
* otherwise empty.
29-
* @run main/othervm -Xbatch -XX:LockingMode=1
30-
* -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::*
31-
* compiler.locks.TestSynchronizeWithEmptyBlock
3229
* @run main/othervm -Xbatch
3330
* -XX:CompileOnly=compiler.locks.TestSynchronizeWithEmptyBlock::*
3431
* compiler.locks.TestSynchronizeWithEmptyBlock

test/hotspot/jtreg/gtest/LockStackGtests.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/hotspot/jtreg/runtime/Monitor/ConcurrentDeflation.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
2424
import jdk.test.lib.process.OutputAnalyzer;
2525
import jdk.test.lib.Platform;
2626
import jdk.test.lib.process.ProcessTools;
27+
import jdk.test.whitebox.WhiteBox;
2728

2829
import java.lang.management.ManagementFactory;
2930
import java.lang.management.ThreadInfo;
@@ -34,10 +35,13 @@
3435
* @bug 8318757
3536
* @summary Test concurrent monitor deflation by MonitorDeflationThread and thread dumping
3637
* @library /test/lib
37-
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:GuaranteedAsyncDeflationInterval=2000 -XX:LockingMode=0 ConcurrentDeflation
38+
* @build jdk.test.whitebox.WhiteBox
39+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
40+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:GuaranteedAsyncDeflationInterval=2000 -XX:+WhiteBoxAPI ConcurrentDeflation
3841
*/
3942

4043
public class ConcurrentDeflation {
44+
static final WhiteBox WB = WhiteBox.getWhiteBox();
4145
public static final long TOTAL_RUN_TIME_NS = 10_000_000_000L;
4246
public static Object[] monitors = new Object[1000];
4347
public static int monitorCount;
@@ -73,6 +77,12 @@ static private void createMonitors() {
7377
index = index++ % 1000;
7478
monitors[index] = new Object();
7579
synchronized (monitors[index]) {
80+
try {
81+
// Force inflation
82+
monitors[index].wait(1);
83+
} catch (InterruptedException e) {
84+
throw new RuntimeException(e);
85+
}
7686
monitorCount++;
7787
}
7888
}

0 commit comments

Comments
 (0)