private ValueEmitter appendArgumentWithRecipe(ValueEmitter sb, DynamicCallSite callSite) { String recipe = callSite.getBootstrapArguments().get(0).getString(); int charCount = recipe.length(); int constantIndex = 0; case VALUE_ARGUMENT: { sb = flushAcc(sb, acc); ValueType type = callSite.getCalledMethod().parameterType(paramIndex++); sb = appendArgument(sb, type, callSite.getArguments().get(valueIndex++)); break; ValueType type = callSite.getCalledMethod().parameterType(paramIndex++); RuntimeConstant poolConstant = callSite.getBootstrapArguments().get(1 + constantIndex++); sb = appendArgument(sb, type, constant(sb.getProgramEmitter(), poolConstant)); break;
private ValueEmitter appendSimpleArguments(ValueEmitter sb, DynamicCallSite callSite) { int parameterCount = callSite.getCalledMethod().parameterCount(); for (int i = 0; i < parameterCount; ++i) { sb = appendArgument(sb, callSite.getCalledMethod().parameterType(i), callSite.getArguments().get(i)); } return sb; }
@Override public ValueEmitter substitute(DynamicCallSite callSite, ProgramEmitter callerPe) { ValueType[] invokedType = callSite.getCalledMethod().getSignature(); ValueType[] samMethodType = callSite.getBootstrapArguments().get(0).getMethodType(); MethodHandle implMethod = callSite.getBootstrapArguments().get(1).getMethodHandle(); ValueType[] instantiatedMethodType = callSite.getBootstrapArguments().get(2).getMethodType(); String samName = ((ValueType.Object) callSite.getCalledMethod().getResultType()).getClassName(); ClassHierarchy hierarchy = callSite.getAgent().getClassHierarchy(); ClassReader samClass = hierarchy.getClassSource().get(samName); String key = callSite.getCaller().getClassName() + "$" + callSite.getCaller().getName(); ClassReaderSource classSource = callSite.getAgent().getClassSource(); ClassReader callerClass = classSource.get(callSite.getCaller().getClassName()); int id = 0; for (MethodReader callerMethod : callerClass.getMethods()) { if (callerMethod.getDescriptor().equals(callSite.getCaller().getDescriptor())) { break; int subId = lambdaIdsByMethod.getOrDefault(callSite.getCaller(), 0); ClassHolder implementor = new ClassHolder(key + "$lambda$_" + id + "_" + subId); lambdaIdsByMethod.put(callSite.getCaller(), subId + 1); int capturedVarCount = callSite.getCalledMethod().parameterCount(); MethodHolder ctor = createConstructor(hierarchy, implementor, Arrays.copyOfRange(invokedType, 0, capturedVarCount), callerPe.getCurrentLocation()); createBridge(hierarchy, implementor, callSite.getCalledMethod().getName(), instantiatedMethodType, samMethodType, callerPe.getCurrentLocation()); MethodHolder worker = new MethodHolder(callSite.getCalledMethod().getName(), instantiatedMethodType);
arguments.add(pe.var(indy.getArguments().get(k), indy.getMethod().parameterType(k))); DynamicCallSite callSite = new DynamicCallSite( methodDep.getReference(), indy.getMethod(), indy.getInstance() != null ? pe.var(indy.getInstance(),
@Override public ValueEmitter substitute(DynamicCallSite callSite, ProgramEmitter pe) { ValueEmitter sb = pe.construct(STRING_BUILDER); if (callSite.getBootstrapMethod().getName().equals("makeConcatWithConstants")) { appendArgumentWithRecipe(sb, callSite); } else { appendSimpleArguments(sb, callSite); } return sb.invokeSpecial("toString", ValueType.object("java.lang.String")); }
arguments.add(pe.var(indy.getArguments().get(k), indy.getMethod().parameterType(k))); DynamicCallSite callSite = new DynamicCallSite(indy.getMethod(), indy.getInstance() != null ? pe.var(indy.getInstance(), ValueType.object(methodDep.getMethod().getOwnerName())) : null,