JDK-8155258 : VarHandle implementation improvements
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-04-27
  • Updated: 2016-05-27
  • Resolved: 2016-05-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b118Fixed
Related Reports
Relates :  
Description
A number of performance (space/time) improvements can be made to the current VarHandles implementation:

1) VarForm can hold erased method types for access mode methods. The non-erased method types held on VarHandle can be removed thus reducing footprint (such types can be created on-demand and cached if necessary)

2) VarHandle can create and cache, on-demand, invoker-based access mode MethodHandle on VarHandle.

3) Guard methods returning void can match a non-void returning access mode method with a corresponding cached, on-demand, erased void returning access mode method type.  The non-void returning member name can still be linked to as the VM will safely drop the return value. This means VH calls to compareAndExchange can drop the return type without any performance issue.

4) Guard methods can, when erased method types do not match, use the MethodHandle in 2) transformed, via MH.asType, using an invoker-based symbolic call site descriptor. Since the cached MethodHandle is used it will be a constant. There is still a performance hit for the non-constant asType transformed MH but there is also the performance hit for boxing/conversion, hence this path is not consider a priority compared to erased matched method types.

5) Static final VarForm instances can be directly held by each VarHandle implementation. This removes the need for ClassValue reducing dependencies and memory footprint.


For future consideration as follow on work:

1) All MemberName instances for access mode methods are calculated on static (or currently effectively static via ClassValue) initialization of a VarHandle implementation. Such instances can be calculated on-demand. A place holder constant value will be required to indicate unsupported access mode (or implementations should implement such modes throwing UOE).


Comments
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8155258-vhs-impl-improvements-jdk/webrev/ http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8155258-vhs-impl-improvements-hotspot/webrev/
27-04-2016