Skip to content

Conversation

fbredber
Copy link
Contributor

@fbredber fbredber commented Sep 2, 2025

Since the integration of JDK-8359437 the LockingMode flag can no longer be set by the user. After that, a number of PRs has been integrated which has removed all LockingMode related code from all platforms (except from zero, which is done in this PR).

This PR removes LockingMode related code from the shared (non-platform specific) files. It also removes the LockingMode variable itself.

Passes tier1-tier5 with no added problems.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8365190: Remove LockingMode related code from share (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27041/head:pull/27041
$ git checkout pull/27041

Update a local copy of the PR:
$ git checkout pull/27041
$ git pull https://git.openjdk.org/jdk.git pull/27041/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27041

View PR using the GUI difftool:
$ git pr show -t 27041

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27041.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 2, 2025

👋 Welcome back fbredberg! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 2, 2025

@fbredber This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8365190: Remove LockingMode related code from share

Reviewed-by: ayang

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 21 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Sep 2, 2025

@fbredber The following labels will be automatically applied to this pull request:

  • graal
  • hotspot
  • serviceability
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Sep 2, 2025

Webrevs

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 2, 2025
@@ -1669,7 +1669,7 @@ bool PhaseIterGVN::verify_Ideal_for(Node* n, bool can_reshape) {
//
// Found (linux x64 only?) with:
// serviceability/sa/ClhsdbThreadContext.java
// -XX:+UnlockExperimentalVMOptions -XX:LockingMode=1 -XX:+IgnoreUnrecognizedVMOptions -XX:VerifyIterativeGVN=1110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For traceability, I suggest leaving this line untouched and adding a comment in the next line clarifying that -XX:LockingMode is not available anymore.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and suggestions for your next RFE.

@@ -341,7 +341,6 @@
volatile_nonstatic_field(ObjectMonitor, _recursions, intptr_t) \
volatile_nonstatic_field(ObjectMonitor, _entry_list, ObjectWaiter*) \
volatile_nonstatic_field(ObjectMonitor, _succ, int64_t) \
volatile_nonstatic_field(ObjectMonitor, _stack_locker, BasicLock*) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some jvmci tests that check that the java side of jvmci matches, ie:

make test TEST=compiler/jvmci

void set_bad_metadata_deopt() { set_metadata(badDispHeaderDeopt); }

// LM_LEGACY
inline markWord displaced_header() const;
inline void set_displaced_header(markWord header);
static int displaced_header_offset_in_bytes() { return metadata_offset_in_bytes(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also delete line 51 ?

assert(_held_monitor_count >= _jni_monitor_count || is_exiting(), "Monitor count discrepancy detected - held count "
"%zd is less than JNI count %zd", _held_monitor_count, _jni_monitor_count);
// Nothing to do. Just do some sanity check.
assert(_held_monitor_count == 0, "counter should not be used");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In further cleanup, can we now remove _held_monitor_count next?

// an inflated ObjectMonitor* for a monitor, and expects to throw a
// java.lang.IllegalMonitorStateException if it is not held by the current
// thread. Such as notify/wait and jni_exit. LM_LIGHTWEIGHT keeps it invariant
// ObjectMonitor* when lightweight locking is used. It is used from contexts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you don't need the phrase "when lightweight locking is used".

// that the locking_thread == Thread::current() or is suspended throughout the call by
// some other mechanism.
// Even with LM_LIGHTWEIGHT the thread might be nullptr when called from a non
// The JavaThread* locking_thread parameter is only used by lightweight locking and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. suggestion:

// The JavaThread* locking parameter requires that the locking_thread == JavaThread::current, or is suspended
// throughout the call by some other mechanism.

// dropped by the calling thread.
monitor = inflate(current, obj(), inflate_cause_notify);
}
monitor = LightweightSynchronizer::inflate_locked_or_imse(obj(), inflate_cause_notify, CHECK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare and initialize on the same line:

ObjectMonitor* monitor = LightwightSynchronizer::inflate_locked_or_imse(obj...);

// dropped by the calling thread.
monitor = inflate(current, obj(), inflate_cause_notify);
}
monitor = LightweightSynchronizer::inflate_locked_or_imse(obj(), inflate_cause_notify, CHECK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here with
ObjectMonitor* monitor = LIght ...

I think we should have another RFE to look at eliminating the middle call. Call these in LIghtweightSynchronizer::notify, notifyAll and waitInterruptably directly and remove these functions.

@@ -45,11 +45,7 @@ inline ObjectMonitor* ObjectSynchronizer::read_monitor(Thread* current, oop obj,
inline void ObjectSynchronizer::enter(Handle obj, BasicLock* lock, JavaThread* current) {
assert(current == Thread::current(), "must be");

if (LockingMode == LM_LIGHTWEIGHT) {
LightweightSynchronizer::enter(obj, lock, current);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the further RFE, we should remove these dispatch functions too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants