Search in sources :

Example 26 with Log

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

Example 27 with Log

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

the class GreyObjectsWalker method haveGreyObjects.

/**
 * Compare the snapshot to the current state of the Space to see if there are grey Objects.
 *
 * @return True if the snapshot updated, false otherwise.
 */
private boolean haveGreyObjects() {
    final Log trace = Log.noopLog().string("[Space.GreyObjectsWalker.haveGreyObjects:");
    /* Any difference is a difference. */
    boolean result = false;
    result |= (getAlignedHeapChunk().notEqual(space.getLastAlignedHeapChunk()));
    result |= (getAlignedHeapChunk().isNonNull() && alignedTop.notEqual(getAlignedHeapChunk().getTop()));
    result |= (getUnalignedHeapChunk().notEqual(space.getLastUnalignedHeapChunk()));
    trace.string("  returns: ").bool(result).string("]").newline();
    return result;
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 28 with Log

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

the class GreyObjectsWalker method walkUnalignedGreyObjects.

private boolean walkUnalignedGreyObjects(final ObjectVisitor visitor) {
    final Log trace = Log.noopLog().string("[Space.GreyObjectsWalker.walkUnalignedGreyObjects:");
    /* Visit the Objects in the UnalignedChunk after the snapshot UnalignedChunk. */
    UnalignedHeapChunk.UnalignedHeader uChunk;
    if (getUnalignedHeapChunk().isNull()) {
        uChunk = space.getFirstUnalignedHeapChunk();
    } else {
        uChunk = getUnalignedHeapChunk().getNext();
    }
    while (uChunk.isNonNull()) {
        trace.newline();
        trace.string("  uChunk: ").hex(uChunk);
        if (!UnalignedHeapChunk.walkObjectsFrom(uChunk, UnalignedHeapChunk.getUnalignedHeapChunkStart(uChunk), visitor)) {
            /* Log the failure. */
            Log.log().string("[Space.GreyObjectsWalker.walkUnalignedGreyObjects:  uChunk.walkObject fails.]").newline();
            return false;
        }
        /* Move the scan point. */
        setUnalignedHeapChunk(uChunk);
        trace.string("  moved unaligned scan point to: ").string("  unalignedChunk: ").hex(getUnalignedHeapChunk());
        /* Step to the next AlignedChunk. */
        uChunk = uChunk.getNext();
    }
    trace.string("  returns true").string("]").newline();
    return true;
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 29 with Log

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

the class GreyObjectsWalker method walkGreyObjects.

boolean walkGreyObjects(final ObjectVisitor visitor) {
    final Log trace = Log.noopLog().string("[Space.GreyObjectsWalker.walkGreyObjects:");
    while (haveGreyObjects()) {
        trace.newline();
        /* Walk the grey objects. */
        if (!walkAlignedGreyObjects(visitor)) {
            /* Log the failure. */
            Log.log().string("[Space.GreyObjectsWalker.walkGreyObjects:  walkAlignedGreyObjects fails.]").newline();
            return false;
        }
        if (!walkUnalignedGreyObjects(visitor)) {
            /* Log the failure. */
            Log.log().string("[Space.GreyObjectsWalker.walkGreyObjects:  walkUnalignedGreyObjects fails.]").newline();
            return false;
        }
    }
    trace.string("  returns true").string("]").newline();
    return true;
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 30 with Log

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

the class GreyToBlackObjRefVisitor method visitObjectReferenceInline.

/**
 * This visitor is deals in *Pointers to Object references*. As such it uses Pointer.readObject
 * and Pointer.writeObject on the Pointer, not Pointer.toObject and Word.fromObject(o).
 */
@Override
@AlwaysInline("GC performance")
public boolean visitObjectReferenceInline(final Pointer objRef, boolean compressed) {
    getCounters().noteObjRef();
    final Log trace = Log.noopLog().string("[GreyToBlackObjRefVisitor.visitObjectReferenceInline:").string("  objRef: ").hex(objRef);
    if (objRef.isNull()) {
        getCounters().noteNullObjRef();
        trace.string(" null objRef ").hex(objRef).string("]").newline();
        return true;
    }
    // Read the referenced Object, carefully.
    final Pointer p = ReferenceAccess.singleton().readObjectAsUntrackedPointer(objRef, compressed);
    trace.string("  p: ").hex(p);
    // It might be null.
    if (p.isNull()) {
        getCounters().noteNullReferent();
        // Nothing to do.
        trace.string(" null").string("]").newline();
        return true;
    }
    final UnsignedWord header = ObjectHeader.readHeaderFromPointer(p);
    final ObjectHeader ohi = HeapImpl.getHeapImpl().getObjectHeader();
    // It might be a forwarding pointer.
    if (ohi.isForwardedHeader(header)) {
        getCounters().noteForwardedReferent();
        trace.string("  forwards to ");
        // Update the reference to point to the forwarded Object.
        final Object obj = ohi.getForwardedObject(header);
        ReferenceAccess.singleton().writeObjectAt(objRef, obj, compressed);
        trace.object(obj);
        if (trace.isEnabled()) {
            trace.string("  objectHeader: ").string(ohi.toStringFromObject(obj)).string("]").newline();
        }
        return true;
    }
    // It might be a real Object.
    final Object obj = p.toObject();
    // If the object is not a heap object there's nothing to do.
    if (ohi.isNonHeapAllocatedHeader(header)) {
        getCounters().noteNonHeapReferent();
        // Non-heap objects do not get promoted.
        trace.string("  Non-heap obj: ").object(obj);
        if (trace.isEnabled()) {
            trace.string("  objectHeader: ").string(ohi.toStringFromObject(obj)).string("]").newline();
        }
        return true;
    }
    // Otherwise, promote it if necessary, and update the Object reference.
    trace.string(" ").object(obj);
    if (trace.isEnabled()) {
        trace.string("  objectHeader: ").string(ohi.toStringFromObject(obj)).newline();
    }
    // Promote the Object if necessary, making it at least grey, and ...
    final Object copy = HeapImpl.getHeapImpl().promoteObject(obj);
    trace.string("  copy: ").object(copy);
    if (trace.isEnabled()) {
        trace.string("  objectHeader: ").string(ohi.toStringFromObject(copy));
    }
    // ... update the reference to point to the copy, making the reference black.
    if (copy != obj) {
        getCounters().noteCopiedReferent();
        trace.string(" updating objRef: ").hex(objRef).string(" with copy: ").object(copy);
        ReferenceAccess.singleton().writeObjectAt(objRef, copy, compressed);
    } else {
        getCounters().noteUnmodifiedReference();
    }
    trace.string("]").newline();
    return true;
}
Also used : ObjectHeader(com.oracle.svm.core.heap.ObjectHeader) Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer) AlwaysInline(com.oracle.svm.core.annotate.AlwaysInline)

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