[foreign-abi] RFR: 8254682: Close MemorySegments passed to upcalls after the upcall is done
Jorn Vernee
jvernee at openjdk.java.net
Tue Oct 13 15:05:36 UTC 2020
Hi,
Currently, we don't close MemorySegments that we pass to upcalls. This makes it easier to leak a MemorySegment from an
upcall, but it also incurs an additional copy on Windows and Aarch64, and forces users to close these segments manually
instead. (This is mostly so for historical reasons, when it was not as easy to avoid this copy due to the code
structure/design at that time).
We can instead registers these segments with a NativeScope that is closed after the upcall completes, to make sure
these segments do not leak inadvertently, and we don't need the additional copy on some platforms.
In this PR I've also fixed 2 minor Javadoc issues in Binding.java that I missed last time around.
This patch will also break jexract tests, but I have a patch ready to fix (was pretty trivial).
Thanks,
Jorn
-------------
Commit messages:
- Close segments passed to upcalls after passing
Changes: https://git.openjdk.java.net/panama-foreign/pull/379/files
Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=379&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8254682
Stats: 282 lines in 11 files changed: 228 ins; 28 del; 26 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/379.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/379/head:pull/379
PR: https://git.openjdk.java.net/panama-foreign/pull/379
More information about the panama-dev
mailing list