Search in sources :

Example 36 with Pointer

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

the class CardTable method verifyDirtyCards.

/**
 * Check that that every object with a pointer to young space has a corresponding dirty card.
 */
private static boolean verifyDirtyCards(Pointer ctStart, Pointer objectsStart, Pointer objectsLimit) {
    final Log trace = Log.noopLog().string("[CardTable.verifyDirtyCards:");
    trace.string("  ctStart: ").hex(ctStart).string("  objectsStart: ").hex(objectsStart).string("  objectsLimit: ").hex(objectsLimit);
    /* Walk the objects */
    Pointer ptr = objectsStart;
    while (ptr.belowThan(objectsLimit)) {
        final Object obj = ptr.toObject();
        final boolean containsYoung = containsReferenceToYoungSpace(obj);
        if (containsYoung) {
            final UnsignedWord index = memoryPointerToIndex(objectsStart, objectsLimit, ptr);
            final boolean isClean = isCleanEntryAtIndex(ctStart, index);
            if (isClean) {
                /* { WITNESS */
                final boolean witnessForDebugging = true;
                final Log witness = (witnessForDebugging ? Log.log() : HeapImpl.getHeapImpl().getHeapVerifierImpl().getTraceLog());
                witness.string("[CardTable.verifyDirtyCards:").string("  objectsStart: ").hex(objectsStart).string("  objectsLimit: ").hex(objectsLimit).newline();
                witness.string("  obj: ").object(obj).string("  contains young: ").bool(containsYoung).string("  but index: ").unsigned(index).string(" is clean.").string(" returns false").string("]").newline();
                /* Return early on failure. */
                return false;
            }
        }
        ptr = LayoutEncoding.getObjectEnd(obj);
    }
    trace.string("]").newline();
    return true;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 37 with Pointer

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

the class DiscoverableReferenceProcessing method verify.

public static boolean verify(DiscoverableReference dr) {
    final Pointer refPointer = dr.getReferentPointer();
    final int refClassification = HeapVerifierImpl.classifyPointer(refPointer);
    if (refClassification < 0) {
        final Log witness = Log.log();
        witness.string("[DiscoverableReference.verify:");
        witness.string("  epoch: ").unsigned(HeapImpl.getHeapImpl().getGCImpl().getCollectionEpoch());
        witness.string("  refClassification: ").signed(refClassification);
        witness.string("]").newline();
        assert (!(refClassification < 0)) : "Bad referent.";
        return false;
    }
    /* Figure out where the referent is. */
    final HeapImpl heap = HeapImpl.getHeapImpl();
    final YoungGeneration youngGen = heap.getYoungGeneration();
    final OldGeneration oldGen = heap.getOldGeneration();
    final boolean refNull = refPointer.isNull();
    final boolean refBootImage = (!refNull) && HeapVerifierImpl.slowlyFindPointerInBootImage(refPointer);
    final boolean refYoung = (!refNull) && youngGen.slowlyFindPointer(refPointer);
    final boolean refOldFrom = (!refNull) && oldGen.slowlyFindPointerInFromSpace(refPointer);
    final boolean refOldTo = (!refNull) && oldGen.slowlyFindPointerInToSpace(refPointer);
    final boolean refOldPinnedFrom = (!refNull) && oldGen.slowlyFindPointerInPinnedFromSpace(refPointer);
    final boolean refOldPinnedTo = (!refNull) && oldGen.slowlyFindPointerInPinnedToSpace(refPointer);
    /* The referent might already have survived, or might not have. */
    if (!(refNull || refYoung || refBootImage || refOldFrom || refOldPinnedFrom)) {
        final Log witness = Log.log();
        witness.string("[DiscoverableReference.verify:");
        witness.string("  epoch: ").unsigned(HeapImpl.getHeapImpl().getGCImpl().getCollectionEpoch());
        witness.string("  refBootImage: ").bool(refBootImage);
        witness.string("  refYoung: ").bool(refYoung);
        witness.string("  refOldFrom: ").bool(refOldFrom);
        witness.string("  refOldPinnedFrom: ").bool(refOldPinnedFrom);
        witness.string("  referent should be in heap.");
        witness.string("]").newline();
        return false;
    }
    assert (!(refOldTo || refOldPinnedTo)) : "referent should be in the heap.";
    return true;
}
Also used : Log(com.oracle.svm.core.log.Log) Pointer(org.graalvm.word.Pointer)

Example 38 with Pointer

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

the class GarbageCollectorManagementFactory method blackenBootImageRoots.

@SuppressWarnings("try")
private void blackenBootImageRoots() {
    final Log trace = Log.noopLog().string("[blackenBootImageRoots:").newline();
    try (Timer bbirt = blackenBootImageRootsTimer.open()) {
        try (GreyToBlackObjRefVisitor.Counters gtborv = greyToBlackObjRefVisitor.openCounters()) {
            /* Walk through the native image heap roots. */
            Pointer cur = Word.objectToUntrackedPointer(NativeImageInfo.firstWritableReferenceObject);
            final Pointer last = Word.objectToUntrackedPointer(NativeImageInfo.lastWritableReferenceObject);
            while (cur.belowOrEqual(last)) {
                Object obj = cur.toObject();
                if (obj != null) {
                    greyToBlackObjectVisitor.visitObjectInline(obj);
                }
                cur = LayoutEncoding.getObjectEnd(obj);
            }
        }
    }
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer)

Example 39 with Pointer

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

the class HeapVerifierImpl method noReferencesToForwardedObjectsVerifier.

/* Look for objects with forwarded headers. */
private boolean noReferencesToForwardedObjectsVerifier(Object obj) {
    final Log trace = getTraceLog();
    trace.string("[HeapVerifierImpl.noReferencesToForwardedObjectsVerifier:");
    trace.string("  obj: ").object(obj);
    final UnsignedWord header = ObjectHeaderImpl.readHeaderFromObjectCarefully(obj);
    trace.string("  header: ").hex(header);
    final Pointer objPointer = Word.objectToUntrackedPointer(obj);
    trace.string("  objPointer: ").hex(objPointer);
    boolean result = InteriorObjRefWalker.walkObject(obj, noReferencesToForwardedObjectsVisitor);
    if (!result) {
        try (Log witness = getWitnessLog()) {
            witness.string("[HeapVerifierImpl.noReferencesToForwardedObjectsVerifier:").string("  cause: ").string(getCause()).string("  obj: ").object(obj).string("]").newline();
        }
    }
    trace.string("]").newline();
    return result;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 40 with Pointer

use of org.graalvm.word.Pointer 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)

Aggregations

Pointer (org.graalvm.word.Pointer)103 UnsignedWord (org.graalvm.word.UnsignedWord)45 Log (com.oracle.svm.core.log.Log)30 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)17 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)15 Snippet (org.graalvm.compiler.api.replacements.Snippet)14 Word (org.graalvm.compiler.word.Word)12 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)9 HotSpotReplacementsUtil.registerAsWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)7 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)5 NeverInline (com.oracle.svm.core.annotate.NeverInline)5 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)5 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)4 DynamicHub (com.oracle.svm.core.hub.DynamicHub)3 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)3 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)3 SignedWord (org.graalvm.word.SignedWord)3 DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)2 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)2 Dirent.direntPointer (com.oracle.svm.core.posix.headers.Dirent.direntPointer)2