-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8362239: Reconcile enter_internal and reenter_internal in the ObjectMonitor code #26858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
8362239: Reconcile enter_internal and reenter_internal in the ObjectMonitor code #26858
Conversation
👋 Welcome back toxaart! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
54f64a0
to
8a0d56b
Compare
8a0d56b
to
bcea486
Compare
@@ -1935,7 +1900,7 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { | |||
enter(current); | |||
} else { | |||
guarantee(v == ObjectWaiter::TS_ENTER, "invariant"); | |||
reenter_internal(current, &node); | |||
enter_internal(current, &node, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enter_internal(current, &node, true); | |
enter_internal(current, &node, true /* do_reenter */); |
// As an aside, if were to ever rewrite the synchronization code mostly | ||
// in Java, WaitNodes, ObjectMonitors, and Events would become 1st-class | ||
// Java objects. This would avoid awkward lifecycle and liveness issues, | ||
// as well as eliminate a subset of ABA issues. | ||
// TODO: eliminate ObjectWaiter and enqueue either Threads or Events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side issue: I think this commentary can be removed now.
Please consider the following changes:
The two methods of the
ObjectMonitor
class, namelyenter_internal()
andreenter_internal()
, are reconciled. As a result,reenter_internal()
is removed, whereasenter_internal()
is modified.The modification affects the range of the code, where the thread is in the blocked state. Now, it is only a small part in the innermost loop of the method. However, suspension of the "contender" thread is not allowed on the initial entrance, as this can potentially lead to a deadlock: if the "contender" thread is suspended in the innermost loop, and the "resumer" thread is parked, no one will be making progress as the "resumer" thread cannot be woken up, as the "contender" thread has not yet exited the monitor to unpark the "resumer".
In this sense, the initial entrance to the monitor is considered to be atomic, i.e. it is either completed, or not done at all. This means it should not be interrupted by a suspension request. The re-entrance to the monitor, however, allows suspension, as the monitor has been already owned by a "contender" thread.
Tested in tiers 1-5.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26858/head:pull/26858
$ git checkout pull/26858
Update a local copy of the PR:
$ git checkout pull/26858
$ git pull https://git.openjdk.org/jdk.git pull/26858/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26858
View PR using the GUI difftool:
$ git pr show -t 26858
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26858.diff
Using Webrev
Link to Webrev Comment