-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8365047: Remove exception handler stub code in C2 #26678
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
Conversation
The C2 exception handler stub code is only a trampoline to the generated exception handler blob. This change removes the extra step on the way to the generated blob. According to some comments in the source code, the exception handler stub code used to be patched upon deoptimization, however presumably these comments are outdated as the patching upon deoptimization happens for post-call NOPs only.
|
👋 Welcome back ruben-arm! A progress list of the required criteria for merging this PR into |
|
@ruben-arm 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 38 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dean-long, @dafedafe, @adinn, @RealFYang, @TheRealMDoerr, @theRealAph) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
@ruben-arm The following label 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 list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
|
This looks good. How much testing have you done? Maybe we can get rid of CodeOffsets::DeoptMH next. |
dean-long
left a comment
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.
Test results from Oracle are good. You need one more review.
|
dafedafe
left a comment
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.
Thanks for "cleaning" this @ruben-arm.
Did you run some testing (on the touched platforms)?
I doubt that there is anything perceivable but, out of curiosity, did you notice any performance change?
|
Thank you for the reviews, @dean-long, @dafedafe,
I've run tier1-tier3 tests, however only on AArch64 and x86-64.
I've not measured performance impact of the patch separately. It is a part of a bigger effort to reduce memory footprint of compiled code. The cumulative effect from this and similar patches is expected to be a noticeable performance improvement, however I wouldn't expect a significant observable effect from this patch only. The decrease for C2-compiled code on AArch64 should be 4-12 bytes (depends on size of code cache) per nmethod, however the nmethod's alignment requirement might hide some of these improvements. I'm also exploring possibility to reduce footprint of the deoptimization handler stub codes.
I will look into this. I have a proof-of-concept patch reducing each deoptimization handler stub code to 1 instruction each on AArch64 - that instruction traps and the rest of the deoptimization handler logic continues in signal handler. However, I would agree it would be preferable to remove the stub code completely if possible. |
adinn
left a comment
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 ok to me.
|
Re: CodeOffsets::DeoptMH, what I meant is that it is just an exact copy of the CodeOffsets::Deopt stub code. Apparently at some point in the JSR 292 evolution, we needed to distinguish between the two, but it looks to me that we no longer need to do that. So we should be able to get rid of DeoptMH and related code, like nmethod::is_deopt_mh_entry(). |
As you've touched a few other platforms' files it might be a good idea (to be on the safe-side). |
|
Thanks for the feedback, I've updated the change.
To clarify my earlier comment: when I said "I can run more tests on these platforms if that might be useful.", I meant more testing on AArch64 and x86-64 only. I don't have any other platform available for testing. Does the testing infrastructure on the Github/CI provide a way to run the tests on other platforms by any chance? Otherwise, to stay on the safe side, I could revert the change for the platforms other than AArch64 and x86-64. Please let me know which path you prefer. |
Sorry, I misread your comment.
Not that I'm aware of but you could for instance ask port maintainers to run a few tiers for you: https://wiki.openjdk.org/display/HotSpot/Ports |
|
@TheRealMDoerr, @RealFYang, @offamitkumar, |
RealFYang
left a comment
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.
@ruben-arm : Thanks for the ping. Changes LGTM. Tier1-3 test good on linux-riscv64.
|
@ruben-arm I don't see any test failure on s390x in tier1. Code change looks good to me. CC: @RealLucy |
TheRealMDoerr
left a comment
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.
Tier 1 has passed on linux ppc64le. Nice cleanup!
|
Thank you for running the tests @TheRealMDoerr, @RealFYang, @offamitkumar. @dafedafe, could you approve if the patch looks good, please? (there have been no code changes since your last comment) |
dafedafe
left a comment
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 @ruben-arm!
Thank you @dafedafe. In the meantime, I realized the AArch32 tests weren't run during my testing earlier - and attempted running them. I found that many of the tests are failing without this patch. Nevertheless, I noticed that more tests are failing with this patch. I've just identified the root cause - described below. This issue is caused by the current version of the patch - at least for AArch32. Once the exception handler stub code is removed, the deoptimization handler stub code can become adjacent to the main code. Occasionally the main code ends with a Presumably, the most straightforward fix could be to emit a |
Wow, that's a bizarre bug. Maybe better might be to generate an illegal instruction rather than a nop but a nop would probably do. |
|
Re: SafeFetch, it is probably OK to make NativePostCallNop_at slightly slower for uses like make_deoptimized(), but the oopmap optimizations like CodeCache::find_blob_and_oopmap() were highly optimized to make loom/VirtualThread performance reasonable. Adding a SafeFetch here might cause a regression. |
Perhaps. I'm not sure it needs it, though.
No, but when we have stack corruption it's better that we don't crash while unwinding. All we're doing by using SafeFetch is adding a little robustness. We're not making things worse. [ As an aside, I believe we should use SafeFetch during unwinding a lot more than we do at present. A corrupted stack often results in a crash during printing a diagnostic trace, and it's good to catch such errors sooner than later. ]
Indeed so. One error would lead to another.
If you step through the stack unwinding code you will encounter calls
It's possible, but it's far more likely that we'll get a usable stack trace in a crash dump.
All of this is true, but you are almost implying that we shouldn't make this thing over here robust because there is this other thing over there that needs fixing too. I'm reminded of the Hubble Space Telescope. The testing error that led to the focussing problem was so gross - about a millimetre - that it could have been detected with a school ruler. It wasn't measured, perhaps because the tolerances to which it was supposed to have been built were much tighter than that.
It may not be possible. Post-call NOPS exist only to make stack unwinding as fast as possible, and if I recall correctly there's already a debug-mode consistency check. |
|
But I'm not going to push |
Sure, but 2 things: |
|
@ruben-arm this pull request can not be integrated into git checkout pr-8365047
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
Thank you for the detailed advice, @theRealAph, I now see how Reviewing the There indeed seems to be a way to have it inlined, at least on Linux - via creating an extra ELF section containing addresses of all inlined Since there isn't necessarily a consensus at this stage on whether |
|
Thank you all for reviewing the PR and helping with testing. A separate JBS issue has been opened for I plan to wait until tomorrow before issuing the |
|
/integrate |
|
@ruben-arm |
|
/sponsor |
|
Going to push as commit 3e3822a.
Your commit was automatically rebased without conflicts. |
|
@eastig @ruben-arm Pushed as commit 3e3822a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
We are seeing some new crashes (JDK-8371388) trying to access a PC that is just past the end of the nmethod and the page is unmapped because it also happens to be the last page of the CodeHeap. Could it be related to the changes in this PR? |
Yes, I think it could be similar to the case fixed for AArch64 post-call NOP check earlier: jdk/src/hotspot/cpu/x86/nativeInst_x86.hpp Line 584 in e34a831
It could be replaced with the two-step comparison: first the comparison matching size of the Would either of these options be suitable? |
|
Indeed, the jdk/src/hotspot/cpu/x86/nativeInst_x86.hpp Line 412 in e34a831
10 as size of the deopt handler stub code at jdk/src/hotspot/cpu/x86/x86.ad Line 2774 in e34a831
7.
|
|
Backing out with #28187. |
The C2 exception handler stub code is only a trampoline to the generated exception handler blob. This change removes the extra step on the way to the generated blob.
According to some comments in the source code, the exception handler stub code used to be patched upon deoptimization, however presumably these comments are outdated as the patching upon deoptimization happens for post-call NOPs only.
Progress
Issue
Reviewers
Contributors
<mdoerr@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26678/head:pull/26678$ git checkout pull/26678Update a local copy of the PR:
$ git checkout pull/26678$ git pull https://git.openjdk.org/jdk.git pull/26678/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26678View PR using the GUI difftool:
$ git pr show -t 26678Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26678.diff
Using Webrev
Link to Webrev Comment