mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8050053: Improve caching of different invokers
Reviewed-by: vlivanov, psandoz
This commit is contained in:
parent
da56d3f6d1
commit
6a177f43fb
7 changed files with 168 additions and 140 deletions
|
@ -102,7 +102,7 @@ public class CallSite {
|
|||
*/
|
||||
/*package-private*/
|
||||
CallSite(MethodType type) {
|
||||
target = type.invokers().uninitializedCallSite();
|
||||
target = makeUninitializedCallSite(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,21 +217,34 @@ public class CallSite {
|
|||
}
|
||||
|
||||
private static final MethodHandle GET_TARGET;
|
||||
private static final MethodHandle THROW_UCS;
|
||||
static {
|
||||
try {
|
||||
GET_TARGET = IMPL_LOOKUP.
|
||||
findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
|
||||
THROW_UCS = IMPL_LOOKUP.
|
||||
findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Object.class, Object[].class));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw newInternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** This guy is rolled into the default target if a MethodType is supplied to the constructor. */
|
||||
/*package-private*/
|
||||
static Empty uninitializedCallSite() {
|
||||
private static Object uninitializedCallSite(Object... ignore) {
|
||||
throw new IllegalStateException("uninitialized call site");
|
||||
}
|
||||
|
||||
private MethodHandle makeUninitializedCallSite(MethodType targetType) {
|
||||
MethodType basicType = targetType.basicType();
|
||||
MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
|
||||
if (invoker == null) {
|
||||
invoker = THROW_UCS.asType(basicType);
|
||||
invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
|
||||
}
|
||||
// unchecked view is OK since no values will be received or returned
|
||||
return invoker.viewAsType(targetType);
|
||||
}
|
||||
|
||||
// unsafe stuff:
|
||||
private static final long TARGET_OFFSET;
|
||||
static {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue