RFR: 8164483: Generate field lambda forms at link time

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed Aug 24 11:02:18 UTC 2016


src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java

+    @ForceInline
+    /*non-public*/ static Unsafe unsafe() {
+        return UNSAFE;
+    }
+

+                    NF_unsafe = new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("unsafe"))

No need for an accessor method. InvokerBytecodeGenerator already 
supports static field getters/setters [1]. You have to provide proper 
NamedFunction for MethodHandleStatics.UNSAFE.

Regarding LambdaForm.Kind, IMO field accessors push enum approach to the 
limit. Let's think about better ways to represent LF shape in a 
structured manner, but I'm fine with keeping it for future cleanup.

Overall, looks good.

Best regards,
Vladimir Ivanov

[1] 
http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/496a116876a3/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java#l931

On 8/23/16 11:57 AM, Claes Redestad wrote:
> Hi,
>
> this patch adds link-time generation of the simplest field lambda forms.
> This avoid generating these forms during bootstrapping, which is
> commonly done early on in even the simplest startup tests.
>
> To make this work, injecting Unsafe as a constant replacement had to be
> replaced with a getter function, resulting in a few more bytecodes to do
> the same thing, but which after inlining should turn into equivalent
> code; performance testing indicate this change is performance neutral.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8164483
> Webrev: http://cr.openjdk.java.net/~redestad/8164483/webrev.01/
>
> Together with JDK-8164569 (which I've tested together with this) this
> removes all class generation from runtime in the tests associated with
> JDK-8086045
>
> Thanks!
>
> /Claes


More information about the core-libs-dev mailing list