Search in sources :

Example 1 with ReferenceMap

use of jdk.vm.ci.code.ReferenceMap 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

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)1 BytecodePosition (jdk.vm.ci.code.BytecodePosition)1 ReferenceMap (jdk.vm.ci.code.ReferenceMap)1 Register (jdk.vm.ci.code.Register)1 VirtualObject (jdk.vm.ci.code.VirtualObject)1 IndexedValueMap (org.graalvm.compiler.lir.util.IndexedValueMap)1