Search in sources :

Example 6 with BytecodeFrame

use of jdk.vm.ci.code.BytecodeFrame in project graal by oracle.

the class CompileQueue method verifyDeoptTarget.

private static boolean verifyDeoptTarget(HostedMethod method, CompilationResult result) {
    Map<Long, BytecodeFrame> encodedBciMap = new HashMap<>();
    /*
         * All deopt targets must have a graph.
         */
    assert method.compilationInfo.graph != null : "Deopt target must have a graph.";
    /*
         * No deopt targets can have a StackValueNode in the graph.
         */
    assert method.compilationInfo.graph.getNodes(StackValueNode.TYPE).isEmpty() : "No stack value nodes must be present in deopt target.";
    for (Infopoint infopoint : result.getInfopoints()) {
        if (infopoint.debugInfo != null) {
            DebugInfo debugInfo = infopoint.debugInfo;
            if (!debugInfo.hasFrame()) {
                continue;
            }
            BytecodeFrame topFrame = debugInfo.frame();
            BytecodeFrame rootFrame = topFrame;
            while (rootFrame.caller() != null) {
                rootFrame = rootFrame.caller();
            }
            assert rootFrame.getMethod().equals(method);
            boolean isDeoptEntry = method.compilationInfo.isDeoptEntry(rootFrame.getBCI(), rootFrame.duringCall, rootFrame.rethrowException);
            if (infopoint instanceof DeoptEntryInfopoint) {
                assert isDeoptEntry;
            } else if (rootFrame.duringCall && isDeoptEntry) {
                assert infopoint instanceof Call || isSingleSteppingInfopoint(infopoint);
            } else {
                continue;
            }
            long encodedBci = FrameInfoEncoder.encodeBci(rootFrame.getBCI(), rootFrame.duringCall, rootFrame.rethrowException);
            if (encodedBciMap.containsKey(encodedBci)) {
                assert encodedBciMap.get(encodedBci).equals(rootFrame) : "duplicate encoded bci " + encodedBci + " in deopt target " + method + " with different debug info:\n\n" + rootFrame + "\n\n" + encodedBciMap.get(encodedBci);
            }
            encodedBciMap.put(encodedBci, rootFrame);
        }
    }
    return true;
}
Also used : Call(jdk.vm.ci.code.site.Call) BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) DebugInfo(jdk.vm.ci.code.DebugInfo)

Example 7 with BytecodeFrame

use of jdk.vm.ci.code.BytecodeFrame in project graal by oracle.

the class HotSpotDebugInfoBuilder method computeFrameForState.

@Override
protected BytecodeFrame computeFrameForState(FrameState state) {
    if (isPlaceholderBci(state.bci) && state.bci != BytecodeFrame.BEFORE_BCI) {
        raiseInvalidFrameStateError(state);
    }
    BytecodeFrame result = super.computeFrameForState(state);
    maxInterpreterFrameSize = Math.max(maxInterpreterFrameSize, codeCacheProvider.interpreterFrameSize(result));
    return result;
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame)

Example 8 with BytecodeFrame

use of jdk.vm.ci.code.BytecodeFrame in project graal by oracle.

the class JVMCIInfopointErrorTest method modifyTopFrame.

private static LIRFrameState modifyTopFrame(LIRFrameState state, VirtualObject[] vobj, JavaValue[] values, JavaKind[] slotKinds, int locals, int stack, int locks) {
    BytecodeFrame top = state.topFrame;
    top = new BytecodeFrame(top.caller(), top.getMethod(), top.getBCI(), top.rethrowException, top.duringCall, values, slotKinds, locals, stack, locks);
    return new LIRFrameState(top, vobj, state.exceptionEdge);
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) BytecodeFrame(jdk.vm.ci.code.BytecodeFrame)

Example 9 with BytecodeFrame

use of jdk.vm.ci.code.BytecodeFrame in project graal by oracle.

the class FrameInfoVerifier method addDebugInfo.

protected FrameData addDebugInfo(ResolvedJavaMethod method, Infopoint infopoint, int totalFrameSize) {
    final boolean shouldIncludeMethod = customization.shouldInclude(method, infopoint);
    final boolean encodeSourceReferences = FrameInfoDecoder.encodeSourceReferences();
    if (!shouldIncludeMethod && !encodeSourceReferences) {
        return null;
    }
    final DebugInfo debugInfo = infopoint.debugInfo;
    final FrameData data = new FrameData();
    data.debugInfo = debugInfo;
    data.totalFrameSize = totalFrameSize;
    data.virtualObjects = new ValueInfo[countVirtualObjects(debugInfo)][];
    data.frame = addFrame(data, debugInfo.frame(), customization.isDeoptEntry(method, infopoint), shouldIncludeMethod);
    final boolean encodeDebugNames = shouldIncludeMethod && FrameInfoDecoder.encodeDebugNames();
    if (encodeDebugNames || FrameInfoDecoder.encodeSourceReferences()) {
        BytecodeFrame bytecodeFrame = data.debugInfo.frame();
        for (FrameInfoQueryResult resultFrame = data.frame; bytecodeFrame != null; resultFrame = resultFrame.caller) {
            customization.fillDebugNames(bytecodeFrame, resultFrame, encodeDebugNames && shouldIncludeMethod);
            bytecodeFrame = bytecodeFrame.caller();
        }
        for (FrameInfoQueryResult cur = data.frame; cur != null; cur = cur.caller) {
            sourceClassNames.addObject(cur.sourceClassName);
            sourceMethodNames.addObject(cur.sourceMethodName);
            sourceFileNames.addObject(cur.sourceFileName);
            if (encodeDebugNames) {
                for (ValueInfo valueInfo : cur.valueInfos) {
                    if (valueInfo.name == null) {
                        valueInfo.name = "";
                    }
                    names.addObject(valueInfo.name);
                }
            }
        }
    }
    allDebugInfos.add(data);
    return data;
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) DebugInfo(jdk.vm.ci.code.DebugInfo)

Example 10 with BytecodeFrame

use of jdk.vm.ci.code.BytecodeFrame in project graal by oracle.

the class CompilationPrinter method debugInfoToString.

/**
 * Formats given debug info as a multi line string.
 */
protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, IndexedValueMap liveBasePointers, RegisterSaveLayout calleeSaveInfo) {
    StringBuilder sb = new StringBuilder();
    if (refMap != null) {
        sb.append("reference-map: ");
        sb.append(refMap.toString());
        sb.append("\n");
    }
    if (liveBasePointers != null) {
        sb.append("live-base-pointers: ");
        sb.append(liveBasePointers);
        sb.append("\n");
    }
    if (calleeSaveInfo != null) {
        sb.append("callee-save-info:");
        for (Map.Entry<Register, Integer> e : calleeSaveInfo.registersToSlots(true).entrySet()) {
            sb.append(" " + e.getKey() + " -> s" + e.getValue());
        }
        sb.append("\n");
    }
    if (codePos != null) {
        BytecodePosition curCodePos = codePos;
        List<VirtualObject> virtualObjects = new ArrayList<>();
        do {
            sb.append(MetaUtil.toLocation(curCodePos.getMethod(), curCodePos.getBCI()));
            sb.append('\n');
            if (curCodePos instanceof BytecodeFrame) {
                BytecodeFrame frame = (BytecodeFrame) curCodePos;
                if (frame.numStack > 0) {
                    sb.append("stack: ");
                    for (int i = 0; i < frame.numStack; i++) {
                        sb.append(valueToString(frame.getStackValue(i), virtualObjects)).append(' ');
                    }
                    sb.append("\n");
                }
                sb.append("locals: ");
                for (int i = 0; i < frame.numLocals; i++) {
                    sb.append(valueToString(frame.getLocalValue(i), virtualObjects)).append(' ');
                }
                sb.append("\n");
                if (frame.numLocks > 0) {
                    sb.append("locks: ");
                    for (int i = 0; i < frame.numLocks; ++i) {
                        sb.append(valueToString(frame.getLockValue(i), virtualObjects)).append(' ');
                    }
                    sb.append("\n");
                }
            }
            curCodePos = curCodePos.getCaller();
        } while (curCodePos != null);
        for (int i = 0; i < virtualObjects.size(); i++) {
            VirtualObject obj = virtualObjects.get(i);
            sb.append(obj).append(" ").append(obj.getType().getName()).append(" ");
            for (int j = 0; j < obj.getValues().length; j++) {
                sb.append(valueToString(obj.getValues()[j], virtualObjects)).append(' ');
            }
            sb.append("\n");
        }
    }
    return sb.toString();
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) BytecodePosition(jdk.vm.ci.code.BytecodePosition) Register(jdk.vm.ci.code.Register) VirtualObject(jdk.vm.ci.code.VirtualObject) ArrayList(java.util.ArrayList) ReferenceMap(jdk.vm.ci.code.ReferenceMap) IndexedValueMap(org.graalvm.compiler.lir.util.IndexedValueMap) Map(java.util.Map)

Aggregations

BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)10 JavaValue (jdk.vm.ci.meta.JavaValue)3 HashMap (java.util.HashMap)2 DebugInfo (jdk.vm.ci.code.DebugInfo)2 VirtualObject (jdk.vm.ci.code.VirtualObject)2 Call (jdk.vm.ci.code.site.Call)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 JavaKind (jdk.vm.ci.meta.JavaKind)2 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)2 ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)1 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)1 DeoptEntryOp (com.oracle.svm.core.graal.lir.DeoptEntryOp)1 SubstrateReferenceMap (com.oracle.svm.core.heap.SubstrateReferenceMap)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 BytecodePosition (jdk.vm.ci.code.BytecodePosition)1 ReferenceMap (jdk.vm.ci.code.ReferenceMap)1 Register (jdk.vm.ci.code.Register)1 StackLockValue (jdk.vm.ci.code.StackLockValue)1