Best way to use FFI-unsafe types in functions?

Zea zea_64 at proton.me
Thu Mar 28 05:03:33 UTC 2024


Hi,
I've been really excited to use this API for accessing Rust libraries, but ran into a snag.

Most Rust types have undefined layout, with the only properties known being size and alignment via const functions that I can export as symbols for the Java side to know ahead of time. From my understanding of the AMD64 ABI, you need to know the exact struct definition because it can sometimes pass things in registers rather than the stack, so how would I go about passing types by value (at least semantically)?

The best I've come up with is passing in/out pointers and memcpying those, but is this the best way? What are the JIT implications of this, if any?

Thanks for helping!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240328/92871ff4/attachment.htm>


More information about the panama-dev mailing list