Search in sources :

Example 1 with VirtualObject

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

the class HotSpotDebugInfoBuilder method computeLockValue.

@Override
protected JavaValue computeLockValue(FrameState state, int lockIndex) {
    int lockDepth = lockIndex;
    if (state.outerFrameState() != null) {
        lockDepth += state.outerFrameState().nestedLockDepth();
    }
    VirtualStackSlot slot = lockStack.makeLockSlot(lockDepth);
    ValueNode lock = state.lockAt(lockIndex);
    JavaValue object = toJavaValue(lock);
    boolean eliminated = object instanceof VirtualObject || state.monitorIdAt(lockIndex).isEliminated();
    assert state.monitorIdAt(lockIndex).getLockDepth() == lockDepth;
    return new StackLockValue(object, slot, eliminated);
}
Also used : VirtualObject(jdk.vm.ci.code.VirtualObject) JavaValue(jdk.vm.ci.meta.JavaValue) ValueNode(org.graalvm.compiler.nodes.ValueNode) StackLockValue(jdk.vm.ci.code.StackLockValue) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 2 with VirtualObject

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

the class DebugInfoBuilder method build.

public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) {
    assert virtualObjects.size() == 0;
    assert objectStates.size() == 0;
    assert pendingVirtualObjects.size() == 0;
    // collect all VirtualObjectField instances:
    FrameState current = topState;
    do {
        if (current.virtualObjectMappingCount() > 0) {
            for (EscapeObjectState state : current.virtualObjectMappings()) {
                if (!objectStates.containsKey(state.object())) {
                    if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) {
                        objectStates.put(state.object(), state);
                    }
                }
            }
        }
        current = current.outerFrameState();
    } while (current != null);
    BytecodeFrame frame = computeFrameForState(topState);
    VirtualObject[] virtualObjectsArray = null;
    if (virtualObjects.size() != 0) {
        // fill in the VirtualObject values
        VirtualObjectNode vobjNode;
        while ((vobjNode = pendingVirtualObjects.poll()) != null) {
            VirtualObject vobjValue = virtualObjects.get(vobjNode);
            assert vobjValue.getValues() == null;
            JavaValue[] values;
            JavaKind[] slotKinds;
            int entryCount = vobjNode.entryCount();
            if (entryCount == 0) {
                values = NO_JAVA_VALUES;
                slotKinds = NO_JAVA_KINDS;
            } else {
                values = new JavaValue[entryCount];
                slotKinds = new JavaKind[entryCount];
            }
            if (values.length > 0) {
                VirtualObjectState currentField = (VirtualObjectState) objectStates.get(vobjNode);
                assert currentField != null;
                int pos = 0;
                for (int i = 0; i < entryCount; i++) {
                    ValueNode value = currentField.values().get(i);
                    if (value == null) {
                        JavaKind entryKind = vobjNode.entryKind(i);
                        values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
                        slotKinds[pos] = entryKind.getStackKind();
                        pos++;
                    } else if (!value.isConstant() || value.asJavaConstant().getJavaKind() != JavaKind.Illegal) {
                        values[pos] = toJavaValue(value);
                        slotKinds[pos] = toSlotKind(value);
                        pos++;
                    } else {
                        assert value.getStackKind() == JavaKind.Illegal;
                        ValueNode previousValue = currentField.values().get(i - 1);
                        assert (previousValue != null && previousValue.getStackKind().needsTwoSlots()) : vobjNode + " " + i + " " + previousValue + " " + currentField.values().snapshot();
                        if (previousValue == null || !previousValue.getStackKind().needsTwoSlots()) {
                            // Don't allow the IllegalConstant to leak into the debug info
                            JavaKind entryKind = vobjNode.entryKind(i);
                            values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
                            slotKinds[pos] = entryKind.getStackKind();
                            pos++;
                        }
                    }
                }
                if (pos != entryCount) {
                    values = Arrays.copyOf(values, pos);
                    slotKinds = Arrays.copyOf(slotKinds, pos);
                }
            }
            assert checkValues(vobjValue.getType(), values, slotKinds);
            vobjValue.setValues(values, slotKinds);
        }
        virtualObjectsArray = new VirtualObject[virtualObjects.size()];
        int index = 0;
        for (VirtualObject value : virtualObjects.getValues()) {
            virtualObjectsArray[index++] = value;
        }
        virtualObjects.clear();
    }
    objectStates.clear();
    return newLIRFrameState(exceptionEdge, frame, virtualObjectsArray);
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) VirtualObjectState(org.graalvm.compiler.virtual.nodes.VirtualObjectState) JavaValue(jdk.vm.ci.meta.JavaValue) LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) FrameState(org.graalvm.compiler.nodes.FrameState) EscapeObjectState(org.graalvm.compiler.nodes.virtual.EscapeObjectState) BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) VirtualObject(jdk.vm.ci.code.VirtualObject) ValueNode(org.graalvm.compiler.nodes.ValueNode) MaterializedObjectState(org.graalvm.compiler.virtual.nodes.MaterializedObjectState) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 3 with VirtualObject

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

the class JVMCIInfopointErrorTest method testDuplicateVirtualObject.

@Test(expected = JVMCIError.class)
public void testDuplicateVirtualObject() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o1 = VirtualObject.get(obj, 0);
        o1.setValues(new JavaValue[0], new JavaKind[0]);
        VirtualObject o2 = VirtualObject.get(obj, 0);
        o2.setValues(new JavaValue[0], new JavaKind[0]);
        safepoint.accept(new LIRFrameState(state.topFrame, new VirtualObject[] { o1, o2 }, state.exceptionEdge));
    });
}
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 4 with VirtualObject

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

the class JVMCIInfopointErrorTest method testUndefinedVirtualObject.

@Test(expected = JVMCIError.class)
public void testUndefinedVirtualObject() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o0 = VirtualObject.get(obj, 0);
        o0.setValues(new JavaValue[0], new JavaKind[0]);
        VirtualObject o1 = VirtualObject.get(obj, 1);
        o1.setValues(new JavaValue[0], new JavaKind[0]);
        LIRFrameState newState = modifyTopFrame(state, new VirtualObject[] { o0 }, new JavaValue[] { o1 }, new JavaKind[] { JavaKind.Object }, 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 5 with VirtualObject

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

the class JVMCIInfopointErrorTest method testInvalidVirtualObjectId.

@Test(expected = JVMCIError.class)
public void testInvalidVirtualObjectId() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o = VirtualObject.get(obj, 5);
        o.setValues(new JavaValue[0], new JavaKind[0]);
        safepoint.accept(new LIRFrameState(state.topFrame, new VirtualObject[] { o }, state.exceptionEdge));
    });
}
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)

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