Search in sources :

Example 1 with JavaValue

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

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

the class LIRFrameState method processValues.

protected void processValues(LIRInstruction inst, JavaValue[] values, InstructionValueProcedure proc) {
    for (int i = 0; i < values.length; i++) {
        JavaValue value = values[i];
        if (isIllegalJavaValue(value)) {
            continue;
        }
        if (value instanceof AllocatableValue) {
            AllocatableValue allocatable = (AllocatableValue) value;
            Value result = proc.doValue(inst, allocatable, OperandMode.ALIVE, STATE_FLAGS);
            if (!allocatable.identityEquals(result)) {
                values[i] = (JavaValue) result;
            }
        } else if (value instanceof StackLockValue) {
            StackLockValue monitor = (StackLockValue) value;
            JavaValue owner = monitor.getOwner();
            if (owner instanceof AllocatableValue) {
                monitor.setOwner((JavaValue) proc.doValue(inst, (AllocatableValue) owner, OperandMode.ALIVE, STATE_FLAGS));
            }
            Value slot = monitor.getSlot();
            if (isVirtualStackSlot(slot)) {
                monitor.setSlot(asAllocatableValue(proc.doValue(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) 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) StackLockValue(jdk.vm.ci.code.StackLockValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 3 with JavaValue

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

the class DebugInfoBuilder method computeFrameForState.

protected BytecodeFrame computeFrameForState(FrameState state) {
    try {
        assert state.bci != BytecodeFrame.INVALID_FRAMESTATE_BCI;
        assert state.bci != BytecodeFrame.UNKNOWN_BCI;
        assert state.bci != BytecodeFrame.BEFORE_BCI || state.locksSize() == 0;
        assert state.bci != BytecodeFrame.AFTER_BCI || state.locksSize() == 0;
        assert state.bci != BytecodeFrame.AFTER_EXCEPTION_BCI || state.locksSize() == 0;
        assert !(state.getMethod().isSynchronized() && state.bci != BytecodeFrame.BEFORE_BCI && state.bci != BytecodeFrame.AFTER_BCI && state.bci != BytecodeFrame.AFTER_EXCEPTION_BCI) || state.locksSize() > 0;
        assert state.verify();
        int numLocals = state.localsSize();
        int numStack = state.stackSize();
        int numLocks = state.locksSize();
        int numValues = numLocals + numStack + numLocks;
        int numKinds = numLocals + numStack;
        JavaValue[] values = numValues == 0 ? NO_JAVA_VALUES : new JavaValue[numValues];
        JavaKind[] slotKinds = numKinds == 0 ? NO_JAVA_KINDS : new JavaKind[numKinds];
        computeLocals(state, numLocals, values, slotKinds);
        computeStack(state, numLocals, numStack, values, slotKinds);
        computeLocks(state, values);
        BytecodeFrame caller = null;
        if (state.outerFrameState() != null) {
            caller = computeFrameForState(state.outerFrameState());
        }
        if (!state.canProduceBytecodeFrame()) {
            // This typically means a snippet or intrinsic frame state made it to the backend
            StackTraceElement ste = state.getCode().asStackTraceElement(state.bci);
            throw new GraalError("Frame state for %s cannot be converted to a BytecodeFrame since the frame state's code is " + "not the same as the frame state method's code", ste);
        }
        return new BytecodeFrame(caller, state.getMethod(), state.bci, state.rethrowException(), state.duringCall(), values, slotKinds, numLocals, numStack, numLocks);
    } catch (GraalError e) {
        throw e.addContext("FrameState: ", state);
    }
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) GraalError(org.graalvm.compiler.debug.GraalError) JavaValue(jdk.vm.ci.meta.JavaValue) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 4 with JavaValue

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

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

the class FrameInfoVerifier method addFrame.

private FrameInfoQueryResult addFrame(FrameData data, BytecodeFrame frame, boolean isDeoptEntry, boolean needLocalValues) {
    FrameInfoQueryResult result = new FrameInfoQueryResult();
    if (frame.caller() != null) {
        assert !isDeoptEntry : "Deoptimization entry point information for caller frames is not encoded";
        result.caller = addFrame(data, frame.caller(), false, needLocalValues);
    }
    result.virtualObjects = data.virtualObjects;
    result.encodedBci = encodeBci(frame.getBCI(), frame.duringCall, frame.rethrowException);
    result.isDeoptEntry = isDeoptEntry;
    result.needLocalValues = needLocalValues;
    SharedMethod method = (SharedMethod) frame.getMethod();
    if (customization.shouldStoreMethod()) {
        result.deoptMethod = method;
        objectConstants.addObject(SubstrateObjectConstant.forObject(method));
    }
    result.deoptMethodOffset = method.getDeoptOffsetInImage();
    result.numLocals = frame.numLocals;
    result.numStack = frame.numStack;
    result.numLocks = frame.numLocks;
    ValueInfo[] valueInfos = null;
    if (needLocalValues) {
        JavaValue[] values = frame.values;
        int numValues = 0;
        for (int i = values.length; --i >= 0; ) {
            if (!ValueUtil.isIllegalJavaValue(values[i])) {
                // Found the last non-illegal value, i.e., the last value we have to encode.
                numValues = i + 1;
                break;
            }
        }
        valueInfos = new ValueInfo[numValues];
        for (int i = 0; i < numValues; i++) {
            valueInfos[i] = makeValueInfo(data, getFrameValueKind(frame, i), values[i]);
        }
    }
    result.valueInfos = valueInfos;
    ImageSingletons.lookup(Counters.class).frameCount.inc();
    return result;
}
Also used : ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) JavaValue(jdk.vm.ci.meta.JavaValue) SharedMethod(com.oracle.svm.core.meta.SharedMethod) Infopoint(jdk.vm.ci.code.site.Infopoint)

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