Search in sources :

Example 1 with InvokeDynamicCallSiteNode

use of com.oracle.truffle.espresso.nodes.quick.invoke.InvokeDynamicCallSiteNode in project graal by oracle.

the class BytecodeNode method quickenInvokeDynamic.

private int quickenInvokeDynamic(final VirtualFrame frame, int top, int curBCI, int opcode) {
    CompilerDirectives.transferToInterpreterAndInvalidate();
    assert (Bytecodes.INVOKEDYNAMIC == opcode);
    RuntimeConstantPool pool = getConstantPool();
    BaseQuickNode quick = null;
    int indyIndex = -1;
    synchronized (this) {
        if (bs.currentVolatileBC(curBCI) == QUICK) {
            // Check if someone did the job for us. Defer the call until we are out of the lock.
            quick = nodes[readCPI(curBCI)];
        } else {
            // fetch indy under lock.
            indyIndex = readCPI(curBCI);
        }
    }
    if (quick != null) {
        // Do invocation outside of the lock.
        return quick.execute(frame) - Bytecodes.stackEffectOf(opcode);
    }
    // Resolution should happen outside of the bytecode patching lock.
    InvokeDynamicConstant.CallSiteLink link = pool.linkInvokeDynamic(getMethod().getDeclaringKlass(), indyIndex);
    // re-lock to check if someone did the job for us, since this was a heavy operation.
    synchronized (this) {
        if (bs.currentVolatileBC(curBCI) == QUICK) {
            // someone beat us to it, just trust him.
            quick = nodes[readCPI(curBCI)];
        } else {
            quick = injectQuick(curBCI, new InvokeDynamicCallSiteNode(link.getMemberName(), link.getUnboxedAppendix(), link.getParsedSignature(), getMeta(), top, curBCI), QUICK);
        }
    }
    return quick.execute(frame) - Bytecodes.stackEffectOf(opcode);
}
Also used : RuntimeConstantPool(com.oracle.truffle.espresso.classfile.RuntimeConstantPool) BaseQuickNode(com.oracle.truffle.espresso.nodes.quick.BaseQuickNode) InvokeDynamicConstant(com.oracle.truffle.espresso.classfile.constantpool.InvokeDynamicConstant) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint) InvokeDynamicCallSiteNode(com.oracle.truffle.espresso.nodes.quick.invoke.InvokeDynamicCallSiteNode)

Aggregations

TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)1 RuntimeConstantPool (com.oracle.truffle.espresso.classfile.RuntimeConstantPool)1 InvokeDynamicConstant (com.oracle.truffle.espresso.classfile.constantpool.InvokeDynamicConstant)1 BaseQuickNode (com.oracle.truffle.espresso.nodes.quick.BaseQuickNode)1 InvokeDynamicCallSiteNode (com.oracle.truffle.espresso.nodes.quick.invoke.InvokeDynamicCallSiteNode)1