[foreign-abi] RFR 8236004: Memory access var handles should support MemoryAddress carrier

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Dec 18 18:03:37 UTC 2019


On 18/12/2019 17:43, Paul Sandoz wrote:
> Some subtle stuff going on here!
>
> The current patch looks correct to me.
>
> Having a few negative tests, passing in bogus arguments is useful. I can send out a webrev if you like.

OK - thanks!

Maurizio

>
>> On Dec 18, 2019, at 8:12 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>>
>>
>> On 18/12/2019 13:42, Maurizio Cimadamore wrote:
>>> X-VarHandleMemoryAddressView.java.template:
>>> - In the long2addr method I'd prefer using invokeExact instead of invoke, to make sure the call always gets inlined.
>> Forgot - this was deliberate too - the target type is not (and cannot be) the same as the declared return type (MemoyAddress) because that's in a different module. So invoke() is, I believe, the only hacky option here.
>>
> Since this is trusted code we can use MH.linkToStatic.  Then, if need be, change it to invokeExact when the API exits incubation.
>
> Using MH.linkToStatic is a little more complicated as you need to pass in a trailing MemberName, which can be created from a Method e.g.:
>
>
>    Method m = … // get method for jdk.incubator.foreign.MemoryAddress.ofLong(long )MemoryAddress
>    ADDRESS_MEMBER_NAME = new MemberName(m)
>
>>
>    return ($type$) MethodHandle.linkToStatic(value, ADDRESS_MEMBER_NAME);
>
> Paul.


More information about the panama-dev mailing list