-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8276064: CheckCastPP with raw oop input floats below a safepoint #10932
Conversation
👋 Welcome back thartmann! A progress list of the required criteria for merging this PR into |
@TobiHartmann 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. |
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.
Good and conservative solution.
Thanks for discussion offline with Tobias and Vladimir I. about this special case from Vector API.
@TobiHartmann 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 150 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 |
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 for fixing the issue!
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 to me.
Thanks, Roland! |
/integrate |
Going to push as commit cd9c688.
Your commit was automatically rebased without conflicts. |
@TobiHartmann Pushed as commit cd9c688. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This bug is similar to JDK-8271600: A CheckCastPP with a raw oop input floats out of a loop and below a safepoint. Since C2 does not generate OopMap entries for raw pointers, the GC will not update the oop if the corresponding object is moved during the safepoint. We either assert already during OopMap creation, or crash when dereferencing a stale oop during runtime (the verification code does not always detect such live raw oops at safepoints, I included a fix for that as well).
I think the fix for JDK-8271600 is incomplete, because it only bails out of PhaseIdealLoop::try_sink_out_of_loop while the underlying issue is that a raw CheckCastPP ends up with ctrl "far away" from its Allocate/Initialize and potentially even below a safepoint. Usually, the CheckCastPP would always be part of safepoint debug info and therefore late ctrl would be guaranteed to be above the safepoint. However, vector objects are aggressively scalar replaced in safepoints, which allows late ctrl to be set to further below. This is specific to vectors, since "normal" Java objects would either be fully scalarized or not be scalarized at all.
In the failing case, Loop Unswitching clones the loop body and creates a Phi to merge the oop results from the vector allocations in both loops. Since ctrl of the CheckCastPP is outside of the loop, its data input is changed to the newly created Phi and its control input is set to the region that merges the loop exits. This moves the CheckCastPP below a safepoint in the loop.
Below graphs show the details.
395 CheckCastPP
is removed from the debug info for262 CallStaticJava
because it's scalarized (326 SafepointScalarObject
). Late ctrl is then computed to be outside of the loop because the CheckCastPP is only used in the return.Now Loop Unswitching creates a
487 Region
and517 Phi
to merge control and data inputs to the CheckCastPP from the fast and slow loops (seePhaseIdealLoop::clone_loop_handle_data_uses
). Control of the395 CheckCastPP
is updated accordingly.As a result, the raw oop input of the
395 CheckCastPP
is live at262 CallStaticJava
.We could now add another point fix to prevent loop unswitching from moving the CheckCastPP out of the loop, but I think there is a risk that other current or future optimizations would rely on the CheckCastPP's late ctrl and do a similar thing. I would therefore suggest to pin all CheckCastPPs with a raw oop input, similar to what JDK-5071820 did in GCM:
jdk/src/hotspot/share/opto/gcm.cpp
Lines 1325 to 1330 in 37107fc
The fix for JDK-8271600 can then be reverted, also because Roland's fix for JDK-8272562 disabled moving all CheckCastPPs out of loops anyway. Roland said that he plans to revisit that decision with JDK-8275202. The tests added with this PR will cover the
PhaseIdealLoop::try_sink_out_of_loop
case as well and therefore serve as regression tests for JDK-8271600.We could improve this by adding logic to set late ctrl just above the safepoint, but I'm not sure if it's worth the complexity because we would need to walk up the control paths from late to early control and compute the dominator of all safepoints.
I also fixed the verification code in
OopFlow::build_oop_map
to account for spilling. Before, compilation oftest1
would pass and only crash during execution. Now, we assert and print:What do you think?
Thanks,
Tobias
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10932/head:pull/10932
$ git checkout pull/10932
Update a local copy of the PR:
$ git checkout pull/10932
$ git pull https://git.openjdk.org/jdk pull/10932/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10932
View PR using the GUI difftool:
$ git pr show -t 10932
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10932.diff