Search in sources :

Example 6 with ValueInfo

use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.

the class CollectingObjectReferenceVisitor method verifyVirtualObject.

private void verifyVirtualObject(CompilationResult compilation, VirtualObject expectedObject, ValueInfo[] actualObject, FrameInfoQueryResult actualFrame, BitSet visitedVirtualObjects) {
    if (visitedVirtualObjects.get(expectedObject.getId())) {
        return;
    }
    visitedVirtualObjects.set(expectedObject.getId());
    ObjectLayout objectLayout = ConfigurationValues.getObjectLayout();
    SharedType expectedType = (SharedType) expectedObject.getType();
    if (expectedType.isArray()) {
        JavaKind kind = expectedType.getComponentType().getJavaKind();
        int expectedLength = 0;
        for (int i = 0; i < expectedObject.getValues().length; i++) {
            JavaValue expectedValue = expectedObject.getValues()[i];
            UnsignedWord expectedOffset = WordFactory.unsigned(objectLayout.getArrayElementOffset(expectedType.getComponentType().getJavaKind(), expectedLength));
            ValueInfo actualValue = findActualArrayElement(actualObject, expectedOffset);
            verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects);
            JavaKind valueKind = expectedObject.getSlotKind(i);
            if (objectLayout.sizeInBytes(kind) == 4 && objectLayout.sizeInBytes(valueKind) == 8) {
                /*
                     * Truffle uses arrays in a non-standard way: it declares an int[] array and
                     * uses it to also store long and double values. These values span two array
                     * elements - so we have to add 2 to the length.
                     */
                expectedLength += 2;
            } else {
                expectedLength++;
            }
        }
        int actualLength = actualObject[1].value.asInt();
        assert expectedLength == actualLength;
    } else {
        SharedField[] expectedFields = (SharedField[]) expectedType.getInstanceFields(true);
        int fieldIdx = 0;
        int valueIdx = 0;
        while (valueIdx < expectedObject.getValues().length) {
            SharedField expectedField = expectedFields[fieldIdx];
            fieldIdx += 1;
            JavaValue expectedValue = expectedObject.getValues()[valueIdx];
            JavaKind valueKind = expectedObject.getSlotKind(valueIdx);
            valueIdx += 1;
            JavaKind kind = expectedField.getStorageKind();
            if (objectLayout.sizeInBytes(kind) == 4 && objectLayout.sizeInBytes(valueKind) == 8) {
                /*
                     * Truffle uses fields in a non-standard way: it declares a couple of
                     * (consecutive) int fields, and uses them to also store long and double values.
                     * These values span two fields - so we have to ignore a field.
                     */
                fieldIdx++;
            }
            UnsignedWord expectedOffset = WordFactory.unsigned(expectedField.getLocation());
            ValueInfo actualValue = findActualField(actualObject, expectedOffset);
            verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects);
        }
    }
}
Also used : SharedField(com.oracle.svm.core.meta.SharedField) UnsignedWord(org.graalvm.word.UnsignedWord) JavaValue(jdk.vm.ci.meta.JavaValue) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) ObjectLayout(com.oracle.svm.core.config.ObjectLayout) SharedType(com.oracle.svm.core.meta.SharedType) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 7 with ValueInfo

use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.

the class CollectingObjectReferenceVisitor method findActualValue.

private static ValueInfo findActualValue(ValueInfo[] actualObject, UnsignedWord expectedOffset, ObjectLayout objectLayout, UnsignedWord startOffset, int startIdx) {
    UnsignedWord curOffset = startOffset;
    int curIdx = startIdx;
    while (curOffset.notEqual(expectedOffset)) {
        ValueInfo value = actualObject[curIdx];
        curOffset = curOffset.add(objectLayout.sizeInBytes(value.getKind(), value.isCompressedReference));
        curIdx++;
    }
    assert curOffset.equal(expectedOffset);
    return actualObject[curIdx];
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint)

Example 8 with ValueInfo

use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.

the class FrameInfoDecoder method decodeValues.

private static ValueInfo[] decodeValues(ValueInfoAllocator valueInfoAllocator, int numValues, TypeReader readBuffer, Object[] frameInfoObjectConstants) {
    ValueInfo[] valueInfos = valueInfoAllocator.newValueInfoArray(numValues);
    for (int i = 0; i < numValues; i++) {
        ValueInfo valueInfo = valueInfoAllocator.newValueInfo();
        if (valueInfos != null) {
            valueInfos[i] = valueInfo;
        }
        int flags = readBuffer.getU1();
        ValueType valueType = extractType(flags);
        if (valueInfo != null) {
            valueInfo.type = valueType;
            valueInfo.kind = extractKind(flags);
            valueInfo.isCompressedReference = extractIsCompressedReference(flags);
        }
        if (valueType.hasData) {
            long valueInfoData = readBuffer.getSV();
            if (valueInfo != null) {
                valueInfo.data = valueInfoData;
            }
        }
        valueInfoAllocator.decodeConstant(valueInfo, frameInfoObjectConstants);
    }
    return valueInfos;
}
Also used : ValueType(com.oracle.svm.core.code.FrameInfoQueryResult.ValueType) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)

Example 9 with ValueInfo

use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.

the class FrameInfoVerifier method addDebugInfo.

protected FrameData addDebugInfo(ResolvedJavaMethod method, Infopoint infopoint, int totalFrameSize) {
    final boolean shouldIncludeMethod = customization.shouldInclude(method, infopoint);
    final boolean encodeSourceReferences = FrameInfoDecoder.encodeSourceReferences();
    if (!shouldIncludeMethod && !encodeSourceReferences) {
        return null;
    }
    final DebugInfo debugInfo = infopoint.debugInfo;
    final FrameData data = new FrameData();
    data.debugInfo = debugInfo;
    data.totalFrameSize = totalFrameSize;
    data.virtualObjects = new ValueInfo[countVirtualObjects(debugInfo)][];
    data.frame = addFrame(data, debugInfo.frame(), customization.isDeoptEntry(method, infopoint), shouldIncludeMethod);
    final boolean encodeDebugNames = shouldIncludeMethod && FrameInfoDecoder.encodeDebugNames();
    if (encodeDebugNames || FrameInfoDecoder.encodeSourceReferences()) {
        BytecodeFrame bytecodeFrame = data.debugInfo.frame();
        for (FrameInfoQueryResult resultFrame = data.frame; bytecodeFrame != null; resultFrame = resultFrame.caller) {
            customization.fillDebugNames(bytecodeFrame, resultFrame, encodeDebugNames && shouldIncludeMethod);
            bytecodeFrame = bytecodeFrame.caller();
        }
        for (FrameInfoQueryResult cur = data.frame; cur != null; cur = cur.caller) {
            sourceClassNames.addObject(cur.sourceClassName);
            sourceMethodNames.addObject(cur.sourceMethodName);
            sourceFileNames.addObject(cur.sourceFileName);
            if (encodeDebugNames) {
                for (ValueInfo valueInfo : cur.valueInfos) {
                    if (valueInfo.name == null) {
                        valueInfo.name = "";
                    }
                    names.addObject(valueInfo.name);
                }
            }
        }
    }
    allDebugInfos.add(data);
    return data;
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) DebugInfo(jdk.vm.ci.code.DebugInfo)

Example 10 with ValueInfo

use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo 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)

Aggregations

ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)13 Infopoint (jdk.vm.ci.code.site.Infopoint)7 JavaKind (jdk.vm.ci.meta.JavaKind)4 JavaValue (jdk.vm.ci.meta.JavaValue)4 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)3 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 UnsignedWord (org.graalvm.word.UnsignedWord)3 SharedField (com.oracle.svm.core.meta.SharedField)2 SharedType (com.oracle.svm.core.meta.SharedType)2 Counters (com.oracle.svm.core.code.CodeInfoEncoder.Counters)1 FrameInfoQueryResult (com.oracle.svm.core.code.FrameInfoQueryResult)1 ValueType (com.oracle.svm.core.code.FrameInfoQueryResult.ValueType)1 VirtualFrame (com.oracle.svm.core.deopt.DeoptimizedFrame.VirtualFrame)1 DynamicHub (com.oracle.svm.core.hub.DynamicHub)1 SharedMethod (com.oracle.svm.core.meta.SharedMethod)1 ArrayList (java.util.ArrayList)1 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)1 DebugInfo (jdk.vm.ci.code.DebugInfo)1 StackSlot (jdk.vm.ci.code.StackSlot)1