Skip to content

Conversation

@fbredber
Copy link
Contributor

@fbredber fbredber commented Oct 21, 2025

This is the last PR in a series of PRs (see: JDK-8344261) to obsolete the LockingMode flag and related code.

The main focus is to to unify ObjectSynchronizer and LightweightSynchronizer.
There used to be a number of "dispatch functions" to redirect calls depending on the setting of the LockingMode flag.
Since we now only have lightweight locking, there is no longer any need for those dispatch functions, so I removed them.
To remove the dispatch functions I renamed the corresponding lightweight functions and call them directly.
This ultimately led me to remove "lightweight" from the function names and go back to "fast" instead, just to avoid having some with, and some without the "lightweight" part of the name.

This PR also include a small simplification of ObjectSynchronizer::FastHashCode.

Tested tier1-7 (on supported platforms) without seeing any problems that can be traced to this code change.
All other platforms (arm, ppc, riscv, s390) has been sanity checked using QEMU.


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-8367982: Unify ObjectSynchronizer and LightweightSynchronizer (Sub-task - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27915

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 21, 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 Oct 21, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Oct 21, 2025
@openjdk
Copy link

openjdk bot commented Oct 21, 2025

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

  • hotspot
  • serviceability

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.

@fbredber fbredber marked this pull request as ready for review October 23, 2025 08:32
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 23, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 23, 2025

Webrevs

@fbredber
Copy link
Contributor Author

@bulasevich, @TheRealMDoerr, @RealFYang, @offamitkumar
Hi guys!
This is the last PR in a series of PRs to obsolete the LockingMode flag and related code.
So please please grab a copy, run it on your favorite platform, and tell me if there's anything wrong with it.
Thanks in advance.

@TheRealMDoerr
Copy link
Contributor

Thanks for cleaning this up on all platforms! Works on PPC64.
Indentation could be improved at many places where the next line was aligned (all platforms and shared code).

Copy link
Contributor

@pchilano pchilano left a comment

Choose a reason for hiding this comment

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

Thanks for doing this cleanup. I only found some instances in comments where lightweight referred to the locking mode and not just the fast path, so the word should be removed rather than replaced with fast.

// stability and then install the hash.
} else if (mark.has_monitor()) {
} else {
assert(!mark.is_unlocked() && !mark.is_fast_locked(), "invariant");
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that mark.monitor() below already asserts mark.has_monitor() which is stronger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, but I still like to keep the assert() on 648 for clarity. Would you rather see it removed?

@RealFYang
Copy link
Member

@bulasevich, @TheRealMDoerr, @RealFYang, @offamitkumar Hi guys! This is the last PR in a series of PRs to obsolete the LockingMode flag and related code. So please please grab a copy, run it on your favorite platform, and tell me if there's anything wrong with it. Thanks in advance.

Hello, A simple tier1 test is good on linux-riscv64. I checked the riscv part and I only see in indentation issues as pointed out by @TheRealMDoerr.

@offamitkumar
Copy link
Member

@bulasevich, @TheRealMDoerr, @RealFYang, @offamitkumar Hi guys! This is the last PR in a series of PRs to obsolete the LockingMode flag and related code. So please please grab a copy, run it on your favorite platform, and tell me if there's anything wrong with it. Thanks in advance.

Hi, I ran tier1 and seems like on s390 everything is good.

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.

Never say "last" cleanup. The renaming to remove "lightweight" looks good. I wasn't sure if we wanted to keep that name or not. There's a lightweight NMT coming so this won't be confused with that anymore. I guess that's good.


// -----------------------------------------------------------------------------
// ConcurrentHashTable storing links from objects to ObjectMonitors
class ObjectMonitorTable : AllStatic {
Copy link
Contributor

@coleenp coleenp Oct 24, 2025

Choose a reason for hiding this comment

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

I guess after looking at this, it made sense to combine the lightweightSynchronizer code into synchronizer.cpp (should be ObjectSynchronizer.hpp/cpp). I wonder if the OM table code could be split out into its own file objectMontitorTable.hpp/cpp. I feel like synchronzer.hpp/cpp again does too many different things.

Copy link
Contributor Author

@fbredber fbredber Oct 24, 2025

Choose a reason for hiding this comment

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

Since we are currently investigating the OM table elseware (see: JDK-8365493) I wote for not doing any OM table refactoring in this PR.

return read_monitor(mark);
} else {
return LightweightSynchronizer::get_monitor_from_table(current, obj);
return ObjectSynchronizer::get_monitor_from_table(current, obj);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's a need for this file anymore. read_monitor is mostly called inside synchronizer.cpp, so it can be inlined there.

Copy link
Contributor Author

@fbredber fbredber Oct 24, 2025

Choose a reason for hiding this comment

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

Would you want me to do that in this PR? Or should I create a new RFE for that, just to acknowledge the fact that one should never say "last" cleanup. :)

@bulasevich
Copy link
Contributor

run it on your favorite platform, and tell me if there's anything wrong with it. Thanks in advance.

Hi, tier1 runs clean on ARM32. Thanks!

@fbredber
Copy link
Contributor Author

@TheRealMDoerr, @RealFYang

Indentation could be improved at many places where the next line was aligned (all platforms and shared code).

Oops, my bad. Guess this what you end up with when you use bash, grep -r and sed to seek out and remove "lightweight" from a source tree, and then check the result using old Un*x style diff -w. I think all the faulty indentation stuff is fixed now, and yes I did check with "new" style git diff to see the surrounding lines.

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

Labels

hotspot hotspot-dev@openjdk.org rfr Pull request is ready for review serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

7 participants