src/java.base/share/classes/java/lang/invoke/Invokers.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
jdk Cdiff src/java.base/share/classes/java/lang/invoke/Invokers.java
src/java.base/share/classes/java/lang/invoke/Invokers.java
Print this page
rev 11258 : 8069591: Customize LambdaForms which are invoked using MH.invoke/invokeExact
Reviewed-by: ?
*** 245,254 ****
--- 245,255 ----
final int OUTARG_LIMIT = ARG_BASE + mtype.parameterCount();
final int INARG_LIMIT = OUTARG_LIMIT + (isLinker && !customized ? 1 : 0);
int nameCursor = OUTARG_LIMIT;
final int MTYPE_ARG = customized ? -1 : nameCursor++; // might be last in-argument
final int CHECK_TYPE = nameCursor++;
+ final int CHECK_CUSTOM = (CUSTOMIZE_THRESHOLD >= 0) ? nameCursor++ : -1;
final int LINKER_CALL = nameCursor++;
MethodType invokerFormType = mtype.invokerType();
if (isLinker) {
if (!customized)
invokerFormType = invokerFormType.appendParameterTypes(MemberName.class);
*** 277,286 ****
--- 278,290 ----
} else {
names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], mtypeArg);
// mh.invokeGeneric(a*):R => checkGenericType(mh, TYPEOF(a*:R)).invokeBasic(a*)
outArgs[0] = names[CHECK_TYPE];
}
+ if (CHECK_CUSTOM != -1) {
+ names[CHECK_CUSTOM] = new Name(NF_checkCustomized, names[CALL_MH]);
+ }
names[LINKER_CALL] = new Name(outCallType, outArgs);
lform = new LambdaForm(debugName, INARG_LIMIT, names);
if (isLinker)
lform.compileToBytecode(); // JVM needs a real methodOop
if (isCached)
*** 384,407 ****
@ForceInline
Object getCallSiteTarget(Object site) {
return ((CallSite)site).getTarget();
}
// Local constant functions:
private static final NamedFunction
NF_checkExactType,
NF_checkGenericType,
! NF_getCallSiteTarget;
static {
try {
NamedFunction nfs[] = {
NF_checkExactType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkExactType", Object.class, Object.class)),
NF_checkGenericType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkGenericType", Object.class, Object.class)),
NF_getCallSiteTarget = new NamedFunction(Invokers.class
! .getDeclaredMethod("getCallSiteTarget", Object.class))
};
for (NamedFunction nf : nfs) {
// Each nf must be statically invocable or we get tied up in our bootstraps.
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf.member)) : nf;
nf.resolve();
--- 388,432 ----
@ForceInline
Object getCallSiteTarget(Object site) {
return ((CallSite)site).getTarget();
}
+ /*non-public*/ static
+ @ForceInline
+ void checkCustomized(MethodHandle mh) {
+ if (mh.form.customized == null) {
+ maybeCustomize(mh);
+ }
+ }
+
+ /*non-public*/ static
+ @DontInline
+ void maybeCustomize(MethodHandle mh) {
+ if (mh.customizationCount >= CUSTOMIZE_THRESHOLD) {
+ mh.customize();
+ } else {
+ mh.customizationCount += 1;
+ }
+ }
+
// Local constant functions:
private static final NamedFunction
NF_checkExactType,
NF_checkGenericType,
! NF_getCallSiteTarget,
! NF_checkCustomized;
static {
try {
NamedFunction nfs[] = {
NF_checkExactType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkExactType", Object.class, Object.class)),
NF_checkGenericType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkGenericType", Object.class, Object.class)),
NF_getCallSiteTarget = new NamedFunction(Invokers.class
! .getDeclaredMethod("getCallSiteTarget", Object.class)),
! NF_checkCustomized = new NamedFunction(Invokers.class
! .getDeclaredMethod("checkCustomized", MethodHandle.class))
};
for (NamedFunction nf : nfs) {
// Each nf must be statically invocable or we get tied up in our bootstraps.
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf.member)) : nf;
nf.resolve();
src/java.base/share/classes/java/lang/invoke/Invokers.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File