openj9
openj9 copied to clipboard
[Part 1] FFI Upcall: creating the upcall stub (native)
The change includes all the native code of creating the upcall stub & metadata which are required in the FFI upcall.
Signed-off-by: Cheng Jin [email protected]
The change (which is the native code for https://github.com/eclipse-openj9/openj9/pull/15069) belongs to the issue intended for the upcall work at #15068.
Note:
-
encodeUpcallSignature()
inLayoutFFITypeHelpers.hpp
(belonging to part 2) is a placeholder, in which the code will be added to the changes in part 2 & 3 (encoding native signature & generating thunk). - some of function definitions intended for part 2 & 3 might need to be temporarily disabled in headers to avoid compilation errors in jenkins and re-enabled in part 2 & 3.
Reviewer: @tajila, @gacholio FYI: @DanHeidinga, @pshipton
Please hold off reviewing the code as the new changes for https://openjdk.java.net/jeps/424 (Preview) come up in https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/443. So I need to double-check to see whether the native code need to be updated accordingly to adapt to new APIs in Java 19 given there is no back compatibility across Java 17, 18 and 19.
The native code here will be updated to support JEP424 (Preview) in Java 19 which I've been working on.
The changes have been updated for JEP424 in Java 19 with createUpcallThunk
temporarily disabled in OutOfLineINL_jdk_internal_foreign_abi_ProgrammableUpcallHandler.cpp
and OutOfLineINL_jdk_internal_foreign_abi_UpcallLinker.cpp
to ensure the compilation passes in Jenkins given the code involved belongs to Part 3 (thunk generation) which will be re-enabled along with the changes in Part 3.
@tajila, the changes are ready for review.
The changes have been updated based on the latest solution at https://github.com/ChengJin01/openj9/commit/f2b361181c71d2ef4bf70e730f5a097cabda6636 to avoid duplicating code in downcall & upcall.
@gacholio Please review these changes
@ChengJin01 please rebase the PR
@gacholio are there anymore review comments?
@ChengJin01 please rebase the PR
Not sure why runtime/vm/OutOfLineINL_jdk_internal_foreign_abi_ProgrammableInvoker.cpp
shows up again (which should be removed before) but the conflict has been resolved after removing the file.
I can't tell from the diff - is the callOutCount
incremented and decremented around the call-out? If not, it should be.
I can't tell from the diff - is the
callOutCount
incremented and decremented around the call-out? If not, it should be.
Yes it should be in our case. So I just added the code to increment an decrement callOutCount
around the call-out in JDK19.
jenkins test sanity zlinux jdknext
jenkins compile win jdk8
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:422:2: error: 'createUpcallThunk' undeclared here (not in a function)
12:51:47 422 | createUpcallThunk,
12:51:47 | ^~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:423:2: error: 'getArgPointer' undeclared here (not in a function)
12:51:47 423 | getArgPointer,
12:51:47 | ^~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:424:2: error: 'allocateUpcallThunkMemory' undeclared here (not in a function)
12:51:47 424 | allocateUpcallThunkMemory,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:425:2: error: 'doneUpcallThunkGeneration' undeclared here (not in a function)
12:51:47 425 | doneUpcallThunkGeneration,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:426:2: error: 'native2InterpJavaUpcall0' undeclared here (not in a function)
12:51:47 426 | native2InterpJavaUpcall0,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:427:2: error: 'native2InterpJavaUpcall1' undeclared here (not in a function)
12:51:47 427 | native2InterpJavaUpcall1,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:428:2: error: 'native2InterpJavaUpcallJ' undeclared here (not in a function)
12:51:47 428 | native2InterpJavaUpcallJ,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:429:2: error: 'native2InterpJavaUpcallF' undeclared here (not in a function)
12:51:47 429 | native2InterpJavaUpcallF,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:430:2: error: 'native2InterpJavaUpcallD' undeclared here (not in a function)
12:51:47 430 | native2InterpJavaUpcallD,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/intfunc.c:431:2: error: 'native2InterpJavaUpcallStruct' undeclared here (not in a function)
12:51:47 431 | native2InterpJavaUpcallStruct,
12:51:47 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12:51:47 runtime/vm/CMakeFiles/j9vm.dir/build.make:584: recipe for target 'runtime/vm/CMakeFiles/j9vm.dir/intfunc.c.o' failed
The failure was caused by the missing code for these functions which belong to Part 2, 3 and 4. So I temporarily comment out these definitions to let the compilation pass and reenable them in other parts.
jenkins test sanity zlinux jdknext
jenkins compile win jdk8
14:19:14 /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/OutOfLineINL_openj9_internal_foreign_abi_InternalUpcallHandler.cpp:48:25: error: unused variable 'vmFuncs' [-Werror=unused-variable]
14:19:14 48 | J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
14:19:14 | ^~~~~~~
The compilation failure at https://openj9-jenkins.osuosl.org/job/Build_JDKnext_s390x_linux_Personal/62/consoleText
[2022-08-17T18:19:14.024Z] /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/OutOfLineINL_openj9_internal_foreign_abi_InternalUpcallHandler.cpp: In function 'VM_BytecodeAction OutOfLineINL_openj9_internal_foreign_abi_InternalUpcallHandler_allocateUpcallStub(J9VMThread*, J9Method*)':
[2022-08-17T18:19:14.024Z] /home/jenkins/workspace/Build_JDKnext_s390x_linux_Personal/openj9/runtime/vm/OutOfLineINL_openj9_internal_foreign_abi_InternalUpcallHandler.cpp:48:25: error: unused variable 'vmFuncs' [-Werror=unused-variable]
[2022-08-17T18:19:14.024Z] 48 | J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
[2022-08-17T18:19:14.024Z] | ^~~~~~~
is due to the disabled code vmFuncs->createUpcallThunk
in this part (enabled in Part2 & 3), in which case vmFuncs
becomes useless at this point. I just commented out this line for the moment and will be enabled in Part2 & 3.
jenkins test sanity zlinux jdknext