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
8254793: [JVMCI] improve speculation encoding #667
Conversation
👋 Welcome back dnsimon! A progress list of the required criteria for merging this PR into |
Webrevs
|
2fb4c99
to
2e4e452
Compare
// uniquely identify the speculative optimization guarded by the uncommon trap. | ||
// The id value is only 32-bits but since this field is exposed via VMStructs to | ||
// JVMCI as a jlong, it needs to be kept as a long to maintain backwards compatibility | ||
// with JVMCI based compilers that emit code to update the field directly. | ||
jlong _pending_failed_speculation; |
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.
I am confusing about backword compatibility comment. It said that old Graal (link in current JDK) generate code which writes 64 bits into this word. Will it use [32:32] index:length format or it will use new [0:27:5] format?
I don't see changes to Graal in this PR.
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.
The version of Graal in the JDK does not change. It is agnostic about the encoding format. All is does is write a value to Thread::_pending_failed_speculation
where said value is provided by JVMCI. The width of the write is determined by the width of the value. You can follow the code that does this here.
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.
Based on some of my comments from elsewhere we've undone some of the original changes so it just produces int friendly long constants. Changing the actual encoding size poses some compatibility problems because we weren't careful enough to be completely size agnostic in Graal code.
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.
Okay, that it what I looked for - the value encoding is provided by JVMCI. Good.
I've updated this PR such that an encoded speculation value is always stored/transported in a long. The encoding still only uses 31 bits which means the instruction sequence emitted by Graal can still be optimized to a single store (e.g. on x86 a MOVESLQ can write a 32 bit value sign extended to a long into a long memory location). |
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.
@dougxc 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 53 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 |
@@ -51,6 +52,21 @@ class JVMCINMethodData { | |||
// is appended when it causes a deoptimization. | |||
FailedSpeculation** _failed_speculations; | |||
|
|||
// A speculation id is an index (high 26 bits) and a length (low 5 bits). |
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.
We don't really have to enforce that it fits in an int any more. I think it would be more natural to allow to use all the remaining bits even though we'll never actually use that space in practice. Doing so makes the code look a little odd I think since there's no obvious reason for limit. We just want an encoding that's int friendly for the normal case.
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.
All good points. Please confirm that 2 most recent commits to this PR align with your suggestions.
// uniquely identify the speculative optimization guarded by the uncommon trap. | ||
// The id value is only 32-bits but since this field is exposed via VMStructs to | ||
// JVMCI as a jlong, it needs to be kept as a long to maintain backwards compatibility | ||
// with JVMCI based compilers that emit code to update the field directly. | ||
jlong _pending_failed_speculation; |
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.
Based on some of my comments from elsewhere we've undone some of the original changes so it just produces int friendly long constants. Changing the actual encoding size poses some compatibility problems because we weren't careful enough to be completely size agnostic in Graal code.
…peculation is reduced (to 5 bits)
@dean-long @vnkozlov I've made a few new changes based on @tkrodriguez 's comments. Please let me know if it still looks good. I've also rerun mach5 testing on the new changes and everything passes. |
New version looks good. |
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.
Still good.
Thanks for the reviews. |
/integrate |
@dougxc Since your change was applied there have been 54 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit f42c032. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR changes the encoding of a
jdk.vm.ci.hotspot.HotSpotSpeculationLog.HotSpotSpeculation
from a long to an int. TheThread::_pending_failed_speculation
field remains as ajlong
since it is already exposed to JVMCI Java code already via VMStructs and this PR does not update its usage in Graal.Progress
Testing
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/667/head:pull/667
$ git checkout pull/667