[foreign-abi] RFR: JDK-8248809: Consider supporting address dereference/allocation for platforms where pointers are not 64 bits

Paul Sandoz psandoz at openjdk.java.net
Fri Sep 4 19:17:15 UTC 2020


On Fri, 4 Sep 2020 17:46:09 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch makes support for addresses more uniform, in a way that scales to platforms whose pointer size might be !=
> 64 bits. After considering a number of alternatives, we settled on something which, I think is pleasing for a number of
> rteasons.  First, we added a new layout, namely `MemoryLayouts.ADDRESS`. This is the layout of a machine pointer, in
> the platform in which the JVM runs. This is a useful piece of information to have regardless.
> This new layout is then used in two places:
> 
> * In MemoryAccess, to decide whether we need a 32 or a 64 dereference handle to get/set addresses
> 
> * In NativeScope, again, to decide to which NativeScope factory we should delegate (the long vs. the int one)
> 
> This should slightly generalize what we have and also adds some extra helper methods to NativeScope which were dropped
> in an earlier iteration, waiting for this issue to be addressed.
> I've tweaked the NativeScope test in order to stress the new address-accepting factories.

Our exposure to 32-bit platforms is getting less and less, making it tricky to test. I suspect most users will hard
code to the long carrier type without realizing it.

I admit to being a little torn over this. Unsafe either ignores the 32 MSBs of long values, or requires they are
zeroed. Not ideal either.

-------------

Marked as reviewed by psandoz (Committer).

PR: https://git.openjdk.java.net/panama-foreign/pull/308


More information about the panama-dev mailing list