Search in sources :

Example 1 with InvokeDynamicPlugin

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;
}
Also used : InvokeDynamicPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvokeDynamicPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) FrameState(org.graalvm.compiler.nodes.FrameState)

Aggregations

JavaConstant (jdk.vm.ci.meta.JavaConstant)1 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)1 FrameState (org.graalvm.compiler.nodes.FrameState)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 InvokeDynamicPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvokeDynamicPlugin)1