Search in sources :

Example 31 with Pointer

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

the class AlignedHeapChunkMemoryWalkerAccessFeature method dirtyCardForObjectOfAlignedHeapChunk.

/**
 * Dirty the card corresponding to the given Object.
 *
 * This has to be fast, because it is used by the post-write barrier.
 */
public static void dirtyCardForObjectOfAlignedHeapChunk(Object obj) {
    final AlignedHeader chunk = getEnclosingAlignedHeapChunk(obj);
    final Pointer cardTableStart = getCardTableStart(chunk);
    final UnsignedWord index = getObjectIndex(chunk, obj);
    CardTable.dirtyEntryAtIndex(cardTableStart, index);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 32 with Pointer

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

the class AlignedHeapChunkMemoryWalkerAccessFeature method verifyOnlyCleanCards.

/**
 * Verify that there are only clean cards for the given chunk.
 */
static boolean verifyOnlyCleanCards(AlignedHeader that) {
    final Log trace = Log.noopLog().string("[AlignedHeapChunk.verifyOnlyCleanCards:");
    trace.string("  that: ").hex(that);
    boolean result = true;
    /* Iterate through the cards looking for dirty cards. */
    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);
    for (UnsignedWord index = WordFactory.zero(); index.belowThan(indexLimit); index = index.add(1)) {
        if (CardTable.isDirtyEntryAtIndex(cardTableStart, index)) {
            result = false;
            final Log witness = Log.log().string("[AlignedHeapChunk.verifyOnlyCleanCards:");
            witness.string("  that: ").hex(that).string("  dirty card at index: ").unsigned(index).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 33 with Pointer

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

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

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

the class AlignedHeapChunkMemoryWalkerAccessFeature method setUpRememberedSetForObjectOfAlignedHeapChunk.

/**
 * Initialize the remembered set for a particular object, if this chunk has a remembered set.
 */
static void setUpRememberedSetForObjectOfAlignedHeapChunk(AlignedHeader that, Object obj) {
    VMOperation.guaranteeInProgress("Should only be called from the collector.");
    /*
         * There is only a remembered set maintained in the old To-Space. Testing against the Young
         * space compiles to a test against a constant.
         */
    final HeapImpl heap = HeapImpl.getHeapImpl();
    if (!heap.isYoungGeneration(that.getSpace())) {
        /*
             * The card remembered set table should already be clean, but the first object table
             * needs to be set up.
             */
        final Pointer fotStart = getFirstObjectTableStart(that);
        final Pointer memoryStart = getAlignedHeapChunkStart(that);
        final Pointer objStart = Word.objectToUntrackedPointer(obj);
        /* Interruptible does not apply because I am in the collector. */
        final Pointer objEnd = LayoutEncoding.getObjectEnd(obj);
        FirstObjectTable.setTableForObject(fotStart, memoryStart, objStart, objEnd);
        /* Note that the object is aligned, and that it has a card remembered set. */
        ObjectHeaderImpl.getObjectHeaderImpl().setCardRememberedSetAligned(obj);
    }
}
Also used : 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