8297728: Cache invocation type rather than invoker in NamedFunction

Reviewed-by: jvernee
This commit is contained in:
Claes Redestad 2022-11-30 20:53:56 +00:00
parent e9d501e442
commit 4485d4e517

View File

@ -1089,7 +1089,7 @@ class LambdaForm {
static class NamedFunction { static class NamedFunction {
final MemberName member; final MemberName member;
private @Stable MethodHandle resolvedHandle; private @Stable MethodHandle resolvedHandle;
@Stable MethodHandle invoker; private @Stable MethodType type;
NamedFunction(MethodHandle resolvedHandle) { NamedFunction(MethodHandle resolvedHandle) {
this(resolvedHandle.internalMemberName(), resolvedHandle); this(resolvedHandle.internalMemberName(), resolvedHandle);
@ -1185,10 +1185,6 @@ class LambdaForm {
Object rval; Object rval;
try { try {
traceInterpreter("[ call", this, arguments); traceInterpreter("[ call", this, arguments);
if (invoker == null) {
traceInterpreter("| getInvoker", this);
invoker();
}
// resolvedHandle might be uninitialized, ok for tracing // resolvedHandle might be uninitialized, ok for tracing
if (resolvedHandle == null) { if (resolvedHandle == null) {
traceInterpreter("| resolve", this); traceInterpreter("| resolve", this);
@ -1204,18 +1200,25 @@ class LambdaForm {
} }
private MethodHandle invoker() { private MethodHandle invoker() {
if (invoker != null) return invoker; return computeInvoker(methodType().form());
// Get an invoker and cache it.
return invoker = computeInvoker(methodType().form());
} }
MethodType methodType() { MethodType methodType() {
if (resolvedHandle != null) MethodType type = this.type;
if (type == null) {
this.type = type = calculateMethodType(member, resolvedHandle);
}
return type;
}
private static MethodType calculateMethodType(MemberName member, MethodHandle resolvedHandle) {
if (resolvedHandle != null) {
return resolvedHandle.type(); return resolvedHandle.type();
else } else {
// only for certain internal LFs during bootstrapping // only for certain internal LFs during bootstrapping
return member.getInvocationType(); return member.getInvocationType();
} }
}
MemberName member() { MemberName member() {
assert(assertMemberIsConsistent()); assert(assertMemberIsConsistent());