couple questions on method handle combinators

Roland Westrelin rwestrel at
Fri Jun 9 16:03:02 UTC 2017

I've been playing with method handle combinators and value types. Here
are 2 tests that I put together:

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

test78() attempts to build a loop whose result is a value type but
creation of the loop combinator fails with:

        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.base/java.lang.reflect.Method.invoke(
        at com.sun.javatest.regtest.agent.MainWrapper$
        at java.base/
Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: compiler.valhalla.valuetypes.My
        at java.base/java.lang.invoke.MethodHandles.makeIdentity(
        at java.base/java.lang.invoke.MethodHandles.identity(
        at java.base/java.lang.invoke.MethodHandles.countedLoop(
        at java.base/java.lang.invoke.MethodHandles.countedLoop(
        at compiler.valhalla.valuetypes.ValueTypeTestBench.<clinit>(
        ... 6 more
Caused by: java.lang.ClassNotFoundException: compiler.valhalla.valuetypes.My
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
        at java.base/java.lang.ClassLoader.loadClass(
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(
        at java.base/valhalla.shady.MinimalValueTypes_1_0.getValueCapableClass(
        at java.base/java.lang.invoke.MethodHandles.makeIdentity(
        ... 10 more

Anyone has any idea how to build the loop combinator?


More information about the valhalla-dev mailing list