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

Allow inlining of java/lang/ref/Reference.refersTo method #13619

Merged
merged 3 commits into from
May 4, 2023

Commits on May 3, 2023

  1. Define queries to test whether Reference.refersTo can be inlined

    The refersTo method was introduced to java.lang.ref.Reference in
    Java 16.  The JIT compiler is able to inline the method under the same
    conditions as it is able to inline Reference.getImpl.  This change
    introduces new query methods and fields to check and record whether both
    methods can be inlined.
    
    The existing VM::isGetImplInliningSupported and
    Compilation::setGetImplInlineable methods are invoked by OMR, so
    they will remain in OpenJ9 until a subsequent pull request against OMR
    replaces calls to those now obsolete methods.
    
    Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
    hzongaro committed May 3, 2023
    Configuration menu
    Copy the full SHA
    aab32e7 View commit details
    Browse the repository at this point in the history
  2. Allow inlining java/lang/ref/Reference.refersTo method

    A Reference.refersTo(Object) method, introduced in Java 16, tests
    whether the referent is the same object as the parameter.  Some
    places in the JCL that used to perform comparisons of the referent using
    Reference.get now use Reference.refersTo.  That affects performance of
    such uses as Reference.get was implemented using a call to
    Reference.getImpl which the JIT compiler recognized and inlined if
    possible.
    
    This change adds recognition of Reference.refersTo to the JIT, which
    will now inline a call to it under the same conditions as it would
    inline a call to Reference.getImpl.
    
    Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
    hzongaro committed May 3, 2023
    Configuration menu
    Copy the full SHA
    69d1aae View commit details
    Browse the repository at this point in the history
  3. Ensure failing to inline Reference.refersTo is handled properly

    If TR_J9VM::inlineNativeCall fails to inline a method, it sometimes
    returns NULL and sometimes returns the original call node.  If it
    returns NULL and the call node is a JNI call, the caller considers
    whether any special processing of the call node is required by calling
    TR::Node::processJNICall.
    
    In the case of Reference.refersTo, the call is not inlined if the
    Metronome GC policy is in effect, but inlineNativeCall was returning the
    original call node.  That signalled to the caller that no special
    consideration of whether the call node was a JNI call was needed, but it
    was in fact needed.
    
    Fixed this by having TR_J9VM::inlineNativeCall return NULL if it is
    unable to inline Reference.refersTo.
    
    Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
    hzongaro committed May 3, 2023
    Configuration menu
    Copy the full SHA
    97af55c View commit details
    Browse the repository at this point in the history