Skip to content
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

Ensure resolved final methods are called directly #4944

Conversation

jdmpapin
Copy link
Contributor

@jdmpapin jdmpapin commented Mar 1, 2019

In 3b2830e genInvokeVirtual() was modified to detect resolved private methods for nestmates. If a private method is found, it generates a direct call, and otherwise (including when the method reference is unresolved) it generates a virtual call. In order to generate a virtual call, it queries the constant pool a second time, and if the constant pool entry was originally unresolved, it might have become resolved since. In this case, ilgen could fail to identify for a resolved call that the called method is final, and generate an indirect instead of a direct call. Normally it's harmless for the call to be indirect, but there are a number of final methods recognized by the JIT compiler that undergo transformations assuming that calls to them are direct.

To prevent this problem, genInvokeVirtual() will now re-read method from the result of findOrCreateVirtualMethodSymbol() whenever that result is resolved.

Fixes #4334
Master PR is #4860

In 3b2830e genInvokeVirtual() was modified to detect resolved private
methods for nestmates. If a private method is found, it generates a
direct call, and otherwise (including when the method reference is
unresolved) it generates a virtual call. In order to generate a virtual
call, it queries the constant pool a second time, and if the constant
pool entry was originally unresolved, it might have become resolved
since. In this case, ilgen could fail to identify for a resolved call
that the called method is final, and generate an indirect instead of a
direct call. Normally it's harmless for the call to be indirect, but
there are a number of final methods recognized by the JIT compiler that
undergo transformations assuming that calls to them are direct.

To prevent this problem, genInvokeVirtual() will now re-read method from
the result of findOrCreateVirtualMethodSymbol() whenever that result is
resolved.

Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
(cherry picked from commit 8a1ec0b)
@DanHeidinga
Copy link
Member

@jdmpapin Can you link to the PR against the master branch? It makes it clear that this fix has already gone into the mainline is being ported to the 0.13.0 release

@pshipton pshipton added this to the Release 0.13.0 (Java 12) milestone Mar 1, 2019
@jdmpapin
Copy link
Contributor Author

jdmpapin commented Mar 1, 2019

I've edited the link into the initial comment

@pshipton pshipton merged commit 481af61 into eclipse-openj9:v0.13.0-release Mar 1, 2019
@jdmpapin jdmpapin deleted the final-invokevirtual-concurrent-resolve-v0.13.0 branch April 9, 2021 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants