[foreign-memaccess+abi] RFR: 8275647: Enable multi-register return values for optimized upcall stubs
Jorn Vernee
jvernee at openjdk.java.net
Tue Nov 9 16:43:24 UTC 2021
On Tue, 2 Nov 2021 19:07:45 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Hi,
>
> After we've added multi-register return support to native invokers, this patch does the same for optimized upcall stubs. The strategy is very similar: the caller (in this case the upcall stub) allocates a return buffer in which the return values are stored, and then after the upcall shuffles the return values from the buffer into the right registers.
>
> This patch also removes the buffered invocation strategy for upcalls, and all related code, such as BufferLayout.
>
> ~Note, in it's current state this patch will disable regress AArch64 since optimized upcalls are not implemented there yet. i.e. this PR is blocked by: https://bugs.openjdk.java.net/browse/JDK-8275646~
>
> Jorn
src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp line 314:
> 312: // skip receiver
> 313: BasicType* in_sig_bt = out_sig_bt + 1;
> 314: int total_in_args = total_out_args - 1;
I've moved this to the shared code in universalUpcallHanlder.cpp, since it can be shared between platforms.
src/hotspot/share/code/codeBlob.cpp line 759:
> 757: JNIHandles::destroy_global(blob->receiver());
> 758: BufferBlob::free(blob);
> 759: }
We were freeing upcall stubs using CodeCache::free, but this doesn't track memory usage. I've added this method to properly handle freeing upcall stubs.
src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/ProgrammableUpcallHandler.java line 143:
> 141:
> 142: // we handle returns first since IMR adds an extra parameter that needs to be specialized as well
> 143: if (llReturn != void.class || callingSequence.needsReturnBuffer()) {
Note that the old code for handling return values is just moved from below the code that handles arguments (and then handling for mutli-reg returns added to that), since the return buffer argument also needs to be handle along with the rest of arguments.
src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/ProgrammableUpcallHandler.java line 203:
> 201: CallingSequence callingSequence,
> 202: Binding.VMStore[] retMoves,
> 203: ABIDescriptor abi) {}
Same as with downcalls, I've bundled all the extra arguments into a record.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/608
More information about the panama-dev
mailing list