Search in sources :

Example 1 with BytecodeStream

use of com.oracle.truffle.espresso.bytecode.BytecodeStream in project graal by oracle.

the class ClassRedefinition method isObsolete.

private static boolean isObsolete(ParserMethod oldMethod, ParserMethod newMethod, ConstantPool oldPool, ConstantPool newPool) {
    CodeAttribute oldCodeAttribute = (CodeAttribute) oldMethod.getAttribute(Symbol.Name.Code);
    CodeAttribute newCodeAttribute = (CodeAttribute) newMethod.getAttribute(Symbol.Name.Code);
    if (oldCodeAttribute == null) {
        return newCodeAttribute != null;
    } else if (newCodeAttribute == null) {
        return oldCodeAttribute != null;
    }
    BytecodeStream oldCode = new BytecodeStream(oldCodeAttribute.getOriginalCode());
    BytecodeStream newCode = new BytecodeStream(newCodeAttribute.getOriginalCode());
    return !isSame(oldCode, oldPool, newCode, newPool);
}
Also used : CodeAttribute(com.oracle.truffle.espresso.classfile.attributes.CodeAttribute) BytecodeStream(com.oracle.truffle.espresso.bytecode.BytecodeStream)

Example 2 with BytecodeStream

use of com.oracle.truffle.espresso.bytecode.BytecodeStream in project graal by oracle.

the class JDWPContextImpl method getNextBCI.

@Override
public int getNextBCI(RootNode callerRoot, Frame frame) {
    if (callerRoot instanceof EspressoRootNode) {
        EspressoRootNode espressoRootNode = (EspressoRootNode) callerRoot;
        int bci = (int) readBCIFromFrame(callerRoot, frame);
        if (bci != -1) {
            BytecodeStream bs = new BytecodeStream(espressoRootNode.getMethodVersion().getOriginalCode());
            return bs.nextBCI(bci);
        }
    }
    return -1;
}
Also used : BytecodeStream(com.oracle.truffle.espresso.bytecode.BytecodeStream) EspressoRootNode(com.oracle.truffle.espresso.nodes.EspressoRootNode)

Example 3 with BytecodeStream

use of com.oracle.truffle.espresso.bytecode.BytecodeStream in project graal by oracle.

the class BytecodeNode method trivialBytecodes.

private boolean trivialBytecodes() {
    if (getMethod().isSynchronized()) {
        return false;
    }
    byte[] originalCode = getMethodVersion().getOriginalCode();
    /*
         * originalCode.length < TrivialMethodSize is checked in the constructor because this method
         * is called from a compiler thread where the context is not accessible.
         */
    BytecodeStream stream = new BytecodeStream(originalCode);
    for (int bci = 0; bci < stream.endBCI(); bci = stream.nextBCI(bci)) {
        int bc = stream.currentBC(bci);
        // Trivial methods should be leaves.
        if (Bytecodes.isInvoke(bc)) {
            return false;
        }
        if (Bytecodes.LOOKUPSWITCH == bc || Bytecodes.TABLESWITCH == bc) {
            return false;
        }
        if (Bytecodes.MONITORENTER == bc || Bytecodes.MONITOREXIT == bc) {
            return false;
        }
        if (Bytecodes.ANEWARRAY == bc || MULTIANEWARRAY == bc) {
            // allowed in trivial methods.
            return false;
        }
        if (Bytecodes.isBranch(bc)) {
            int dest = stream.readBranchDest(bci);
            if (dest <= bci) {
                // Back-edge (probably a loop) but loops are not allowed in trivial methods.
                return false;
            }
        }
    }
    return true;
}
Also used : BytecodeStream(com.oracle.truffle.espresso.bytecode.BytecodeStream) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint)

Example 4 with BytecodeStream

use of com.oracle.truffle.espresso.bytecode.BytecodeStream in project graal by oracle.

the class BytecodeNode method getBaseQuickNode.

private BaseQuickNode getBaseQuickNode(int curBCI, int top, int statementIndex, BaseQuickNode quickNode) {
    // block while class redefinition is ongoing
    quickNode.getContext().getClassRedefinition().check();
    BaseQuickNode result = quickNode;
    synchronized (this) {
        // re-check if node was already replaced by another thread
        if (result != nodes[readCPI(curBCI)]) {
            // another thread beat us
            result = nodes[readCPI(curBCI)];
        } else {
            // other threads might still have beat us but if
            // so, the resolution failed and so will we below
            BytecodeStream original = new BytecodeStream(getMethodVersion().getCodeAttribute().getOriginalCode());
            char cpi = original.readCPI(curBCI);
            int nodeOpcode = original.currentBC(curBCI);
            Method resolutionSeed = resolveMethodNoCache(nodeOpcode, cpi);
            result = insert(dispatchQuickened(top, curBCI, cpi, nodeOpcode, statementIndex, resolutionSeed, getContext().InlineFieldAccessors));
            nodes[readCPI(curBCI)] = result;
        }
    }
    return result;
}
Also used : BytecodeStream(com.oracle.truffle.espresso.bytecode.BytecodeStream) BaseQuickNode(com.oracle.truffle.espresso.nodes.quick.BaseQuickNode) Method(com.oracle.truffle.espresso.impl.Method) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint)

Aggregations

BytecodeStream (com.oracle.truffle.espresso.bytecode.BytecodeStream)4 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)2 CodeAttribute (com.oracle.truffle.espresso.classfile.attributes.CodeAttribute)1 Method (com.oracle.truffle.espresso.impl.Method)1 EspressoRootNode (com.oracle.truffle.espresso.nodes.EspressoRootNode)1 BaseQuickNode (com.oracle.truffle.espresso.nodes.quick.BaseQuickNode)1