Search in sources :

Example 16 with Pointer

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

the class ThreadLocalAllocation method retireAllocationChunk.

/**
 * Retire the current allocation chunk of current TLAB.
 */
@Uninterruptible(reason = "Modifies TLAB")
private static void retireAllocationChunk(Descriptor tlab) {
    Pointer allocationTop = tlab.getAllocationTop(TOP_IDENTITY);
    if (allocationTop.isNonNull()) {
        AlignedHeader alignedChunk = tlab.getAlignedChunk();
        assert alignedChunk.getTop().isNull();
        assert alignedChunk.getEnd().equal(tlab.getAllocationEnd(END_IDENTITY));
        /*
             * While the aligned chunk is the allocation chunk its top value is always 'null' and it
             * doesn't reflect the upper limit of allocated memory. The 'top' is stored in the TLAB
             * and only set in the top aligned chunk when it is retired.
             */
        alignedChunk.setTop(allocationTop);
        tlab.setAllocationTop(WordFactory.nullPointer(), TOP_IDENTITY);
        tlab.setAllocationEnd(WordFactory.nullPointer(), END_IDENTITY);
    }
}
Also used : AlignedHeader(com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader) Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 17 with Pointer

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

the class ThreadLocalAllocation method allocateNewInstanceUninterruptibly.

@Uninterruptible(reason = "Holds uninitialized memory, modifies TLAB")
private static Object allocateNewInstanceUninterruptibly(DynamicHub hub, ThreadLocalAllocation.Descriptor tlab, boolean rememberedSet, UnsignedWord size, AlignedHeader newChunk) {
    registerNewAllocationChunk(tlab, newChunk);
    /*
         * Allocate the memory. We must have a chunk, because we just registered one and we are
         * still in the same block of uninterruptible code.
         */
    Pointer memory = allocateMemory(tlab, size);
    assert memory.isNonNull();
    /* Install the DynamicHub and zero the fields. */
    return KnownIntrinsics.formatObject(memory, hub.asClass(), rememberedSet);
}
Also used : Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 18 with Pointer

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

the class ThreadLocalAllocation method getObjectBytes.

/**
 * Returns the total memory used by the TLAB in bytes. It counts only the memory actually used,
 * not the total committed memory.
 */
public static UnsignedWord getObjectBytes(Descriptor tlab) {
    Log log = log();
    log.newline();
    log.string("[ThreadLocalAllocator.usedMemory: tlab ").hex(tlab).newline();
    AlignedHeader aChunk = tlab.getAlignedChunk();
    UnsignedWord alignedUsedMemory = WordFactory.zero();
    while (aChunk.isNonNull()) {
        AlignedHeader next = aChunk.getNext();
        Pointer start = AlignedHeapChunk.getAlignedHeapChunkStart(aChunk);
        /* The allocation top has a null top; the TLAB is the one advancing the top pointer. */
        Pointer top = aChunk.getTop().isNull() ? tlab.getAllocationTop(TOP_IDENTITY) : aChunk.getTop();
        UnsignedWord aChunkUsedMemory = top.subtract(start);
        alignedUsedMemory = alignedUsedMemory.add(aChunkUsedMemory);
        log.string("     aligned chunk: ").hex(aChunk).string(" | used memory: ").unsigned(aChunkUsedMemory).newline();
        aChunk = next;
    }
    UnsignedWord unalignedUsedMemory = WordFactory.zero();
    UnalignedHeader uChunk = tlab.getUnalignedChunk();
    while (uChunk.isNonNull()) {
        UnalignedHeader next = uChunk.getNext();
        UnsignedWord uChunkUsedMemory = UnalignedHeapChunk.usedObjectMemoryOfUnalignedHeapChunk(uChunk);
        unalignedUsedMemory = unalignedUsedMemory.add(uChunkUsedMemory);
        log.string("     unaligned chunk ").hex(uChunk).string(" | used memory: ").unsigned(uChunkUsedMemory).newline();
        uChunk = next;
    }
    UnsignedWord tlabUsedMemory = alignedUsedMemory.add(unalignedUsedMemory);
    log.newline();
    log.string("  aligned used memory: ").unsigned(alignedUsedMemory).newline();
    log.string("  unaligned used memory: ").unsigned(unalignedUsedMemory).newline();
    log.string("  TLAB used memory: ").unsigned(tlabUsedMemory).newline();
    log.string("  ]").newline();
    return tlabUsedMemory;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) AlignedHeader(com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader) UnalignedHeader(com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader) Pointer(org.graalvm.word.Pointer)

Example 19 with Pointer

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method dirtyCardForObjectOfUnalignedHeapChunk.

/**
 * 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 dirtyCardForObjectOfUnalignedHeapChunk(Object obj) {
    final UnalignedHeader chunk = getEnclosingUnalignedHeapChunk(obj);
    final Pointer rememberedSetStart = getCardTableStart(chunk);
    final UnsignedWord objectIndex = getObjectIndex();
    CardTable.dirtyEntryAtIndex(rememberedSetStart, objectIndex);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 20 with Pointer

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

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