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
8276824: refactor Thread::is_JavaThread_protected #6315
Conversation
|
/label add hotspot-runtime |
@dcubed-ojdk |
@coleenp, @dholmes-ora and @robehn - since the three of you were involved in the Advantages to this version (from my POV):
Disadvantages to this version (from my POV):
@dholmes-ora says that materializing current_thread is no longer as expensive as |
Webrevs
|
Thank you for this refactoring. A small suggestion, we'll see if it's popular or not.
src/hotspot/share/runtime/thread.cpp
Outdated
// Is the target JavaThread protected by a ThreadsListHandle (TLH) associated | ||
// with the calling Thread? | ||
// | ||
bool Thread::is_JavaThread_protected_by_TLH(const JavaThread* p) { |
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.
I think you could pass JavaThread* current as the first parameter here. The naming will help to keep it straight and make this an assert(current == JavaThread::current() if this is deemed to be expensive.
At the callsites below, it would make it obvious that "this" isn't meant to be the current thread (and calling Thread::current() inside a (tbd) assert would make it clear which thread is which.
With this handshake code I continuously am trying to figure out which thread is current vs. target.
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.
I'm not fond of passing the current thread in as a parameter because that could
make folks think that these functions can be called on any Thread*
. They must
be called in the context of the current thread which is also why they are static.
I would like to rename the p
parameter to target
and I could add /*target*/
to the call sites to make things more clear.
@dcubed-ojdk This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
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 23 new commits pushed to the
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.
|
I've pushed changes to clarify the target thread parameter. |
@robehn - are you okay with the comment updates? |
Hi Dan,
I'm okay with the changes as-is but also would not object to passing the current thread to avoid manifesting it - we do that a lot in other parts of the VM.
One (multi-place) nit below.
Thanks,
David
@@ -1750,13 +1761,13 @@ void JavaThread::send_thread_stop(oop java_throwable) { | |||
// - Target thread will not enter any new monitors. | |||
// | |||
bool JavaThread::java_suspend() { | |||
guarantee(Thread::is_JavaThread_protected(this, /* checkTLHOnly */ true), | |||
guarantee(Thread::is_JavaThread_protected_by_TLH(/* target */ this), |
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.
Nit: there's no need to comment a single argument.
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.
I added the comment due to this comment from @coleenp:
At the callsites below, it would make it obvious that "this" isn't meant to be the current thread (and calling Thread::current() inside a (tbd) assert would make it clear which thread is which.
I read @coleenp's comment as meaning that the uncommented this
could be made more
obvious so I'm going to leave those two /* target */
comments for clarity.
@dholmes-ora - Thanks for re-review! I think we're good to go on this cleanup. /integrate |
Going to push as commit 176d21d.
Your commit was automatically rebased without conflicts. |
@dcubed-ojdk Pushed as commit 176d21d. |
Refactor
Thread::is_JavaThread_protected(const JavaThread* p, bool checkTLHOnly)
into:
bool Thread::is_JavaThread_protected(const JavaThread* p)
and:
Thread::is_JavaThread_protected_by_TLH(const JavaThread* p)
.Also change callers that passed
checkTLHOnly == true
into calls toThread::is_JavaThread_protected_by_TLH(const JavaThread* p)
.This refactoring is being tested with Mach5 Tier[1-3] (in process).
In the "Files changed" view, enable "Settings -> Hide whitespace" for an easier review.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6315/head:pull/6315
$ git checkout pull/6315
Update a local copy of the PR:
$ git checkout pull/6315
$ git pull https://git.openjdk.java.net/jdk pull/6315/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6315
View PR using the GUI difftool:
$ git pr show -t 6315
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6315.diff