-
Notifications
You must be signed in to change notification settings - Fork 720
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
Use VM criteria for J2I Thunk Sharing in AOT Compiles #16625
Conversation
@@ -9195,13 +9195,44 @@ TR_J9SharedCacheVM::getDesignatedCodeCache(TR::Compilation *comp) | |||
void * | |||
TR_J9SharedCacheVM::getJ2IThunk(char *signatureChars, uint32_t signatureLength, TR::Compilation *comp) | |||
{ | |||
return (void *)findPersistentThunk(signatureChars, signatureLength); |
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.
There is a future PR where findPersistentThunk
will be cleaned up. At the moment, two different types of J2I thunks are stored using this, but they are maintained by completely different data structures. The future cleanup PR will address this.
33381e4
to
227faa5
Compare
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.
LGTM. I only have a couple of small requests regarding comments.
If you do any future cleanup (I saw a comment saying that you intend that) maybe it's worth creating a data structure for the thunk. I saw some magic where we get back by 8 bytes and then read the thunk code length stored on 4 bytes.
Refactor the part of j9ThunkEncodeSignature that determines the encoding of the J2I Thunk Signature so that it can be reused by other functions. Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
227faa5
to
85f2a79
Compare
jenkins test sanity all jdk17 |
Add methods that will find and store J2I Thunks into the SCC rather than the hash tables. Because the SCC key needs to be a UTF8 string, generate the encoding of the signature (used as the key for the SCC entry) in ASCII. Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
@dsouzai Some compilation errors:
|
I guess some compilers don't like |
Since tests were already kicked off, I'll wait to force push until they're done. zLinux build failed because of #9758 |
85f2a79
to
96d36b7
Compare
jenkins test sanity all jdk17 |
In a non-AOT compilation, the JIT generates J2I Thunks and stores them into a VM Hash Table using the
j9ThunkNewSignature
API; it looks up existing thunks using thej9ThunkLookupSignature
API. In an AOT compilation, the JIT does not uses these APIs, but rather simply stores the Thunks into the SCC using the signature of the method as the key.The VM API will share the thunks for two different methods if all of the following is true:
Therefore, if two methods have different object types, they can still use the same thunk. For example,
foo(IILMyObject;)V
andbar(IILMyOtherObject;)V
can share the same thunk, butbaz(ILMyObject;I)V
cannot.Because AOT compiles only used the signature of the method as the key for the SCC entry, it resulted in thunks that could be shared not being shared. This is the root cause of the problem described in #16402.
This PR reuses the VM mechanism to encode the signature to generate the key to store the SCC entry. As such, the same sharing that occurs in a non-AOT compile will also occur in an AOT compile.
Fixes #16402