[foreign-abi] RFR: 8248420: Add a variant of VaList::make which takes a NativeScope
Jorn Vernee
jvernee at openjdk.java.net
Thu Jul 9 20:39:14 UTC 2020
On Thu, 9 Jul 2020 20:31:11 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> A VaList is really only a 'view' of a set of arguments stored elsewhere. In native code the place where the arguments
>> are stored (i.e. the 'argument space') is on the stack, so the memory will get cleaned up automatically. But, if we
>> create a VaList on the Java side we need to do an explicit off-heap allocation and later call free to clean up the
>> memory that stores the arguments. This argument space is freed when calling `close()` on the VaList. So, if you
>> `copy()` a VaList, only the 'view' part is copied, but not the memory that holds the arguments.
>
> I'm thinking of maybe dropping the VaList::make overload that doesn't take a NativeScope, so that the memory for the
> arguments will always be managed by a NativeScope, and it doesn't have to piggyback on VaList::close
I'll try and add a test for this as well
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/237
More information about the panama-dev
mailing list