-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8329597: C2: Intrinsify Reference.clear #20139
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
8329597: C2: Intrinsify Reference.clear #20139
Conversation
On Mac AArch64, which suffers from both native call and WX transition:
On x86_64 m7a.16xlarge, which only suffers from the native call:
|
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
@shipilev 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:
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 103 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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
The reason we did not do this before is that this is not a strong reference store. Strong reference stores with a SATB collector will keep the referent alive, which is typically the exact opposite of what a user wants when they clear a Reference. |
You mean not doing this store just on the Java side? Yes, I agree, it would be awkward. In intrinsic, we are storing with the same decorators that |
The runtime use of the Access API knows how to resolve an unknown oop ref strength using AccessBarrierSupport::resolve_unknown_oop_ref_strength. However, we do not have support for that in the C2 backend. In fact, it does not understand non-strong oop stores at all. Because there hasn't really been a use case for it, other than clearing a Reference. That's the precise reason why we do not have a clear intrinsic; it would have to add that infrastructure. |
Aw, nice usability landmine. I thought C2 barrier set would assert on me if it cannot deliver. Apparently not, I see it just does pre-barriers when it is not sure what strongness the store is. Hrmpf. OK, let me see what can be done here. It might be just easier to further specialize |
Reference.refersTo has similar issues. See refersToImpl and refersTo0 in both Reference and PhantomReference. One additional complication is that Reference.enqueue intentionally calls clear0. If implementing clear similarly |
I should have read what I was replying to more carefully, rather than focusing on what was further up in the thread. |
fecf4af
to
ba820da
Compare
Yeah, thanks. The Pushed the crude prototype that follows |
Split out the |
Yeah, so this version seems to work well on tests. I am being extra paranoid about only accepting I think this is sanely insane, given how sharp-edged |
Tests pass with the new change. I eyeballed G1 perfasm output on new benchmark, and there are no barriers in sight as well. |
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.
One last thing...
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.
Looks good.
Thanks! I see Kim reviewed JDK parts, so we need another Reviewer for Hotspot parts. |
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.
C2 change (intrinsics code) is fine.
Thanks for review, folks. I am re-running testing locally here. Would appreciate if you can give this patch a spin through your CIs as well. |
I will run some internal CI testing and report back in one or two days. |
The test results look good. I tested the changes (up to commit 9f7ad7a) on top of jdk-24+19 running tier1-tier5 on all Oracle-supported platforms. |
Thank you for testing! Here goes. /integrate |
Going to push as commit 7625b29.
Your commit was automatically rebased without conflicts. |
JDK-8240696 added the native method for
Reference.clear
. The original patch skipped intrinsification of this method, because we thoughtReference.clear
is not on a performance sensitive path. However, it shows up prominently on simple benchmarks that touch e.g.ThreadLocal
cleanups. See the bug for an example profile withRRWL
benchmarks.We need to know the actual oop strongness/weakness before we call into C2 Access API, this work models this after existing code for
refersTo0
intrinsics. C2 Access also need a support forAS_NO_KEEPALIVE
for stores.Additional testing:
all
all
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20139/head:pull/20139
$ git checkout pull/20139
Update a local copy of the PR:
$ git checkout pull/20139
$ git pull https://git.openjdk.org/jdk.git pull/20139/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20139
View PR using the GUI difftool:
$ git pr show -t 20139
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20139.diff
Webrev
Link to Webrev Comment