Implementing VarHandle
MacGregor, Duncan (GE Energy Management)
duncan.macgregor at ge.com
Tue Apr 14 08:38:56 UTC 2015
On 12/04/2015 15:54, "Remi Forax" <forax at univ-mlv.fr> wrote:
>Hi guys,
>I was about to write a blog post explaining why i don't like the way
>VarHandle are currently implemented when it occurs to me that providing
>another implementation may be a more efficient to discuss about
>implementation.
>
>So my implementation is here,
> https://github.com/forax/varhandle2
>
>the API is typesafe, the implementation is runtime safe and i get mostly
>the same assembly code using unsafe or this VarHandle API.
>
>The idea is that there is no need to add more polymorphic signature
>methods, a good old Java method is enough if it using a method handle
>under the hood.
>All the logic is described using method handles and the only logic
>written in Java is
>1) when to create such method handle (the first time a method is called),
> it works like invokedynamic but the method handles are stable
>instead of being constant.
>2) how to link all things together to do nullcheck, atomic operation and
>post operation (like fence or sum).
Although I agree regarding the type safety of this being better than the
polymorphic signatures of the current VarHandle API, this doesn¹t feel
like it has the right shape. How would your API expand to handle user
defined value types? I think if we want something type safe then
specialisation over type variables would be a much better path forward for
this, assuming the two can be lined up in when they might be delivered
into the main JDK.
Regards, Duncan.
More information about the mlvm-dev
mailing list