Search in sources :

Example 96 with Log

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

the class GarbageCollectorManagementFactory method visitWatchersBefore.

@SuppressWarnings("try")
private void visitWatchersBefore() {
    final Log trace = Log.noopLog().string("[GCImpl.visitWatchersBefore:").newline();
    trace.string("  Watchers before: ");
    try (Timer wbt = watchersBeforeTimer.open()) {
        for (CollectionWatcher watcher = collectionWatcherList.getFirst(); watcher != null; watcher = watcher.getNextElement()) {
            try {
                watcher.beforeCollection();
            } catch (Throwable t) {
                trace.string("[GCImpl.visitWatchersBefore: Caught: ").string(t.getClass().getName()).string("]").newline();
            }
        }
    }
    trace.string("]").newline();
}
Also used : CollectionWatcher(com.oracle.svm.core.heap.CollectionWatcher) Log(com.oracle.svm.core.log.Log)

Example 97 with Log

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

the class GarbageCollectorManagementFactory method scavenge.

/**
 * Scavenge, either just from dirty roots or from all roots.
 *
 * Process discovered references while scavenging.
 */
@SuppressWarnings("try")
private void scavenge(boolean fromDirtyRoots) {
    final Log trace = Log.noopLog().string("[GCImpl.scavenge:").string("  fromDirtyRoots: ").bool(fromDirtyRoots).newline();
    /* Empty the list of DiscoveredReferences before walking the heap. */
    DiscoverableReferenceProcessing.clearDiscoveredReferences();
    try (Timer rst = rootScanTimer.open()) {
        trace.string("  Cheney scan: ");
        if (fromDirtyRoots) {
            cheneyScanFromDirtyRoots();
        } else {
            cheneyScanFromRoots();
        }
    }
    trace.string("  Discovered references: ");
    /* Process the list of DiscoveredReferences after walking the heap. */
    try (Timer drt = discoverableReferenceTimer.open()) {
        DiscoverableReferenceProcessing.processDiscoveredReferences();
    }
    trace.string("  Release spaces: ");
    /* Release any memory in the young and from Spaces. */
    try (Timer rst = releaseSpacesTimer.open()) {
        releaseSpaces();
    }
    trace.string("  Swap spaces: ");
    /* Exchange the from and to Spaces. */
    swapSpaces();
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 98 with Log

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

the class GarbageCollectorManagementFactory method releaseSpaces.

private void releaseSpaces() {
    final Log trace = Log.noopLog().string("[GCImpl.releaseSpaces:");
    final HeapImpl heap = HeapImpl.getHeapImpl();
    heap.getYoungGeneration().releaseSpaces();
    if (completeCollection) {
        heap.getOldGeneration().releaseSpaces();
    }
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 99 with Log

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

the class GarbageCollectorManagementFactory method walkRegisteredObjectReferences.

@SuppressWarnings("try")
private void walkRegisteredObjectReferences() {
    final Log trace = Log.noopLog().string("[walkRegisteredObjectReferences").string(":").newline();
    try (Timer wrm = walkRegisteredMemoryTimer.open()) {
        /*
             * ObjectReferenceWalkers should be pinned, otherwise they might already be forwarded.
             * Walk the list as Object so there is no type checking until I know it is safe.
             */
        Object element = objectReferenceWalkerList.getFirstObject();
        while (element != null) {
            if (!HeapImpl.getHeapImpl().isPinned(element)) {
                throw unpinnedObjectReferenceWalkerException;
            }
            element = ((AllocationFreeList.Element<?>) element).getNextObject();
        }
        /* Visit each walker. */
        for (ObjectReferenceWalker walker = objectReferenceWalkerList.getFirst(); walker != null; walker = walker.getNextElement()) {
            trace.string("[").string(walker.getWalkerName()).string(":");
            trace.newline();
            walker.walk(greyToBlackObjRefVisitor);
            trace.string("]").newline();
        }
    }
    trace.string("]").newline();
}
Also used : ObjectReferenceWalker(com.oracle.svm.core.heap.ObjectReferenceWalker) Log(com.oracle.svm.core.log.Log) AllocationFreeList(com.oracle.svm.core.heap.AllocationFreeList)

Example 100 with Log

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

the class GarbageCollectorManagementFactory method collectImpl.

@SuppressWarnings("try")
private void collectImpl(String cause) {
    final Log trace = Log.noopLog().string("[GCImpl.collectImpl:").newline().string("  epoch: ").unsigned(getCollectionEpoch()).string("  cause: ").string(cause).newline();
    VMOperation.guaranteeInProgress("Collection should be a VMOperation.");
    final HeapImpl heap = HeapImpl.getHeapImpl();
    precondition();
    /*
         * Disable young generation allocations *inside* the collector, and detect any that slip in.
         */
    trace.string("  Begin collection: ");
    try (NoAllocationVerifier nav = noAllocationVerifier.open()) {
        trace.string("  Verify before: ");
        try (Timer vbt = verifyBeforeTimer.open()) {
            HeapImpl.getHeapImpl().verifyBeforeGC(cause, getCollectionEpoch());
        }
        getAccounting().beforeCollection();
        try (Timer ct = collectionTimer.open()) {
            /*
                 * Always scavenge the young generation, then maybe scavenge the old generation.
                 * Scavenging the young generation will free up the chunks from the young
                 * generation, so that when the scavenge of the old generation needs chunks it will
                 * find them on the free list.
                 *
                 */
            if (getPolicy().collectIncrementally()) {
                scavenge(true);
            }
            completeCollection = getPolicy().collectCompletely();
            if (completeCollection) {
                scavenge(false);
            }
        }
        /* Distribute any discovered references to their queues. */
        DiscoverableReferenceProcessing.Scatterer.distributeReferences();
    }
    getAccounting().afterCollection(completeCollection, collectionTimer);
    trace.string("  Verify after: ");
    try (Timer vat = verifyAfterTimer.open()) {
        heap.verifyAfterGC(cause, getCollectionEpoch());
    }
    postcondition();
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log) NoAllocationVerifier(com.oracle.svm.core.heap.NoAllocationVerifier)

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