Search in sources :

Example 21 with Log

use of com.oracle.svm.core.log.Log 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 22 with Log

use of com.oracle.svm.core.log.Log 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 23 with Log

use of com.oracle.svm.core.log.Log in project graal by oracle.

the class UnalignedHeapChunkMemoryWalkerAccessFeature method cleanRememberedSetOfUnalignedHeapChunk.

/**
 * Clean the remembered set for the given chunk.
 */
protected static void cleanRememberedSetOfUnalignedHeapChunk(UnalignedHeader that) {
    final Log trace = Log.noopLog().string("[UnalignedHeapChunk.cleanRememberedSet:").newline();
    trace.string("  that: ").hex(that);
    CardTable.cleanTableToPointer(getCardTableStart(that), getCardTableLimit(that));
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 24 with Log

use of com.oracle.svm.core.log.Log 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 25 with Log

use of com.oracle.svm.core.log.Log 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)

Aggregations

Log (com.oracle.svm.core.log.Log)130 Pointer (org.graalvm.word.Pointer)30 UnsignedWord (org.graalvm.word.UnsignedWord)30 IsolateThread (org.graalvm.nativeimage.IsolateThread)4 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)4 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)3 CollectionWatcher (com.oracle.svm.core.heap.CollectionWatcher)3 DiscoverableReference (com.oracle.svm.core.heap.DiscoverableReference)3 XOptions (com.oracle.svm.core.option.XOptions)3 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)2 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)2 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)2 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)2 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)1 CodeInfoQueryResult (com.oracle.svm.core.code.CodeInfoQueryResult)1 SubstrateInstalledCode (com.oracle.svm.core.deopt.SubstrateInstalledCode)1 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)1 UnalignedHeader (com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader)1 AllocationFreeList (com.oracle.svm.core.heap.AllocationFreeList)1 NoAllocationVerifier (com.oracle.svm.core.heap.NoAllocationVerifier)1