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
8252406: Introduce Thread::as_Java_thread() convenience function #37
Conversation
|
@dholmes-ora The following labels will be automatically applied to this pull request: 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 |
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.
Drive-by comment: Shenandoah changes look good.
Thanks @shipilev ! Sending this out for RFR now. |
Webrevs
|
Mailing list message from Kim Barrett on shenandoah-dev: ------------------------------------------------------------------------------ This should be using a static_cast. However, making that change will This definition cannot correctly be located here. It must follow the (The definition can remain in this file if that's more (One of the very real dangers with C-style casts is that you might not ------------------------------------------------------------------------------ This should be const JavaThread* as_Java_Thread() const { And of course, moved after the definition of JavaThread, per the above ------------------------------------------------------------------------------ I reviewed all the (non-Shenandoah) gc changes, and they look good. |
Mailing list message from David Holmes on shenandoah-dev: Hi Kim, Thanks for taking a look. On 8/09/2020 9:23 am, Kim Barrett wrote:
I did try to do the right thing with static_cast and of course
Okay I will look at what is involved in putting it in the .inline.hpp
Will fix.
Thanks for the review and coding tips! Cheers, |
Moved inline functions to thread.inline.hpp Updated #includes to deal with the move to thread.inline.hpp Updated copyright year where needed.
The fanout for this change is now quite large.
Mailing list message from Kim Barrett on shenandoah-dev: ------------------------------------------------------------------------------ This missed part of what I'd suggested. I don't think the "const" part There are some situations where there is such an overload pair and it ------------------------------------------------------------------------------ The fannout from putting the conversion functions in thread.inline.hpp seems ------------------------------------------------------------------------------ |
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.
Shenandoah parts still look good. Formally approving.
@dholmes-ora This change now passes all automated pre-integration checks. In addition to the automated checks, the change must also fulfill all project specific requirements After integration, the commit message will be:
Since the source branch of this PR was last updated there have been 44 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 automatic rebasing, please merge
|
Mailing list message from David Holmes on shenandoah-dev: On 8/09/2020 4:34 pm, Kim Barrett wrote:
I saw that but thought it was a typo as I don't think about overloads in But in addition I wanted to have this say as_const_JavaThread because I
I tried to do the right and obey the "use .inline.hpp for inline Thanks,
|
This reverts commit da70f80. Reverting v3 and v2 so that we can take a simpler approach that touches far fewer files.
Mailing list message from Kim Barrett on shenandoah-dev:
Intentional, not a typo.
That's correct, the function's const qualifier or lack thereof provides
I think those cases are just jfr being better than typical HotSpot code
I don't think there is such a rule, but that's a deep discussion that goes |
Mailing list message from David Holmes on shenandoah-dev: Just to be clear please wait for v5 to appear before reviewing. Thanks, On 8/09/2020 7:34 pm, David Holmes wrote: |
- Change C-style cast to static_cast and move function definitions so this works. - Use overloading for const and non-const versions of as_Java_thread(). - Update copyright years. Re-testing builds in tiers 1-5. Thanks.
I'll look at v5 diffs but if I don't, this is still reviewed. Nice cleanup. |
Mailing list message from David Holmes on shenandoah-dev: Thanks for the review Coleen! David On 9/09/2020 5:10 am, Coleen Phillimore wrote: |
Mailing list message from Kim Barrett on shenandoah-dev:
I think you meant ?v4?, i.e. the 5th zero-based version? |
Mailing list message from Kim Barrett on shenandoah-dev: I reviewed all of v4, not just the gc parts this time. ------------------------------------------------------------------------------ The block from line 1646-1655 seems to be misindented. And was before too. ------------------------------------------------------------------------------ This was an intentional redundancy with the following JavaThread::current(), [Sorry about missing this on my first pass through.] ------------------------------------------------------------------------------ This change looks suspicious. The old code used Thread::current() here and (At least locally; there could be things being called in the !is_hotspot() It also looks like the THREAD variable could be eliminated and it's one use ------------------------------------------------------------------------------ It's not obvious why this assert is being removed. ------------------------------------------------------------------------------ 63 #define assert_Java_thread() \ => 63 void ConcurrentGCBreakpoints::run_to_idle_impl(bool acquiring_control) { and related later changes in this file. I prefer the original code, which intentionally made the precondition check [Sorry about missing this on my first pass through.] ------------------------------------------------------------------------------ The only use of Self could just be THREAD, which is also used in this Hm, there are other functions in this file that have a peculiar mix of Cleaning that up should probably be a separate task; this changeset is ------------------------------------------------------------------------------ Indentation got messed up. ------------------------------------------------------------------------------ It seems like there are some places where if a function parameter were ------------------------------------------------------------------------------ |
Mailing list message from Kim Barrett on shenandoah-dev:
I guess it was v5 I was reviewing. There seems to be an inconsistency in numbering. |
Mailing list message from David Holmes on shenandoah-dev: Hi Kim, On 9/09/2020 1:30 pm, Kim Barrett wrote:
Thank you. Note that I've been using the version as given in the email subject
Fixed.
Reverted.
Yes - if you look at JNIAccessMark it manifests JavaThread::current() by
Or I can keep it and also use it for the JNIAccessMark constructor.
The fact THREAD must be a JavaThread is already established by the
The same precondition is already present in the use of
Right, I tried to avoid the temptation of dealing with the https://bugs.openjdk.java.net/browse/JDK-8252685
Fixed. (I must remember to try the emacs fix to handle the JVM_ENTRY and
Yep - that same RFE: https://bugs.openjdk.java.net/browse/JDK-8252685 Thanks,
|
Mailing list message from Kim Barrett on shenandoah-dev: Hi David. Thanks for clarifying some bits I was confused abut.
I see; good.
Right. I keep forgetting which of these macros does what with which kinds of threads.
I'm not that concerned by a little redundant work in a debug build. I think
Good. |
Mailing list message from David Holmes on shenandoah-dev: Trimming ... On 9/09/2020 7:09 pm, Kim Barrett wrote:
I personally think that the use of JavaThread::current() makes a clear Thanks,
|
This is a really nice set of cleanup changes. I have a few comments. https://openjdk.github.io/cr/?repo=jdk&pr=37&range=06#frames-33 Note: I included the link the webrev had me on, but I have no idea what https://openjdk.github.io/cr/?repo=jdk&pr=37&range=06#frames-80 276 guarantee(current == get_thread() || current == get_thread()->active_handshaker(),
https://openjdk.github.io/cr/?repo=jdk&pr=37&range=06#frames-101 358 this->as_Java_thread()->set_stack_overflow_limit(); https://openjdk.github.io/cr/?repo=jdk&pr=37&range=06#frames-107 old code: new code: If the calling thread is not a JavaThread and passes a thread_id ==0, The craziness in the JavaThread::pd_get_top_frame() functions made my head hurt. |
/reviewer add dcubed_ojdk |
@dcubed-ojdk Only the author (@dholmes-ora) is allowed to issue the |
I don't see how to add myself as a reviewer... what am I missing? |
…t restored but not commited, then a later rollback to v1 lost the fix. Minor issues Dan spotted now fixed.
Mailing list message from David Holmes on shenandoah-dev: Hi Dan, Thanks for looking at this one. On 10/09/2020 9:26 am, Daniel D.Daugherty wrote:
Yes will add braces. So glad you picked on this though as I messed up one of my commits and return true; //something like this: thread->is_VM_thread(); so I tried: return thread->is_VM_thread(); but it causes the assertion to fail as GC threads also execute this. So
Yeah those links are pretty obscure, and even the webrev frames view it
It was wrong - fixed.
Nope. Fixed.
This code is in a JVM_ENTRY - so both THREAD and thread refer to
Thanks again for the review. v8 will be appearing shortly. David |
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.
Incremental looks good to me.
/integrate |
@dholmes-ora Since your change was applied there have been 44 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 976acdd. |
This is a rather large but generally simple cleanup.
We use a lot of raw C-style casts to "(JavaThread*)" typically after checking "thread->is_Java_thread()". To simplify this pattern, and make the code look somewhat cleaner we introduce a convenience function Thread::as_Java_thread(), which asserts is_Java_thread() and returns "this" cast to "JavaThread*". A const version, as_const_Java_thread(), was also added to allow use in cases where we start with "const Thread *".
Summary of changes:
the only way the assert can fire is if someone deliberately bypasses the type system, and if we are going to worry about that then we would need asserts like this on every method that expects a JavaThread! The right place for the assertion is at the head of any such call chain.
Change locations found by grepping for variations of the cast syntax "(JavaThread*)" - it is possible some may have been missed.
Testing: tiers 1-3
Thanks,
David
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/37/head:pull/37
$ git checkout pull/37