Search in sources :

Example 51 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class HeapVerifierImpl method noReferencesOutsideHeap.

/**
 * For debugging: look for objects with interior references to outside the heap.
 *
 * That includes: references that are to zapped objects, and references that aren't to the heap.
 */
private boolean noReferencesOutsideHeap(Object obj) {
    final Log trace = getTraceLog();
    trace.string("[HeapVerifierImpl.noReferencesToZappedObjectsVerifier:");
    trace.string("  obj: ").object(obj).string("  obj.getClass: ").string(obj.getClass().getName());
    final ObjectHeaderImpl ohi = ObjectHeaderImpl.getObjectHeaderImpl();
    final UnsignedWord header = ObjectHeaderImpl.readHeaderFromObjectCarefully(obj);
    trace.string("  header: ").hex(header).string("  objectHeader: ").string(ohi.toStringFromObject(obj));
    final Pointer objPointer = Word.objectToUntrackedPointer(obj);
    trace.string("  objPointer: ").hex(objPointer);
    boolean result = InteriorObjRefWalker.walkObject(obj, noReferencesOutsideHeapVisitor);
    if (!result) {
        try (Log witness = getWitnessLog()) {
            witness.string("[HeapVerifierImpl.noReferencesOutsideHeap:").string("  cause: ").string(getCause());
            witness.string("  obj: ").string(obj.getClass().getName()).string("@").hex(objPointer);
            witness.string("  header: ").hex(header).string("  objectHeader: ").string(ohi.toStringFromObject(obj)).string("]").newline();
        }
    }
    trace.string("  returns: ").bool(result).string("]").newline();
    return result;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 52 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class ObjectHeaderImpl method classifyHeader.

/**
 * Debugging: Classifies a header so I can decide how much to trust it.
 *
 * <ul>
 * <li>Negative results fail in one way or another.</li>
 * <li>Positive results mean the header was valid.</li>
 * </ul>
 */
public static int classifyHeader(UnsignedWord header) {
    /* Check for total failures. */
    if (header.equal(WordFactory.zero())) {
        return -1_000_000;
    }
    if (header.equal(HeapPolicy.getProducedHeapChunkZapValue())) {
        return -2_000_000;
    }
    if (header.equal(HeapPolicy.getConsumedHeapChunkZapValue())) {
        return -3_000_000;
    }
    /* Tease the header apart into the DynamicHub bits and the header bits. */
    final UnsignedWord headerBits = ObjectHeaderImpl.getHeaderBitsFromHeaderCarefully(header);
    final int headerBitsClassification;
    if (headerBits.equal(NO_REMEMBERED_SET_ALIGNED)) {
        headerBitsClassification = 1;
    } else if (headerBits.equal(CARD_REMEMBERED_SET_ALIGNED)) {
        headerBitsClassification = 2;
    } else if (headerBits.equal(NO_REMEMBERED_SET_UNALIGNED)) {
        headerBitsClassification = 3;
    } else if (headerBits.equal(CARD_REMEMBERED_SET_UNALIGNED)) {
        headerBitsClassification = 4;
    } else if (headerBits.equal(BOOT_IMAGE)) {
        headerBitsClassification = 5;
    } else if (headerBits.equal(FORWARDED)) {
        headerBitsClassification = 6;
    } else {
        headerBitsClassification = -1;
    }
    final DynamicHub hub = ObjectHeader.dynamicHubFromObjectHeader(header);
    final int hubClassification = HeapVerifierImpl.classifyObject(hub);
    return ((1000 * hubClassification) + headerBitsClassification);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) DynamicHub(com.oracle.svm.core.hub.DynamicHub)

Example 53 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class ObjectHeaderImpl method readHeaderFromPointerCarefully.

public static UnsignedWord readHeaderFromPointerCarefully(Pointer p) {
    VMError.guarantee(!p.isNull(), "ObjectHeader.readHeaderFromPointerCarefully:  p: null");
    VMError.guarantee(p.notEqual(HeapPolicy.getProducedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully:  p: producedZapValue");
    VMError.guarantee(p.notEqual(HeapPolicy.getConsumedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully:  p: consumedZapValue");
    final UnsignedWord header = readHeaderFromPointer(p);
    VMError.guarantee(header.notEqual(WordFactory.zero()), "ObjectHeader.readHeaderFromPointerCarefully:  header: 0");
    VMError.guarantee(header.notEqual(HeapPolicy.getProducedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully:  header: producedZapValue");
    VMError.guarantee(header.notEqual(HeapPolicy.getConsumedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully:  header: consumedZapValue");
    return header;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 54 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class ObjectHeaderImpl method isPointerToForwardedObjectCarefully.

protected boolean isPointerToForwardedObjectCarefully(Pointer p) {
    final UnsignedWord header = readHeaderFromPointerCarefully(p);
    final boolean result = isForwardedHeaderCarefully(header);
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 55 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class OldGeneration method promoteUnalignedObjectChunk.

private Object promoteUnalignedObjectChunk(Object original) {
    final Log trace = Log.noopLog().string("[OldGeneration.promoteUnalignedObjectChunk:").string("  original: ").object(original);
    assert ObjectHeaderImpl.getObjectHeaderImpl().isUnalignedObject(original);
    final UnalignedHeapChunk.UnalignedHeader uChunk = UnalignedHeapChunk.getEnclosingUnalignedHeapChunk(original);
    final Space originalSpace = uChunk.getSpace();
    trace.string("  originalSpace: ").string(originalSpace.getName());
    if (shouldPromoteFrom(originalSpace)) {
        trace.string("  promoting");
        /*
             * Since the object does not move when an UnalignedChunk is promoted, there is no need
             * to return a possible copy.
             */
        if (HeapOptions.TraceObjectPromotion.getValue()) {
            final Log promotionTrace = Log.log().string("[OldGeneration.promoteUnalignedObjectChunk:").string("  original: ").object(original);
            final UnsignedWord size = LayoutEncoding.getSizeFromObject(original);
            promotionTrace.string("  size: ").unsigned(size).string("]").newline();
        }
        getToSpace().promoteUnalignedHeapChunk(uChunk);
    } else {
        trace.string("  not promoting");
    }
    trace.string("  returns: ").object(original);
    if (trace.isEnabled()) {
        final UnalignedHeapChunk.UnalignedHeader resultChunk = UnalignedHeapChunk.getEnclosingUnalignedHeapChunk(original);
        final Space resultSpace = resultChunk.getSpace();
        trace.string("  resultSpace: ").string(resultSpace.getName());
    }
    trace.string("]").newline();
    return original;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord)

Aggregations

UnsignedWord (org.graalvm.word.UnsignedWord)137 Pointer (org.graalvm.word.Pointer)43 Log (com.oracle.svm.core.log.Log)30 DynamicHub (com.oracle.svm.core.hub.DynamicHub)11 Fold (org.graalvm.compiler.api.replacements.Fold)11 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)9 Snippet (org.graalvm.compiler.api.replacements.Snippet)9 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)6 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)4 WordBase (org.graalvm.word.WordBase)4 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)3 ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)3 UnalignedHeader (com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader)3 XOptions (com.oracle.svm.core.option.XOptions)3 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)3 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)2 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 JavaKind (jdk.vm.ci.meta.JavaKind)2