Search in sources :

Example 6 with VirtualObject

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

the class FrameInfoVerifier method countVirtualObjects.

private static void countVirtualObjects(JavaValue[] values, BitSet visitedVirtualObjects) {
    for (JavaValue value : values) {
        if (value instanceof VirtualObject) {
            VirtualObject virtualObject = (VirtualObject) value;
            if (!visitedVirtualObjects.get(virtualObject.getId())) {
                visitedVirtualObjects.set(virtualObject.getId());
                countVirtualObjects(virtualObject.getValues(), visitedVirtualObjects);
            }
        }
    }
}
Also used : VirtualObject(jdk.vm.ci.code.VirtualObject) JavaValue(jdk.vm.ci.meta.JavaValue)

Example 7 with VirtualObject

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

the class JVMCIInfopointErrorTest method testUnexpectedVirtualObject.

@Test(expected = JVMCIError.class)
public void testUnexpectedVirtualObject() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o = VirtualObject.get(obj, 0);
        o.setValues(new JavaValue[0], new JavaKind[0]);
        LIRFrameState newState = modifyTopFrame(state, new VirtualObject[] { o }, new JavaValue[] { o }, new JavaKind[] { JavaKind.Int }, 1, 0, 0);
        safepoint.accept(newState);
    });
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) VirtualObject(jdk.vm.ci.code.VirtualObject) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 8 with VirtualObject

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

the class FrameInfoVerifier method makeValueInfo.

private ValueInfo makeValueInfo(FrameData data, JavaKind kind, JavaValue value) {
    ValueInfo result = new ValueInfo();
    result.kind = kind;
    if (ValueUtil.isIllegalJavaValue(value)) {
        result.type = ValueType.Illegal;
        assert result.kind == JavaKind.Illegal;
    } else if (value instanceof StackSlot) {
        StackSlot stackSlot = (StackSlot) value;
        result.type = ValueType.StackSlot;
        result.data = stackSlot.getOffset(data.totalFrameSize);
        result.isCompressedReference = isCompressedReference(stackSlot);
        ImageSingletons.lookup(Counters.class).stackValueCount.inc();
    } else if (value instanceof JavaConstant) {
        JavaConstant constant = (JavaConstant) value;
        result.value = constant;
        if (constant.isDefaultForKind()) {
            result.type = ValueType.DefaultConstant;
        } else {
            result.type = ValueType.Constant;
            if (constant.getJavaKind() == JavaKind.Object) {
                /*
                     * Collect all Object constants, which will be stored in a separate Object[]
                     * array so that the GC can visit them.
                     */
                objectConstants.addObject(constant);
            }
        }
        ImageSingletons.lookup(Counters.class).constantValueCount.inc();
    } else if (ValueUtil.isVirtualObject(value)) {
        VirtualObject virtualObject = (VirtualObject) value;
        result.type = ValueType.VirtualObject;
        result.data = virtualObject.getId();
        makeVirtualObject(data, virtualObject);
    } else {
        throw shouldNotReachHere();
    }
    return result;
}
Also used : VirtualObject(jdk.vm.ci.code.VirtualObject) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) StackSlot(jdk.vm.ci.code.StackSlot) Counters(com.oracle.svm.core.code.CodeInfoEncoder.Counters) JavaConstant(jdk.vm.ci.meta.JavaConstant)

Example 9 with VirtualObject

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

the class DebugInfoBuilder method toJavaValue.

protected JavaValue toJavaValue(ValueNode value) {
    try {
        if (value instanceof VirtualObjectNode) {
            VirtualObjectNode obj = (VirtualObjectNode) value;
            EscapeObjectState state = objectStates.get(obj);
            if (state == null && obj.entryCount() > 0) {
                // null states occur for objects with 0 fields
                throw new GraalError("no mapping found for virtual object %s", obj);
            }
            if (state instanceof MaterializedObjectState) {
                return toJavaValue(((MaterializedObjectState) state).materializedValue());
            } else {
                assert obj.entryCount() == 0 || state instanceof VirtualObjectState;
                VirtualObject vobject = virtualObjects.get(obj);
                if (vobject == null) {
                    vobject = VirtualObject.get(obj.type(), virtualObjects.size());
                    virtualObjects.put(obj, vobject);
                    pendingVirtualObjects.add(obj);
                }
                STATE_VIRTUAL_OBJECTS.increment(debug);
                return vobject;
            }
        } else {
            // Remove proxies from constants so the constant can be directly embedded.
            ValueNode unproxied = GraphUtil.unproxify(value);
            if (unproxied instanceof ConstantNode) {
                STATE_CONSTANTS.increment(debug);
                return unproxied.asJavaConstant();
            } else if (value != null) {
                STATE_VARIABLES.increment(debug);
                Value operand = nodeValueMap.operand(value);
                if (operand instanceof ConstantValue && ((ConstantValue) operand).isJavaConstant()) {
                    return ((ConstantValue) operand).getJavaConstant();
                } else {
                    assert operand instanceof Variable : operand + " for " + value;
                    return (JavaValue) operand;
                }
            } else {
                // return a dummy value because real value not needed
                STATE_ILLEGALS.increment(debug);
                return Value.ILLEGAL;
            }
        }
    } catch (GraalError e) {
        throw e.addContext("toValue: ", value);
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Variable(org.graalvm.compiler.lir.Variable) GraalError(org.graalvm.compiler.debug.GraalError) VirtualObjectState(org.graalvm.compiler.virtual.nodes.VirtualObjectState) VirtualObject(jdk.vm.ci.code.VirtualObject) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaValue(jdk.vm.ci.meta.JavaValue) ConstantValue(org.graalvm.compiler.lir.ConstantValue) Value(jdk.vm.ci.meta.Value) MaterializedObjectState(org.graalvm.compiler.virtual.nodes.MaterializedObjectState) ConstantValue(org.graalvm.compiler.lir.ConstantValue) EscapeObjectState(org.graalvm.compiler.nodes.virtual.EscapeObjectState)

Example 10 with VirtualObject

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

VirtualObject (jdk.vm.ci.code.VirtualObject)10 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)5 JavaValue (jdk.vm.ci.meta.JavaValue)4 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)4 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)4 Test (org.junit.Test)4 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)2 EscapeObjectState (org.graalvm.compiler.nodes.virtual.EscapeObjectState)2 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)2 MaterializedObjectState (org.graalvm.compiler.virtual.nodes.MaterializedObjectState)2 VirtualObjectState (org.graalvm.compiler.virtual.nodes.VirtualObjectState)2 Counters (com.oracle.svm.core.code.CodeInfoEncoder.Counters)1 ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)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