< prev index next >

src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java

Print this page
rev 15353 : 8164044: Generate the corresponding BoundMethodHandle to all generated DirectMethodHandles
Reviewed-by: vlivanov, mhaupt

*** 36,45 **** --- 36,46 ---- import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.Objects; import static java.lang.invoke.LambdaForm.*; + import static java.lang.invoke.LambdaForm.Kind.*; import static java.lang.invoke.MethodHandleNatives.Constants.*; import static java.lang.invoke.MethodHandleStatics.UNSAFE; import static java.lang.invoke.MethodHandleStatics.newInternalError; import static java.lang.invoke.MethodTypeForm.*;
*** 187,204 **** } static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) { boolean needsInit = (which == LF_INVSTATIC_INIT); boolean doesAlloc = (which == LF_NEWINVSPECIAL); ! String linkerName, lambdaName; switch (which) { ! case LF_INVVIRTUAL: linkerName = "linkToVirtual"; lambdaName = "DMH.invokeVirtual"; break; ! case LF_INVSTATIC: linkerName = "linkToStatic"; lambdaName = "DMH.invokeStatic"; break; ! case LF_INVSTATIC_INIT:linkerName = "linkToStatic"; lambdaName = "DMH.invokeStaticInit"; break; ! case LF_INVSPECIAL: linkerName = "linkToSpecial"; lambdaName = "DMH.invokeSpecial"; break; ! case LF_INVINTERFACE: linkerName = "linkToInterface"; lambdaName = "DMH.invokeInterface"; break; ! case LF_NEWINVSPECIAL: linkerName = "linkToSpecial"; lambdaName = "DMH.newInvokeSpecial"; break; default: throw new InternalError("which="+which); } MethodType mtypeWithArg = mtype.appendParameterTypes(MemberName.class); if (doesAlloc) --- 188,206 ---- } static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) { boolean needsInit = (which == LF_INVSTATIC_INIT); boolean doesAlloc = (which == LF_NEWINVSPECIAL); ! String linkerName; ! LambdaForm.Kind kind; switch (which) { ! case LF_INVVIRTUAL: linkerName = "linkToVirtual"; kind = DIRECT_INVOKE_VIRTUAL; break; ! case LF_INVSTATIC: linkerName = "linkToStatic"; kind = DIRECT_INVOKE_STATIC; break; ! case LF_INVSTATIC_INIT:linkerName = "linkToStatic"; kind = DIRECT_INVOKE_STATIC_INIT; break; ! case LF_INVSPECIAL: linkerName = "linkToSpecial"; kind = DIRECT_INVOKE_SPECIAL; break; ! case LF_INVINTERFACE: linkerName = "linkToInterface"; kind = DIRECT_INVOKE_INTERFACE; break; ! case LF_NEWINVSPECIAL: linkerName = "linkToSpecial"; kind = DIRECT_NEW_INVOKE_SPECIAL; break; default: throw new InternalError("which="+which); } MethodType mtypeWithArg = mtype.appendParameterTypes(MemberName.class); if (doesAlloc)
*** 238,252 **** System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2); outArgs[0] = names[NEW_OBJ]; result = NEW_OBJ; } names[LINKER_CALL] = new Name(linker, outArgs); ! lambdaName += "_" + shortenSignature(basicTypeSignature(mtype)); ! LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result); // This is a tricky bit of code. Don't send it through the LF interpreter. ! lform.compileToBytecode(Holder.class); return lform; } static Object findDirectMethodHandle(Name name) { if (name.function == NF_internalMemberName || --- 240,254 ---- System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2); outArgs[0] = names[NEW_OBJ]; result = NEW_OBJ; } names[LINKER_CALL] = new Name(linker, outArgs); ! String lambdaName = kind.defaultLambdaName + "_" + shortenSignature(basicTypeSignature(mtype)); ! LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result, kind); // This is a tricky bit of code. Don't send it through the LF interpreter. ! lform.compileToBytecode(); return lform; } static Object findDirectMethodHandle(Name name) { if (name.function == NF_internalMemberName ||
*** 703,717 **** throw newInternalError(ex); } } static { ! // The DMH class will contain pre-generated DirectMethodHandles resolved // speculatively using MemberName.getFactory().resolveOrNull. However, that // doesn't initialize the class, which subtly breaks inlining etc. By forcing // initialization of the Holder class we avoid these issues. UNSAFE.ensureClassInitialized(Holder.class); } /* Placeholder class for DirectMethodHandles generated ahead of time */ ! private final class Holder {} } --- 705,719 ---- throw newInternalError(ex); } } static { ! // The Holder class will contain pre-generated DirectMethodHandles resolved // speculatively using MemberName.getFactory().resolveOrNull. However, that // doesn't initialize the class, which subtly breaks inlining etc. By forcing // initialization of the Holder class we avoid these issues. UNSAFE.ensureClassInitialized(Holder.class); } /* Placeholder class for DirectMethodHandles generated ahead of time */ ! final class Holder {} }
< prev index next >