use of org.graalvm.compiler.nodes.graphbuilderconf.InvokeDynamicPlugin in project graal by oracle.
the class BytecodeParser method genDynamicInvokeHelper.
private boolean genDynamicInvokeHelper(ResolvedJavaMethod target, int cpi, int opcode) {
assert opcode == INVOKEDYNAMIC || opcode == INVOKEVIRTUAL;
InvokeDynamicPlugin invokeDynamicPlugin = graphBuilderConfig.getPlugins().getInvokeDynamicPlugin();
if (opcode == INVOKEVIRTUAL && invokeDynamicPlugin != null && !invokeDynamicPlugin.isResolvedDynamicInvoke(this, cpi, opcode)) {
// regular invokevirtual, let caller handle it
return false;
}
if (GeneratePIC.getValue(options) && (invokeDynamicPlugin == null || !invokeDynamicPlugin.supportsDynamicInvoke(this, cpi, opcode))) {
// bail out if static compiler and no dynamic type support
append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
return true;
}
JavaConstant appendix = constantPool.lookupAppendix(cpi, opcode);
ValueNode appendixNode = null;
if (appendix != null) {
if (invokeDynamicPlugin != null) {
invokeDynamicPlugin.recordDynamicMethod(this, cpi, opcode, target);
// Will perform runtime type checks and static initialization
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
appendixNode = invokeDynamicPlugin.genAppendixNode(this, cpi, opcode, appendix, stateBefore);
} else {
appendixNode = ConstantNode.forConstant(appendix, metaAccess, graph);
}
frameState.push(JavaKind.Object, appendixNode);
} else if (GeneratePIC.getValue(options)) {
// Need to emit runtime guard and perform static initialization.
// Not implemented yet.
append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
return true;
}
boolean hasReceiver = (opcode == INVOKEDYNAMIC) ? false : !target.isStatic();
ValueNode[] args = frameState.popArguments(target.getSignature().getParameterCount(hasReceiver));
if (hasReceiver) {
appendInvoke(InvokeKind.Virtual, target, args);
} else {
appendInvoke(InvokeKind.Static, target, args);
}
return true;
}
Aggregations