Invoke downcall handle with custom memory layout requires arena in params

tison wander4096 at gmail.com
Sat Apr 6 13:58:52 UTC 2024


I found this sentence on the apidoc now:

Moreover, if the function descriptor's return layout is a group layout, the
resulting downcall method handle accepts an additional leading parameter of
type SegmentAllocator
<https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/foreign/SegmentAllocator.html>,
which is used by the linker runtime to allocate the memory region
associated with the struct returned by the downcall method handle.

Best,
tison.


tison <wander4096 at gmail.com>于2024年4月6日 周六17:13写道:

> Hi,
>
> This seems undocumented. As in [1], the native method signature is:
> FunctionDescriptor.of(either, ValueLayout.ADDRESS).
>
> And below when invoke the method handle, it requires: handle.invoke(arena,
> arena.allocateFrom("name")
>
> Where comes this extra param?
>
> Best,
> tison.
>
> [1]
> https://x.com/tisonkuncz/status/1776518595499217094
> <https://x.com/tisonkuncz/status/1776518595499217094?s=46&t=rCbLrJSBayvO_CKE6XmYKQ>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240406/d38be86b/attachment.htm>


More information about the panama-dev mailing list