Search in sources :

Example 6 with JavaValue

use of jdk.vm.ci.meta.JavaValue 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 JavaValue

use of jdk.vm.ci.meta.JavaValue in project graal by oracle.

the class Instance method doState.

private void doState(DebugContext debug, FrameMap frameMap, LIRInstruction op, LIRFrameState state) {
    SubstrateReferenceMap refMap = (SubstrateReferenceMap) state.debugInfo().getReferenceMap();
    /*
         * We want to verify explicit deoptimization entry points, and implicit deoptimization entry
         * points at call sites. Unfortunately, just checking isDeoptEntry gives us false positives
         * for some runtime calls that re-use a state (which is not marked as "during call").
         */
    boolean isDeoptEntry = ((HostedMethod) state.topFrame.getMethod()).compilationInfo.isDeoptEntry(state.topFrame.getBCI(), state.topFrame.duringCall, state.topFrame.rethrowException);
    if (op instanceof DeoptEntryOp || (state.topFrame.duringCall && isDeoptEntry)) {
        BytecodeFrame frame = state.topFrame;
        Map<Integer, Object> allUsedRegisters = refMap.getDebugAllUsedRegisters();
        Map<Integer, Object> allUsedStackSlots = refMap.getDebugAllUsedStackSlots();
        if (allUsedRegisters != null && !allUsedRegisters.isEmpty()) {
            throw shouldNotReachHere("Deoptimization target must not use any registers");
        }
        if (allUsedStackSlots != null) {
            Map<Integer, Object> cleanedStackSlots = new HashMap<>(allUsedStackSlots);
            do {
                /*
                     * Remove stack slot information for all slots which already have a
                     * representative in the bytecode frame.
                     */
                for (JavaValue value : frame.values) {
                    if (value instanceof StackSlot) {
                        StackSlot stackSlot = (StackSlot) value;
                        int offset = stackSlot.getOffset(frameMap.totalFrameSize());
                        debug.log("remove slot %d: %s", offset, stackSlot);
                        cleanedStackSlots.remove(offset);
                    } else if (ValueUtil.isConstantJavaValue(value) || ValueUtil.isIllegalJavaValue(value)) {
                    /* Nothing to do. */
                    } else {
                        throw shouldNotReachHere("unknown value in deopt target: " + value);
                    }
                }
                frame = frame.caller();
            } while (frame != null);
            int firstBci = state.topFrame.getMethod().isSynchronized() ? BytecodeFrame.BEFORE_BCI : 0;
            if (state.topFrame.getBCI() == firstBci && state.topFrame.caller() == null && state.topFrame.duringCall == false && state.topFrame.rethrowException == false) {
                /*
                     * Some stack slots, e.g., the return address and manually allocated stack
                     * memory, are alive the whole method. So all stack slots that are registered
                     * for the method entry are allowed to be registered in all subsequent states.
                     */
                assert op instanceof DeoptEntryOp;
                assert allowedStackSlots == null;
                allowedStackSlots = new HashMap<>(cleanedStackSlots);
            } else {
                if (allowedStackSlots == null) {
                    allowedStackSlots = new HashMap<>();
                }
                for (Integer key : allowedStackSlots.keySet()) {
                    cleanedStackSlots.remove(key);
                }
                if (!cleanedStackSlots.isEmpty()) {
                    throw shouldNotReachHere("unknown values in stack slots: method " + state.topFrame.getMethod().toString() + ", op " + op.id() + " " + op + ": " + cleanedStackSlots);
                }
            }
        }
    }
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) HashMap(java.util.HashMap) JavaValue(jdk.vm.ci.meta.JavaValue) DeoptEntryOp(com.oracle.svm.core.graal.lir.DeoptEntryOp) StackSlot(jdk.vm.ci.code.StackSlot) SubstrateReferenceMap(com.oracle.svm.core.heap.SubstrateReferenceMap)

Example 8 with JavaValue

use of jdk.vm.ci.meta.JavaValue in project graal by oracle.

the class LIRFrameState method visitValues.

protected void visitValues(LIRInstruction inst, JavaValue[] values, InstructionValueConsumer proc) {
    for (int i = 0; i < values.length; i++) {
        JavaValue value = values[i];
        if (isIllegalJavaValue(value)) {
            continue;
        } else if (value instanceof AllocatableValue) {
            proc.visitValue(inst, (AllocatableValue) value, OperandMode.ALIVE, STATE_FLAGS);
        } else if (value instanceof StackLockValue) {
            StackLockValue monitor = (StackLockValue) value;
            JavaValue owner = monitor.getOwner();
            if (owner instanceof AllocatableValue) {
                proc.visitValue(inst, (AllocatableValue) owner, OperandMode.ALIVE, STATE_FLAGS);
            }
            Value slot = monitor.getSlot();
            if (isVirtualStackSlot(slot)) {
                proc.visitValue(inst, slot, OperandMode.ALIVE, STATE_FLAGS);
            }
        } else {
            assert unprocessed(value);
        }
    }
}
Also used : JavaValue(jdk.vm.ci.meta.JavaValue) ValueUtil.isIllegalJavaValue(jdk.vm.ci.code.ValueUtil.isIllegalJavaValue) ValueUtil.isConstantJavaValue(jdk.vm.ci.code.ValueUtil.isConstantJavaValue) StackLockValue(jdk.vm.ci.code.StackLockValue) JavaValue(jdk.vm.ci.meta.JavaValue) StackLockValue(jdk.vm.ci.code.StackLockValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) ValueUtil.isIllegalJavaValue(jdk.vm.ci.code.ValueUtil.isIllegalJavaValue) Value(jdk.vm.ci.meta.Value) ValueUtil.isConstantJavaValue(jdk.vm.ci.code.ValueUtil.isConstantJavaValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 9 with JavaValue

use of jdk.vm.ci.meta.JavaValue in project graal by oracle.

the class JVMCIInfopointErrorTest method testUnexpectedObject.

@Test(expected = JVMCIError.class)
public void testUnexpectedObject() {
    JavaValue wrapped = getSnippetReflection().forObject(this);
    test((tool, state, safepoint) -> {
        LIRFrameState newState = modifyTopFrame(state, new JavaValue[] { wrapped }, new JavaKind[] { JavaKind.Int }, 1, 0, 0);
        safepoint.accept(newState);
    });
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) JavaValue(jdk.vm.ci.meta.JavaValue) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 10 with JavaValue

use of jdk.vm.ci.meta.JavaValue in project graal by oracle.

the class CollectingObjectReferenceVisitor method verifyFrame.

private void verifyFrame(CompilationResult compilation, BytecodeFrame expectedFrame, FrameInfoQueryResult actualFrame, BitSet visitedVirtualObjects) {
    assert (expectedFrame == null) == (actualFrame == null);
    if (expectedFrame == null || !actualFrame.needLocalValues) {
        return;
    }
    verifyFrame(compilation, expectedFrame.caller(), actualFrame.getCaller(), visitedVirtualObjects);
    for (int i = 0; i < expectedFrame.values.length; i++) {
        JavaValue expectedValue = expectedFrame.values[i];
        if (i >= actualFrame.getValueInfos().length) {
            assert ValueUtil.isIllegalJavaValue(expectedValue);
            continue;
        }
        ValueInfo actualValue = actualFrame.getValueInfos()[i];
        JavaKind expectedKind = FrameInfoEncoder.getFrameValueKind(expectedFrame, i);
        assert expectedKind == actualValue.getKind();
        verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects);
    }
}
Also used : JavaValue(jdk.vm.ci.meta.JavaValue) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) JavaKind(jdk.vm.ci.meta.JavaKind)

Aggregations

JavaValue (jdk.vm.ci.meta.JavaValue)13 JavaKind (jdk.vm.ci.meta.JavaKind)5 ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)4 VirtualObject (jdk.vm.ci.code.VirtualObject)4 Infopoint (jdk.vm.ci.code.site.Infopoint)4 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)3 StackLockValue (jdk.vm.ci.code.StackLockValue)3 Value (jdk.vm.ci.meta.Value)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)2 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 SharedField (com.oracle.svm.core.meta.SharedField)2 SharedType (com.oracle.svm.core.meta.SharedType)2 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 ValueUtil.isConstantJavaValue (jdk.vm.ci.code.ValueUtil.isConstantJavaValue)2 ValueUtil.isIllegalJavaValue (jdk.vm.ci.code.ValueUtil.isIllegalJavaValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 GraalError (org.graalvm.compiler.debug.GraalError)2 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)2 EscapeObjectState (org.graalvm.compiler.nodes.virtual.EscapeObjectState)2