Re: RFR: 8254354: Add an asExact() VarHandle combinator [v11]

2020-10-30 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v10]

2020-10-30 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v9]

2020-10-30 Thread Paul Sandoz
On Thu, 29 Oct 2020 18:14:05 GMT, Jorn Vernee wrote: >> Hi, >> >> This patch adds an asExact() combinator to VarHandle, that will return a new >> VarHandle that performs exact type checks, similar to >> MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, >> which can

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v9]

2020-10-29 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-29 Thread Jorn Vernee
On Tue, 27 Oct 2020 15:01:31 GMT, Jorn Vernee wrote: >> I've updated the implementation of accessModeType to work with the ordinal >> directly. Note that it was using the AccessType ordinal though, so I also >> had to change the parameter type of accessModeTypeUncached, and the >> respective i

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-27 Thread Jorn Vernee
On Mon, 26 Oct 2020 18:54:45 GMT, Jorn Vernee wrote: >> Paul, >> an invoker has the MethodHandle (resp. VarHandle) as first argument so it's >> not the same semantics. > > I've updated the implementation of accessModeType to work with the ordinal > directly. Note that it was using the AccessTyp

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v8]

2020-10-26 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v7]

2020-10-26 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator

2020-10-26 Thread Rémi Forax
On Fri, 23 Oct 2020 17:47:36 GMT, Jorn Vernee wrote: > Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead t

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-26 Thread Jorn Vernee
On Mon, 26 Oct 2020 17:13:05 GMT, Rémi Forax wrote: >> We can clarify the new methods and tie them closer to method handle >> semantics. I suggest the names `asExactInvoker` and `asInvoker`, referencing >> `MethodHandles.exactInvoker` and `MethodHandles.invoker` respectively. (The >> term "ge

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-26 Thread Rémi Forax
On Mon, 26 Oct 2020 16:34:10 GMT, Paul Sandoz wrote: >> The direct use of the enum ordinal is because HotSpot accessing it from the >> enum value is (or was) not optimal in C2. >> >> You can avoid the addition of the stable array by doing the following: >> >> public final MethodType acces

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-26 Thread Paul Sandoz
On Mon, 26 Oct 2020 16:13:59 GMT, Paul Sandoz wrote: >> I've updated the javadoc, and added two benchmarks that show the existing >> discrepancy between an exact and a generic use of a VarHandle, as well as >> showing that an exact VarHandle is as fast as a generic VarHandle for an >> exact in

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-26 Thread Paul Sandoz
On Mon, 26 Oct 2020 13:37:58 GMT, Jorn Vernee wrote: >> @PaulSandoz I've implemented your suggestion, by moving the `exact` flag to >> VarHandle itself. FWIW, the VH::accessModeType method took an AccessMode >> value as an argument, and the AccessDescriptor only stored the ordinal, so I >> add

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-26 Thread Jorn Vernee
On Fri, 23 Oct 2020 23:58:29 GMT, Jorn Vernee wrote: >> @PaulSandoz Thanks. I initially tested this with memory access VarHandles, >> which don't erase the receiver type. e.g. >> >> MemoryLayout layout = MemoryLayout.ofSequence(10, JAVA_INT); >> VarHandle vh = layout.varHandle(int.class, >> Me

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v6]

2020-10-26 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v5]

2020-10-26 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v4]

2020-10-24 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-23 Thread Jorn Vernee
On Fri, 23 Oct 2020 21:38:16 GMT, Jorn Vernee wrote: >> This approach does not work for reference types, since they are erased to >> `Object`, and then exact checking will be performed on the erased reference >> types. >> >> For example try this: >> >> import java.lang.invoke.MethodHandles; >

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v3]

2020-10-23 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-23 Thread Jorn Vernee
On Fri, 23 Oct 2020 20:41:31 GMT, Paul Sandoz wrote: >> Jorn Vernee has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Make internalName helper method static > > This approach does not work for reference types, since they are erased to > `

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-23 Thread Paul Sandoz
On Fri, 23 Oct 2020 18:06:51 GMT, Jorn Vernee wrote: >> Hi, >> >> This patch adds an asExact() combinator to VarHandle, that will return a new >> VarHandle that performs exact type checks, similar to >> MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, >> which can

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-23 Thread Jorn Vernee
On Fri, 23 Oct 2020 18:02:11 GMT, Rémi Forax wrote: >> Jorn Vernee has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Make internalName helper method static > > src/java.base/share/classes/java/lang/invoke/MemoryAccessVarHandleGenerator.ja

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-23 Thread Rémi Forax
On Fri, 23 Oct 2020 18:04:11 GMT, Jorn Vernee wrote: >> Hi, >> >> This patch adds an asExact() combinator to VarHandle, that will return a new >> VarHandle that performs exact type checks, similar to >> MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, >> which can

Re: RFR: 8254354: Add an asExact() VarHandle combinator [v2]

2020-10-23 Thread Jorn Vernee
> Hi, > > This patch adds an asExact() combinator to VarHandle, that will return a new > VarHandle that performs exact type checks, similar to > MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, > which can lead to performance degradation. > > This is implemented usi