couple questions on method handle combinators

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Jun 9 20:44:12 UTC 2017



On 09/06/17 17:03, Roland Westrelin wrote:
> I've been playing with method handle combinators and value types. Here
> are 2 tests that I put together:
>
> http://cr.openjdk.java.net/~roland/valhalla/combinators/webrev.00/
>
> but they don't do what I want.
>
> test77() runs fine but I noticed that if what test77_test() returns is
> not constant then, test77_target1() and test_target2() are not inlined:
>
>      876   82    b        compiler.valhalla.valuetypes.ValueTypeTestBench::test77 (8 bytes)
>                              @ 4   java.lang.invoke.LambdaForm$MH/1308244637::invokeExact_MT (36 bytes)   force inline by annotation
>                                @ 11   java.lang.invoke.Invokers::checkExactType (17 bytes)   force inline by annotation
>                                  @ 1   java.lang.invoke.MethodHandle::type (5 bytes)   accessor
>                                @ 21   java.lang.invoke.Invokers::checkCustomized (23 bytes)   force inline by annotation
>                                  @ 1   java.lang.invoke.MethodHandleImpl::isCompileConstant (2 bytes)   (intrinsic)
>                                @ 32   java.lang.invoke.LambdaForm$MH/597255128::guard (91 bytes)   force inline by annotation
>                                  @ 51   java.lang.invoke.LambdaForm$DMH/586617651::invokeVirtual (14 bytes)   force inline by annotation
>                                    @ 1   java.lang.invoke.DirectMethodHandle::internalMemberName (8 bytes)   force inline by annotation
>                                    @ 10   compiler.valhalla.valuetypes.ValueTypeTestBench::test77_test (5 bytes)   accessor
>                 !                @ 63   java.lang.invoke.MethodHandleImpl::profileBoolean (34 bytes)   (intrinsic)
>                                  @ 79   java.lang.invoke.MethodHandleImpl::selectAlternative (8 bytes)   inline (hot)
>                                  @ 87   java.lang.invoke.MethodHandle::invokeBasic(L)Qjava/lang/__Value; (0 bytes)   receiver not constant
>
> What I want is 2 inlined methods that return a value type and the 2
> return values go through a merge point before the method handle call
> returns. Anyone sees way to get that with guardWithTest or something
> else?
>
> test78() attempts to build a loop whose result is a value type but
> creation of the loop combinator fails with:
I'll look into that.

(I'll happily leave your other inlining questions to people more 
knowledgeable in that area).

Maurizio
>
> java.lang.ExceptionInInitializerError
>          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>          at java.base/java.lang.reflect.Method.invoke(Method.java:563)
>          at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
>          at java.base/java.lang.Thread.run(Thread.java:844)
> Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: compiler.valhalla.valuetypes.My
>          at java.base/java.lang.invoke.MethodHandles.makeIdentity(MethodHandles.java:3432)
>          at java.base/java.lang.invoke.MethodHandles.identity(MethodHandles.java:3363)
>          at java.base/java.lang.invoke.MethodHandles.countedLoop(MethodHandles.java:5524)
>          at java.base/java.lang.invoke.MethodHandles.countedLoop(MethodHandles.java:5389)
>          at compiler.valhalla.valuetypes.ValueTypeTestBench.<clinit>(ValueTypeTestBench.java:2314)
>          ... 6 more
> Caused by: java.lang.ClassNotFoundException: compiler.valhalla.valuetypes.My
>          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:553)
>          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
>          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:486)
>          at java.base/java.lang.Class.forName0(Native Method)
>          at java.base/java.lang.Class.forName(Class.java:374)
>          at java.base/valhalla.shady.MinimalValueTypes_1_0.getValueCapableClass(MinimalValueTypes_1_0.java:81)
>          at java.base/java.lang.invoke.MethodHandles.makeIdentity(MethodHandles.java:3430)
>          ... 10 more
>
> Anyone has any idea how to build the loop combinator?
>
> Roland.



More information about the valhalla-dev mailing list