Search in sources :

Example 41 with UnsignedWord

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

the class AlignedHeapChunkMemoryWalkerAccessFeature method verifyHeaders.

/**
 * Verify that all the objects have headers that say they are aligned.
 */
private static boolean verifyHeaders(AlignedHeader that) {
    final Log trace = Log.noopLog().string("[AlignedHeapChunk.verifyHeaders: ").string("  that: ").hex(that);
    /* Get the Object at the offset, or null. */
    Pointer current = getAlignedHeapChunkStart(that);
    while (current.belowThan(that.getTop())) {
        trace.newline().string("  current: ").hex(current);
        final UnsignedWord header = ObjectHeader.readHeaderFromPointer(current);
        if (!ObjectHeaderImpl.getObjectHeaderImpl().isAlignedHeader(header)) {
            trace.string("  does not have an aligned header: ").hex(header).string("  returns: false").string("]").newline();
            return false;
        }
        /*
             * Step over the object. This does not deal with forwarded objects, but I have already
             * checked that the header is an aligned header.
             */
        current = LayoutEncoding.getObjectEnd(current.toObject());
    }
    trace.string("  returns: true]").newline();
    return true;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 42 with UnsignedWord

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

the class AlignedHeapChunkMemoryWalkerAccessFeature method getFirstObjectTableSize.

/**
 * How big is the first object table?
 */
@Fold
static UnsignedWord getFirstObjectTableSize() {
    /* How much space is there in the chunk? */
    final UnsignedWord headerSize = getHeaderSize();
    final UnsignedWord available = HeapPolicy.getAlignedHeapChunkSize().subtract(headerSize);
    /* How big should the table be? */
    final UnsignedWord requiredSize = CardTable.tableSizeForMemorySize(available);
    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 43 with UnsignedWord

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

the class AlignedHeapChunkMemoryWalkerAccessFeature method cleanRememberedSetOfAlignedHeapChunk.

/**
 * Clean the remembered set for an AlignedHeapChunk.
 */
static void cleanRememberedSetOfAlignedHeapChunk(AlignedHeader that) {
    final Log trace = Log.noopLog().string("[AlignedHeapChunk.cleanRememberedSet:");
    trace.string("  that: ").hex(that);
    final Pointer cardTableStart = getCardTableStart(that);
    final Pointer objectsStart = getAlignedHeapChunkStart(that);
    final Pointer objectsLimit = that.getTop();
    final UnsignedWord memorySize = objectsLimit.subtract(objectsStart);
    final UnsignedWord indexLimit = CardTable.indexLimitForMemorySize(memorySize);
    trace.string("  objectsStart: ").hex(objectsStart).string("  objectsLimit: ").hex(objectsLimit).string("  indexLimit: ").unsigned(indexLimit);
    CardTable.cleanTableToIndex(cardTableStart, indexLimit);
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 44 with UnsignedWord

use of org.graalvm.word.UnsignedWord 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 45 with UnsignedWord

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

the class FirstObjectTable method initializeTableToPointerForAsserts.

/**
 * Initialize all the entries to the UninitializedEntry value, since I check for that in
 * asserts.
 */
private static boolean initializeTableToPointerForAsserts(Pointer table, Pointer tableLimit) {
    final UnsignedWord indexLimit = FirstObjectTable.tableOffsetToIndex(tableLimit.subtract(table));
    FirstObjectTable.initializeTableToIndexForAsserts(table, indexLimit);
    return true;
}
Also used : 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