Search in sources :

Example 11 with UnsignedWord

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method verifyOnlyCleanCardsOfUnalignedHeapChunk.

/**
 * Verify that there are only clean cards in the remembered set of the given chunk.
 */
static boolean verifyOnlyCleanCardsOfUnalignedHeapChunk(UnalignedHeader that) {
    final Log trace = Log.noopLog().string("[UnalignedHeapChunk.verifyOnlyCleanCards:");
    trace.string("  that: ").hex(that);
    boolean result = true;
    // Iterate through the cards looking for dirty cards.
    final Pointer rememberedSetStart = getCardTableStart(that);
    final UnsignedWord objectIndex = getObjectIndex();
    if (CardTable.isDirtyEntryAtIndex(rememberedSetStart, objectIndex)) {
        result = false;
        final Log witness = Log.log().string("[UnalignedHeapChunk.verifyOnlyCleanCards:");
        witness.string("  that: ").hex(that).string("  dirty card at index: ").unsigned(objectIndex).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 12 with UnsignedWord

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method getCardTableSize.

/**
 * How big is the card table?
 */
@Fold
static UnsignedWord getCardTableSize() {
    // A "table" of one entry.
    final UnsignedWord requiredSize = CardTable.tableSizeForMemorySize(WordFactory.unsigned(1));
    final UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment());
    return UnsignedUtils.roundUp(requiredSize, alignment);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Fold(org.graalvm.compiler.api.replacements.Fold)

Example 13 with UnsignedWord

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method verifyRememberedSet.

/**
 * Verify the remembered set of the given chunk.
 */
private static boolean verifyRememberedSet(UnalignedHeader that) {
    // Only chunks in the old from space have a remembered set.
    final HeapImpl heap = HeapImpl.getHeapImpl();
    final OldGeneration oldGen = heap.getOldGeneration();
    if (that.getSpace() == oldGen.getFromSpace()) {
        // Check if there are cross-generational pointers ...
        final Pointer objStart = getUnalignedStart(that);
        final Object obj = objStart.toObject();
        final boolean containsYoungReferences = CardTable.containsReferenceToYoungSpace(obj);
        // ... and if so, that the chunk is marked as dirty.
        if (containsYoungReferences) {
            final Pointer rememberedSet = getCardTableStart(that);
            final UnsignedWord objectIndex = getObjectIndex();
            final boolean isDirty = CardTable.isDirtyEntryAtIndex(rememberedSet, objectIndex);
            if (!isDirty) {
                final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
                witness.string("  that: ").hex(that);
                witness.string("  containsYoungReferences implies isDirty").string("]").newline();
                return false;
            }
        }
    }
    return true;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Log(com.oracle.svm.core.log.Log) Pointer(org.graalvm.word.Pointer)

Example 14 with UnsignedWord

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method verifyUnalignedHeapChunk.

/**
 * Verify an UnalignedHeapChunk, called from sub-class verify methods.
 */
private static boolean verifyUnalignedHeapChunk(UnalignedHeader that, Pointer start) {
    VMOperation.guaranteeInProgress("Should only be called as a VMOperation.");
    // The object in this chunk should not be forwarded,
    // and should be the only object in the chunk.
    final Log trace = HeapImpl.getHeapImpl().getHeapVerifierImpl().getTraceLog().string("[UnalignedHeapChunk.verifyUnalignedHeapChunk");
    trace.string("  that: ").hex(that).string("  start: ").hex(start).string("  top: ").hex(that.getTop()).string("  end: ").hex(that.getEnd()).newline();
    final UnsignedWord objHeader = ObjectHeader.readHeaderFromPointer(start);
    final ObjectHeaderImpl ohi = ObjectHeaderImpl.getObjectHeaderImpl();
    // The object should not be forwarded.
    if (ohi.isForwardedHeader(objHeader)) {
        final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
        witness.string("  that: ").hex(that).string("  start: ").hex(start).string("  top: ").hex(that.getTop()).string("  end: ").hex(that.getEnd());
        witness.string("  space: ").string(that.getSpace().getName());
        witness.string("  objHeader: ").string(ohi.toStringFromHeader(objHeader));
        witness.string("  should not be forwarded").string("]").newline();
        return false;
    }
    // The object should be marked as being unaligned.
    if (!ohi.isUnalignedHeader(objHeader)) {
        final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
        witness.string("  that: ").hex(that).string("  start: ").hex(start).string("  end: ").hex(that.getEnd());
        witness.string("  space: ").string(that.getSpace().getName());
        witness.string("  obj: ").hex(start).string("  objHeader: ").hex(objHeader);
        witness.string("  does not have an unaligned header").string("]").newline();
        return false;
    }
    // The object should be the only object in the chunk.
    final Object obj = start.toObject();
    final Pointer objEnd = LayoutEncoding.getObjectEnd(obj);
    if (objEnd.notEqual(that.getTop())) {
        final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
        witness.string("  that: ").hex(that).string("  start: ").hex(start).string("  end: ").hex(that.getEnd());
        witness.string("  space: ").string(that.getSpace().getName());
        witness.string("  obj: ").object(obj).string("  objEnd: ").hex(objEnd);
        witness.string("  should be the only object in the chunk").string("]").newline();
        return false;
    }
    if (!verifyRememberedSet(that)) {
        final Log witnessLog = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeadChunk remembered set fails to verify");
        witnessLog.string("  that: ").hex(that).string("  remembered set fails to verify.").string("]").newline();
    }
    // Verify the super-class.
    final boolean result = verifyHeapChunk(that, start);
    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 15 with UnsignedWord

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method walkDirtyObjectsOfUnalignedHeapChunk.

/**
 * Walk the dirty Objects in this chunk, passing each to a Visitor.
 */
public static boolean walkDirtyObjectsOfUnalignedHeapChunk(UnalignedHeader that, ObjectVisitor visitor, boolean clean) {
    final Log trace = Log.noopLog().string("[UnalignedHeapChunk.walkDirtyObjects:");
    trace.string("  clean: ").bool(clean).string("  that: ").hex(that).string("  ");
    boolean result = true;
    final Pointer rememberedSetStart = getCardTableStart(that);
    final UnsignedWord objectIndex = getObjectIndex();
    trace.string("  rememberedSetStart: ").hex(rememberedSetStart).string("  objectIndex: ").unsigned(objectIndex);
    // If the card for this chunk is dirty, visit the object.
    if (CardTable.isDirtyEntryAtIndex(rememberedSetStart, objectIndex)) {
        final Pointer objectsStart = getUnalignedStart(that);
        final Object obj = objectsStart.toObject();
        trace.string("  obj: ").object(obj);
        // Visit the object.
        if (!visitor.visitObjectInline(obj)) {
            result = false;
        }
        if (clean) {
            CardTable.cleanEntryAtIndex(rememberedSetStart, objectIndex);
        }
    }
    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

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