src/java.base/share/classes/java/lang/invoke/Invokers.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/java.base/share/classes/java/lang/invoke/Invokers.java	Thu Jan 22 20:49:30 2015
--- new/src/java.base/share/classes/java/lang/invoke/Invokers.java	Thu Jan 22 20:49:30 2015

*** 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 **** --- 388,434 ---- @ForceInline Object getCallSiteTarget(Object site) { return ((CallSite)site).getTarget(); } + /*non-public*/ static + @ForceInline + void checkCustomized(Object o) { + MethodHandle mh = (MethodHandle)o; + if (mh.form.customized == null) { + maybeCustomize(mh); + } + } + + /*non-public*/ static + @DontInline + void maybeCustomize(MethodHandle mh) { + byte count = mh.customizationCount; + if (count >= CUSTOMIZE_THRESHOLD) { + mh.customize(); + } else { + mh.customizationCount = (byte)(count+1); + } + } + // Local constant functions: private static final NamedFunction NF_checkExactType, NF_checkGenericType, ! NF_getCallSiteTarget; ! 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", 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();

src/java.base/share/classes/java/lang/invoke/Invokers.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File