ibmruntimes / openj9-openjdk-jdk

Extensions for OpenJDK for Eclipse OpenJ9
GNU General Public License v2.0
17 stars 73 forks source link

[FFI] Handling the default library loading on z/OS #794

Closed ChengJin01 closed 3 months ago

ChengJin01 commented 3 months ago

The changes follow the same way of accessing the default libraries on AIX with the inlined functions in a list to address the issue with the default libraries during the FFI downcall on z/OS.

Related: Internal 441

Signed-off-by: ChengJin01 jincheng@ca.ibm.com

ChengJin01 commented 3 months ago

The PR (verified on AIX) has the same changes as https://github.com/ibmruntimes/openj9-openjdk-jdk21/pull/159.

ChengJin01 commented 3 months ago

Reviewer: @tajila FYI: @keithc-ca, @pshipton

keithc-ca commented 3 months ago

Jenkins test sanity aix,alinux jdknext

ChengJin01 commented 3 months ago

The failure at https://openj9-jenkins.osuosl.org/job/Test_openjdknext_j9_sanity.functional_aarch64_linux_Personal/37/artifact/Test_openjdknext_j9_sanity.functional_aarch64_linux_Personal_testList_0/37/aqa-tests/TKG/output_17168469728045/Test_openjdknext_j9_sanity.functional_aarch64_linux_Personal_testList_0.tap

        Caused by: java.util.NoSuchElementException: Symbol not found: funcs_addr
            at java.base/java.lang.foreign.SymbolLookup.findOrThrow(SymbolLookup.java:179)
            at java.base/jdk.internal.foreign.SystemLookup.getInlinedFunctListAddr(SystemLookup.java:98)
            at java.base/jdk.internal.foreign.SystemLookup.<clinit>(SystemLookup.java:65)
            ... 34 more
        -----------------------------------
        Jep454Tests_testLinkerFfi_DownCall_0_FAILED

indicates we should do nothing in getInlinedFunctListAddr() on other platforms give funcs_addr is specific to AIX & z/OS. So I suggest to add a piece of code to simply return null for non-AIX/zOS platforms in the static method as follows:

    private static MemorySegment getInlinedFunctListAddr() {
   if (!OperatingSystem.isAix() || !OperatingSystem.isZOS()) {
         return null;
     }
    ....
}

or

    private static final MemorySegment funcs = (OperatingSystem.isAix() || OperatingSystem.isZOS()) ? getInlinedFunctListAddr() : null;
keithc-ca commented 3 months ago

simply return null for non-AIX/zOS platforms

I suggest that should happen within getInlinedFunctListAddr() as it already checks for AIX; so moving the definition of funcsLayout to the beginning addresses the problem:

        SequenceLayout funcsLayout;

        if (OperatingSystem.isAix()) {
            funcsLayout = AixFuncSymbols.LAYOUT;
        } else if (OperatingSystem.isZOS()) {
            funcsLayout = ZosFuncSymbols.LAYOUT;
        } else {
            return null;
        }
ChengJin01 commented 3 months ago

simply return null for non-AIX/zOS platforms

I suggest that should happen within getInlinedFunctListAddr() as it already checks for AIX; so moving the definition of funcsLayout to the beginning addresses the problem:

        SequenceLayout funcsLayout;

        if (OperatingSystem.isAix()) {
            funcsLayout = AixFuncSymbols.LAYOUT;
        } else if (OperatingSystem.isZOS()) {
            funcsLayout = ZosFuncSymbols.LAYOUT;
        } else {
            return null;
        }

Updated the code against the suggestion above.

keithc-ca commented 3 months ago

Jenkins test sanity aix,alinux jdknext