If a MemberName is constant, direct call is faster than linkTo* call.
Consider simple recursive call:
static void rec(int depth) throws Throwable {
if (depth > 0) {
recMH.invokeExact(depth-1);
} else {
return;
}
}
C2 -XX:+PrintCompilation:
jsr292.RecursiveCall::rec (18 bytes)
@ 10 java.lang.invoke.LambdaForm$MH/537548559::invokeExact_MT (16 bytes) force inline by annotation
@ 2 java.lang.invoke.Invokers::checkExactType (30 bytes) force inline by annotation
@ 11 java.lang.invoke.MethodHandle::type (5 bytes) accessor
@ 12 java.lang.invoke.LambdaForm$DMH/1617791695::invokeStatic_I_V (14 bytes) force inline by annotation
@ 1 java.lang.invoke.DirectMethodHandle::internalMemberName (8 bytes) force inline by annotation
@ 10 jsr292.RecursiveCall::rec (18 bytes) inline (hot)
@ 10 java.lang.invoke.LambdaForm$MH/537548559::invokeExact_MT (16 bytes) force inline by annotation
@ 2 java.lang.invoke.Invokers::checkExactType (30 bytes) force inline by annotation
@ 11 java.lang.invoke.MethodHandle::type (5 bytes) accessor
@ 12 java.lang.invoke.LambdaForm$DMH/1617791695::invokeStatic_I_V (14 bytes) force inline by annotation
@ 1 java.lang.invoke.DirectMethodHandle::internalMemberName (8 bytes) force inline by annotation
@ 10 jsr292.RecursiveCall::rec (18 bytes) recursive inlining is too deep
Non-inlined recursive call can be a direct call, but it is a ::linkToStatic call:
[...]
0x000000010feeabfe: movabs $0x79561d2a0,%rdx ; {oop(a 'java/lang/invoke/MemberName' = {method} {0x00000001180a3528} 'rec' '(I)V' in 'jsr292/RecursiveCall')}
0x000000010feeac08: nop
0x000000010feeac09: nop
0x000000010feeac0a: nop
0x000000010feeac0b: callq 0x000000010fe49900 ; OopMap{off=48}
;*invokestatic linkToStatic
; - java.lang.invoke.LambdaForm$DMH/1617791695::invokeStatic_I_V@10
; - java.lang.invoke.LambdaForm$MH/537548559::invokeExact_MT@12
; - jsr292.RecursiveCall::rec@10 (line 28)
; - java.lang.invoke.LambdaForm$DMH/1617791695::invokeStatic_I_V@10
; - java.lang.invoke.LambdaForm$MH/537548559::invokeExact_MT@12
; - jsr292.RecursiveCall::rec@10 (line 28)
; {static_call}
[...]
- relates to
-
JDK-8148994 Replacing MH::invokeBasic with a direct call breaks LF customization
-
- Resolved
-
-
JDK-8150436 Incorrect invocation mode when linkToInteface linker is eliminated
-
- Resolved
-
-
JDK-8145137 Incorrect call signature can be used in nmethod::preserve_callee_argument_oops
-
- Closed
-
-
JDK-8158639 C2 compilation fails with SIGSEGV
-
- Closed
-
-
JDK-8203480 IncompatibleClassChangeError thrown at sites linked to default interface methods
-
- Closed
-
-
JDK-8217760 C2: Missing symbolic info on a call from intrinsics when invoked through MethodHandle
-
- Closed
-