[foreign-memaccess] RFR 8237349: Memory access var handles are never called with exact types

Paul Sandoz paul.sandoz at oracle.com
Wed Jan 29 18:39:21 UTC 2020


+1 a neat workaround.

Paul.

> On Jan 29, 2020, at 8:10 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> We currently have an issue: since the memory access var handle have to use MemoryAddressProxy as their first coordinate (such handles are generated in java.base which doesn't see the true MemoryAddress interface), whenever a var handle get/set fall outside the guards in VarHandleGuards performance suffer big time, because a full asType() adaptation has to occur.
> 
> For instance these are some numbers for the TestOverNonConstant benchmark:
> 
> W/ guards
> 
> 0.306 ms/op
> 
> W/o guards (-Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false)
> 
> 13.926 ms/op
> 
> The proposed patch adds an adaptation step to all memory access handles, so that their coordinate type is adjusted to be MemoryAddress, not MemoryAddressProxy. With this, there's no difference in performances w/ and w/o guards.
> 
> Webrev:
> 
> http://cr.openjdk.java.net/~mcimadamore/panama/8237349/
> 
> Note: as demonstrated in the test changes, this also makes adapting access var handle easier, since the user can't really access MemoryAddressProxy.
> 
> P.S.
> As a precaution I've run all our microbenchmark which seem unaffected by this (except in cases where, as shown above, this patch makes quite the - positive - difference).
> 
> Maurizio
> 
> 



More information about the panama-dev mailing list