openj9 icon indicating copy to clipboard operation
openj9 copied to clipboard

Recognize linkToNative() in the JIT compiler to allow J2I calls

Open jdmpapin opened this issue 1 year ago • 9 comments

  • Treat linkToNative() as signature-polymorphic.
  • Pass an extra argument to reserve space for the appendix.
  • Always compile-time resolve to ensure the extra argument is passed.

jdmpapin avatar Jan 24 '24 22:01 jdmpapin

Note that linkToNative() is not yet in use. These changes are meant to work with the prototype implementation in #18799, which will be available under the option -Xffiproto

jdmpapin avatar Jan 24 '24 22:01 jdmpapin

@0xdaryl, would you please review?

jdmpapin avatar Jan 30 '24 20:01 jdmpapin

@0xdaryl, is there any update with your review on this PR? We need to get it merged asap to let the JIT team start working on the optimization related code.

ChengJin01 avatar Feb 12 '24 19:02 ChengJin01

Jenkins test sanity all jdk21

0xdaryl avatar Feb 12 '24 19:02 0xdaryl

Jenkins test sanity all jdk22

0xdaryl avatar Feb 12 '24 19:02 0xdaryl

Jenkins test sanity all jdk22

0xdaryl avatar Feb 13 '24 01:02 0xdaryl

In general, the code here looks fine to me. However, the Windows JDK 22 failure is for an UnsatisfiedLinkError in cmdLineTester_loadLibraryTests_0. I don't believe this is a known issue. While this PR is not expected to affect that, it does deal with calling native code which makes it tangentially related.

I've seen this fail twice with this PR. I am launching an independent build without the change to see if the problem appears there.

0xdaryl avatar Feb 14 '24 14:02 0xdaryl

Jenkins test sanity win jdk22

0xdaryl avatar Feb 15 '24 14:02 0xdaryl

I think the Windows failure needs investigation. It is reproducible and in the test runs I've done I've only seen it with this PR. It might still turn out to be an infra-related issue but I'd like Devin to look into it when he's back from leave next week before this is merged.

0xdaryl avatar Feb 16 '24 12:02 0xdaryl

Jenkins test sanity win jdk22

jdmpapin avatar Feb 20 '24 17:02 jdmpapin

Error fetching remote repo 'origin'

Jenkins test sanity win jdk22

jdmpapin avatar Feb 20 '24 17:02 jdmpapin

I've rerun the Windows JDK22 PR build/tests with my changes reverted, and I don't see an unexpected UnsatisfiedLinkError. However, I do see a failure to throw an expected UnsatisfiedLinkError:

[2024-02-20T21:09:33.378Z] TESTING:
[2024-02-20T21:09:34.292Z] *** Starting test suite: LoadLibrary test intended for CMVC 201408 ***
[2024-02-20T21:09:34.292Z] Testing: LoadLibrary testcase with invalid paths specified in the library path list
[2024-02-20T21:09:34.293Z] Test start time: 2024/02/20 16:09:33 Eastern Standard Time
[2024-02-20T21:09:34.293Z] Running command: C:/Users/jenkins/workspace/Test_openjdk22_j9_sanity.functional_x86-64_windows_Personal_testList_1/jdkbinary/j2sdk-image\bin\java -Djava.library.path=".;'C:\\Program Files (x86)\\ibm\\tivoli';C:\\Users\\j9build;C:\\dev;." -cp C:/Users/jenkins/workspace/Test_openjdk22_j9_sanity.functional_x86-64_windows_Personal_testList_1/aqa-tests///..//jvmtest\functional\cmdLineTests\loadLibraryTest\loadLibraryTest.jar org.openj9.test.loadLibrary.TestLoadLibrary
[2024-02-20T21:09:34.712Z] Time spent starting: 172 milliseconds
[2024-02-20T21:09:35.584Z] Time spent executing: 1078 milliseconds
[2024-02-20T21:09:35.584Z] Test result: FAILED
[2024-02-20T21:09:35.584Z] Output from test:
[2024-02-20T21:09:35.584Z] >> Success condition was not found: [Output match: Not found in java.library.path]
[2024-02-20T21:09:35.584Z] >> Success condition was not found: [Output match: The specified network name is no longer available]
[2024-02-20T21:09:35.584Z] >> Success condition was not found: [Output match: java.lang.UnsatisfiedLinkError: Can't load abcdef]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: The specified path is invalid]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: Could not find or load main class Files]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: Unhandled Exception]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: corrupt]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: Processing dump event]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: JVM requested Java dump]
[2024-02-20T21:09:35.584Z] >> Failure condition was not found: [Output match: JVM requested Snap dump]
[2024-02-20T21:09:35.584Z] 
[2024-02-20T21:09:35.584Z] 
[2024-02-20T21:09:35.584Z] ---TEST RESULTS---
[2024-02-20T21:09:35.584Z] Number of PASSED tests: 0 out of 1
[2024-02-20T21:09:35.584Z] Number of FAILED tests: 1 out of 1
[2024-02-20T21:09:35.584Z] 
[2024-02-20T21:09:35.584Z] ---SUMMARY OF FAILED TESTS---
[2024-02-20T21:09:35.584Z] LoadLibrary testcase with invalid paths specified in the library path list
[2024-02-20T21:09:35.584Z] -----------------------------
[2024-02-20T21:09:35.584Z] 
[2024-02-20T21:09:35.584Z] -----------------------------------
[2024-02-20T21:09:35.584Z] cmdLineTester_loadLibraryTests_0_FAILED
[2024-02-20T21:09:35.584Z] -----------------------------------

In particular:

>> Success condition was not found: [Output match: java.lang.UnsatisfiedLinkError: Can't load abcdef]

This is in the same cmdLineTester_loadLibraryTests_0 that was mentioned in https://github.com/eclipse-openj9/openj9/pull/18817#issuecomment-1943829938

The test that failed this time appears to be the only test within cmdLineTester_loadLibraryTests_0 ("FAILED tests: 1 out of 1"). @0xdaryl, is this the same failure that you saw before, or was that failure actually an unexpected UnsatisfiedLinkError?

jdmpapin avatar Feb 21 '24 23:02 jdmpapin

The latest failure I described here has been observed elsewhere and reported as #18975. That issue wasn't opened until the 16th, so after the failure seen in the PR build had been determined not to be a known issue in https://github.com/eclipse-openj9/openj9/pull/18817#issuecomment-1943829938

jdmpapin avatar Feb 22 '24 16:02 jdmpapin

@0xdaryl was this the failure that you saw before?

jdmpapin avatar Feb 23 '24 19:02 jdmpapin

was this the failure that you saw before?

It probably was. I didn't dive too deep into the failure to determine whether it was demonstrating an expected failure and then failing by other means.

Based on your investigation, I believe all issues with this PR have been explained.

0xdaryl avatar Feb 26 '24 18:02 0xdaryl

Is this ready to move out of draft?

0xdaryl avatar Feb 26 '24 18:02 0xdaryl

Removed the revert commit

jdmpapin avatar Feb 26 '24 20:02 jdmpapin