FTR: heisenbox factory RFE filed
John Rose
john.r.rose at oracle.com
Wed Aug 3 21:41:19 UTC 2016
Following a suggestion by Rémi Forax:
experimental hook for creating heisenboxes
https://bugs.openjdk.java.net/browse/JDK-8163133
Description:
> We need a way to build "heisenboxes", which are value boxes with value-based semantics.
>
> Example API (using Unsafe as the carrier):
>
> Class boxType = Integer.class, valType = int.class;
> MethodHandle hFactory = Unsafe.findFeisenBoxConstructor(boxType);
> assert hFactory.type().equals( methodType(boxType, boxType) );
> MethodHandle boxer = identity(valType).asType(methodType(boxType, valType));
> MethodHandle hBoxer = filterReturnValue(boxer, hFactory);
>
> The boxes returned from a heisen-boxing function have suppressed equality semantics, allowing easier optimization (free from the need for escape analysis). In exchange, their identity semantics (as detected by op==/acmp and synchronization/monitorenter) are reduced, in a VM-dependent way.
>
> Typical reduced semantics: Synch. attempts cause an exception (IMSE), and pointer comparisons are guaranteed to return false if the boxed values differ, with no other guarantees.
>
> This feature will be experimental, so that we can try a range of reduced semantics.
More information about the valhalla-dev
mailing list