8390650: Unsafe access with constant zero offset triggers assert in EA - #32466
8390650: Unsafe access with constant zero offset triggers assert in EA#32466TobiHartmann wants to merge 3 commits into
Conversation
|
👋 Welcome back thartmann! A progress list of the required criteria for merging this PR into |
|
@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 /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 47 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 |
|
@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. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
|
Thanks Quan-Anh! |
| // EA expects on-heap memory addresses to be represented by an AddP. An AddP with a zero | ||
| // offset can be optimized to its oop base, so recreate it. | ||
| Node* addp = AddPNode::make_with_base(n->in(MemNode::Address), n->in(MemNode::Address), _igvn->MakeConX(0)); |
There was a problem hiding this comment.
May be use oopDesc::mark_offset_in_bytes() instead of 0.
There was a problem hiding this comment.
But that would be incorrect if oopDesc::mark_offset_in_bytes() ever became non-zero, right? So we would at least need to add an assert here which feels misplaced.
There was a problem hiding this comment.
Yes, you are right. I forgot it just unsafe access to some offset. :(
The original failure happened with CTW of some internal code. The issue happens when C2 compiles an (unreachable) unsafe access with a constant zero offset and IGVN folds the
AddPaddress to the base oop. We then hit an assert in escape analysis because it expects memory addresses to always be represented by anAddP.By coincidence, we hit a similar issue in Valhalla when adding support for
Unsafe.makePrivateBuffer/finishPrivateBuffer(see JDK-8206144), which had to read/write a mark word bit and therefore emitted a load/store on the mark word address in the header without anAddP. We fixed it like this:jdk/src/hotspot/share/opto/escape.cpp
Lines 172 to 181 in c92288e
Now this code is dead since
Unsafe.makePrivateBuffer/finishPrivateBufferand their C2 mark-word loads/stores were removed by JDK-8373375 and JDK-8380802.I think we should still revive the code to handle this case which is a much older issue and independent of Valhalla.
The alternative would be to emit a runtime check and guard it with an
OpaqueConstantBoolNodesuch that it's folded later. I quickly prototyped this but it feels way too complicated to handle this edge case. Also, it would not help if we add mark word loads/stores back in the future.Thanks,
Tobias
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32466/head:pull/32466$ git checkout pull/32466Update a local copy of the PR:
$ git checkout pull/32466$ git pull https://git.openjdk.org/jdk.git pull/32466/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 32466View PR using the GUI difftool:
$ git pr show -t 32466Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32466.diff
Using Webrev
Link to Webrev Comment