-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8364670: Extend JVMCI to express fixed binding #26652
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
base: master
Are you sure you want to change the base?
8364670: Extend JVMCI to express fixed binding #26652
Conversation
Hi @MichaelHaas99, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user MichaelHaas99" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
❗ This change is not yet ready to be integrated. |
@MichaelHaas99 The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
/** | ||
* Specifies if the call has a corresponding bytecode. | ||
*/ | ||
public final boolean trustBytecode; |
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 know this is just draft, but I'm wondering what the purpose of this is? It seems like setting bind says whether to do it or not. Is this just for testing?
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 should try avoid adding stuff here just for testing if possible.
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.
No not just for testing.
Hotspot assumes that the bound method originated from an underlying bytecode.
Therefore I want sth to say: don't trust the bytecode patch calls in JVMCI compiled code with the bound method. I guess we will need this for the truffle safepoint right?
If we trust it we will follow the normal logic in sharedRuntime.cpp.
Valhalla also expects that if the method is bound and not a method handle then it must have scalarized parameters, see https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/runtime/sharedRuntime.cpp#L1244
I think it is better if our logic have as less influence as possible of whatever changes they do in there.
So inserting a truffle safepoint is actually similar to the acmp patch here, except that acmp actually has a corresponding bytecode
https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/runtime/sharedRuntime.cpp#L1194
method handle has corresponding bytecode (invoke..), trustBytecode=true
acmp has corresponding bytecode (acmp), trustBytecode=true
truffle safepoint has no corresponding bytecode?, trustBytecode=false
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 see. We want to specially identify these call sites as intentionally bound so that we can safely plug into the existing sanity checks and whatever checks are eventually added. I think for the purposes of JVMCI, setting the bind flag is how we indicate this and having a separate flag doesn't make much sense to me. The new reloc info flag could be explicitly_bound which I think is more clear. trust_bytecode implies unrelated things to me.
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.
But that would be a one to one mapping of the explicitly_bound and bind flag then?
As the bind flag means attach the method there is no sense in having an explicitly_bound flag then?
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.
Yes that's what I want to say, also an option yes. What if the underlying bytecode is an invoke itself, can we ensure this will not be the 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.
truffle safepoint is no different than the acmp case but we might be at any possible valid bci in a method. So there is a bytecode but we don't know what it is until the safepoint call is inserted in the graph. Hopefully that's not a problem for HotSpot. Are we sure that valhalla doesn't contain any extra fixes to make bound calls at acmp work? I just find it a little hard to believe that somewhere in HotSpot there isn't an assert or two that would be unhappy about the resulting structure.
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.
Our comments are getting ordered weirdly. I agree it might be a little confusing if the call site was an invoke though that seems a little unlikely. We should be getting state afters from FSA. I think we just need to get some code working and see if anything barfs. Or maybe write a better unittest that exercises the possible truffle use case. We could also instrument FSA to report what states and bytecode are assigned to TruffleSafepointNode in a stock Graal build.
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.
truffle safepoint is no different than the acmp case but we might be at any possible valid bci in a method. So there is a bytecode but we don't know what it is until the safepoint call is inserted in the graph. Hopefully that's not a problem for HotSpot. Are we sure that valhalla doesn't contain any extra fixes to make bound calls at acmp work? I just find it a little hard to believe that somewhere in HotSpot there isn't an assert or two that would be unhappy about the resulting structure.
I'll need to have a look maybe, maybe not. But yes let's try it in the jvmcicodeinstaller as well.
Our comments are getting ordered weirdly. I agree it might be a little confusing if the call site was an invoke though that seems a little unlikely. We should be getting state afters from FSA. I think we just need to get some code working and see if anything barfs. Or maybe write a better unittest that exercises the possible truffle use case. We could also instrument FSA to report what states and bytecode are assigned to TruffleSafepointNode in a stock Graal build.
yes sounds 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.
@tkrodriguez @dougxc
Having thought about it for a while and looked at code in Valhalla, I came up with the following solution for the truffle safepoint:
Calls based on invoke bytecodes are marked as don't reexecute. In Graal an Invoke node is a state split and computes its stateDuring based on the stateAfter. The stateDuring has the StackState After_Pop=!should_reexecute.
As we now have calls that don't correspond to invoke bytecodes, their nodes should rely on a stateBefore (StackState is Before_Pop = should_reexecute) to deoptimize.
In sharedRutime.cpp we can then check if the reexecute bit is set and a method is bound and resolve the call site for the truffle safepoint.
See 21759a9
What do you think?
@@ -49,11 +49,27 @@ public final class Call extends Infopoint { | |||
*/ | |||
public final boolean direct; | |||
|
|||
/** | |||
* Specifies if the target method should be attached to the call site. This is necessary if the corresponding bytecode does not represent a call or no corresponding bytecode exists. |
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.
* Specifies if the target method should be attached to the call site. This is necessary if the corresponding bytecode does not represent a call or no corresponding bytecode exists. | |
* Specifies if {@link #target} should be attached to the call site. This is necessary if {@link debugInfo} does not represent an invoke bytecode or no corresponding bytecode exists. |
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.
Not sure if we should say "an invoke bytecode" if_acmp is no invoke bytecode (Valhalla)
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.
Ok, it would help to mention this example in the comment. And I'm still hoping we can avoid needing to support the "no corresponding bytecode exists" 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.
What does no corresponding bytecode exists
even mean? The call is in the context of an nmethod and while you don't have to be at an invoke bytecode you must be at some valid bci in an method since a frame state is still required for safepointing.
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.
Corresponding in the sense of although the bytecode is no invoke.. it still has some semantic link (Valhalla acmp)
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 think describing those as different cases is confusing for documentation. It seems like it would sufficient to just say This permits the compiler to override the bytecode based call site resolution for cases were special semantics are needed.
. Going into more detail than that doesn't seem necessary.
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.
sounds good
We might want to also delete JVMCIRuntime::invoke_static_method_one_arg to make it clear that we are using this new support to replace that helper so we are more loom friendly. That would mean we'd need to have the graal side changes ready to go so we can merge them to galahad too. |
The basic shape looks good to me so far, so we just need to confirm if we can use it for truffle or not. Thanks for jumping on this so quickly. |
Yes I will delete JVMCIRuntime::invoke_static_method_one_arg Thank you, thanks for the comments, helped a lot. |
5902b64
to
a1c3cf7
Compare
430f20f
to
ab184be
Compare
@MichaelHaas99 Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
Created JTREG test.
ab184be
to
61dca0c
Compare
@MichaelHaas99 Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
Progress
Errors
Integration blocker
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26652/head:pull/26652
$ git checkout pull/26652
Update a local copy of the PR:
$ git checkout pull/26652
$ git pull https://git.openjdk.org/jdk.git pull/26652/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26652
View PR using the GUI difftool:
$ git pr show -t 26652
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26652.diff