-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8305247: On RISC-V generate_fixed_frame() sometimes generate a relativized locals value which is way too large #13245
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
…vized locals value which is way too large.
👋 Welcome back fbredber! A progress list of the required criteria for merging this PR into |
Hi @RealFYang can you verify that this PR works on RISC-V? |
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 reasonable. I performed tier1-3 tests on my linux-riscv64 boards, result looks good.
BTW: You might want to change the issue title removing the '.' symbol.
@fbredber 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 34 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 (@RealFYang, @robehn) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
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
Thanks for testing @RealFYang. I've changed the title as you suggested. |
/integrate |
/sponsor |
Going to push as commit 33d09e5.
Your commit was automatically rebased without conflicts. |
The relativized locals value is supposed to contain the distance between the frame pointer and the local variables in an interpreter frame, expressed in number of words. It typically contains the value "frame::sender_sp_offset + padding + max_locals - 1"
On most architectures sender_sp_offset is 2. This gives us the value "1 + padding + max_locals", which is always greater or equal to 1.
However on RISC-V the value of frame::sender_sp_offset is 0, which means that if we don't have any padding and no local variables we end up with a relativized_locals value of -1.
When generate_fixed_frame() calculates the relativized_locals value it subtracts the frame pointer from the xlocals and then logically shifts the result right by Interpreter::logStackElementSize (to convert it into a word index).
This works fine on all platforms (except RISC-V), because the subtraction will never become negative. But since the subtraction can end up negative on RISC-V, the shift instruction must be a arithmetic-shift-right (not a logical-shift-right) to preserve the sign and not end up with a very large positive index.
This is currently not a real problem since the relativized_locals value is not used if max_local is zero, which is the only case the value is wrong.
It is however a real problem when implementing JDK-8300197.
The bug was introduced in JDK-8299795 and is fixed by changing a "srli" instruction to a "srai" in generate_fixed_frame().
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13245/head:pull/13245
$ git checkout pull/13245
Update a local copy of the PR:
$ git checkout pull/13245
$ git pull https://git.openjdk.org/jdk.git pull/13245/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13245
View PR using the GUI difftool:
$ git pr show -t 13245
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13245.diff