506 * if a big adapter BA can be pulled out of (MT0,MT1)
507 * => BA.invokeBasic(MT0,MH,a*)
508 * if a local adapter LA can cached on static CS0 = new GICS(MT0)
509 * => CS0.LA.invokeBasic(MH,a*)
510 * else
511 * => MH.asType(MT0).invokeBasic(A*)
512 */
513 }
514
515 static MemberName linkToCallSiteMethod(MethodType mtype) {
516 LambdaForm lform = callSiteForm(mtype, false);
517 return lform.vmentry;
518 }
519
520 static MemberName linkToTargetMethod(MethodType mtype) {
521 LambdaForm lform = callSiteForm(mtype, true);
522 return lform.vmentry;
523 }
524
525 // skipCallSite is true if we are optimizing a ConstantCallSite
526 private static LambdaForm callSiteForm(MethodType mtype, boolean skipCallSite) {
527 mtype = mtype.basicType(); // normalize Z to I, String to Object, etc.
528 final int which = (skipCallSite ? MethodTypeForm.LF_MH_LINKER : MethodTypeForm.LF_CS_LINKER);
529 LambdaForm lform = mtype.form().cachedLambdaForm(which);
530 if (lform != null) return lform;
531 // exactInvokerForm (Object,Object)Object
532 // link with java.lang.invoke.MethodHandle.invokeBasic(MethodHandle,Object,Object)Object/invokeSpecial
533 final int ARG_BASE = 0;
534 final int OUTARG_LIMIT = ARG_BASE + mtype.parameterCount();
535 final int INARG_LIMIT = OUTARG_LIMIT + 1;
536 int nameCursor = OUTARG_LIMIT;
537 final int APPENDIX_ARG = nameCursor++; // the last in-argument
538 final int CSITE_ARG = skipCallSite ? -1 : APPENDIX_ARG;
539 final int CALL_MH = skipCallSite ? APPENDIX_ARG : nameCursor++; // result of getTarget
540 final int LINKER_CALL = nameCursor++;
541 MethodType invokerFormType = mtype.appendParameterTypes(skipCallSite ? MethodHandle.class : CallSite.class);
542 Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType);
543 assert(names.length == nameCursor);
544 assert(names[APPENDIX_ARG] != null);
545 if (!skipCallSite)
546 names[CALL_MH] = new Name(getFunction(NF_getCallSiteTarget), names[CSITE_ARG]);
|
506 * if a big adapter BA can be pulled out of (MT0,MT1)
507 * => BA.invokeBasic(MT0,MH,a*)
508 * if a local adapter LA can cached on static CS0 = new GICS(MT0)
509 * => CS0.LA.invokeBasic(MH,a*)
510 * else
511 * => MH.asType(MT0).invokeBasic(A*)
512 */
513 }
514
515 static MemberName linkToCallSiteMethod(MethodType mtype) {
516 LambdaForm lform = callSiteForm(mtype, false);
517 return lform.vmentry;
518 }
519
520 static MemberName linkToTargetMethod(MethodType mtype) {
521 LambdaForm lform = callSiteForm(mtype, true);
522 return lform.vmentry;
523 }
524
525 // skipCallSite is true if we are optimizing a ConstantCallSite
526 static LambdaForm callSiteForm(MethodType mtype, boolean skipCallSite) {
527 mtype = mtype.basicType(); // normalize Z to I, String to Object, etc.
528 final int which = (skipCallSite ? MethodTypeForm.LF_MH_LINKER : MethodTypeForm.LF_CS_LINKER);
529 LambdaForm lform = mtype.form().cachedLambdaForm(which);
530 if (lform != null) return lform;
531 // exactInvokerForm (Object,Object)Object
532 // link with java.lang.invoke.MethodHandle.invokeBasic(MethodHandle,Object,Object)Object/invokeSpecial
533 final int ARG_BASE = 0;
534 final int OUTARG_LIMIT = ARG_BASE + mtype.parameterCount();
535 final int INARG_LIMIT = OUTARG_LIMIT + 1;
536 int nameCursor = OUTARG_LIMIT;
537 final int APPENDIX_ARG = nameCursor++; // the last in-argument
538 final int CSITE_ARG = skipCallSite ? -1 : APPENDIX_ARG;
539 final int CALL_MH = skipCallSite ? APPENDIX_ARG : nameCursor++; // result of getTarget
540 final int LINKER_CALL = nameCursor++;
541 MethodType invokerFormType = mtype.appendParameterTypes(skipCallSite ? MethodHandle.class : CallSite.class);
542 Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType);
543 assert(names.length == nameCursor);
544 assert(names[APPENDIX_ARG] != null);
545 if (!skipCallSite)
546 names[CALL_MH] = new Name(getFunction(NF_getCallSiteTarget), names[CSITE_ARG]);
|