Search in sources :

Example 66 with Log

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

the class DumpRuntimeCompilation method handle.

@Override
public void handle(Signal arg0) {
    VMOperation.enqueueBlockingSafepoint("DumpRuntimeCompilation", () -> {
        Log log = Log.log();
        SubstrateUtil.dumpRuntimeCompilation(log);
        log.flush();
    });
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 67 with Log

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

the class JNIFunctions method FatalError.

/*
     * void FatalError(JNIEnv *env, const char *msg);
     */
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerVoid.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void FatalError(JNIEnvironment env, CCharPointer message) {
    Log log = Log.log().autoflush(true);
    log.string("Fatal error reported via JNI: ").string(message).newline();
    VMThreads.StatusSupport.setStatusIgnoreSafepoints();
    SubstrateUtil.printDiagnostics(log, KnownIntrinsics.readCallerStackPointer(), KnownIntrinsics.readReturnAddress());
    LogHandler.get().fatalError();
}
Also used : Log(com.oracle.svm.core.log.Log) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 68 with Log

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

the class VMOperationControlFeature method enqueue.

/**
 * Queue a VMOperation and drain all the queued operations. This is over-engineered now because
 * I execute a VMOperation as soon as it is enqueued, and I hold a lock (preventing further
 * enqueuing) by other threads while I do that.
 */
public static void enqueue(VMOperation operation) {
    final Log trace = SubstrateOptions.TraceVMOperations.getValue() ? Log.log() : Log.noopLog();
    trace.string("[VMOperationControl.enqueue:").string("  operation: ").string(operation.getName());
    boolean needsCallback = ThreadingSupportImpl.singleton().needsCallbackOnSafepointCheckSlowpath();
    long callbackTime = 0;
    int callbackValue = 0;
    /*
         * Policy: Only one thread at a time can drain the queues. This mimics HotSpot's single
         * "VMThread", which probably saves a lot of locking or atomics.
         */
    /*
         * If I am not already the owner of the VMOperation, then acquire the lock, and release it
         * as I exit.
         */
    final boolean needLockUnlock = !isLockOwner();
    if (needLockUnlock) {
        if (needsCallback) {
            /*
                 * While a VMOperation is running, periodic callbacks are suspended because we
                 * cannot let arbitrary user code run, e.g., during GC. We save the state here so
                 * that we can restore it below after releasing the lock again.
                 */
            callbackTime = System.nanoTime();
            callbackValue = Safepoint.getSafepointRequested(CEntryPointContext.getCurrentIsolateThread());
        }
        getVMOperationControl().acquireLock();
    }
    try {
        // The reason is most recently queued VMOperation.
        getVMOperationControl().setReason(operation.getName());
        // Distribute the operation to the correct queue.
        if ((!operation.getBlocksCaller()) && (!operation.getCausesSafepoint())) {
            getVMOperationControl().nonBlockingNonSafepointOperations.push(operation);
        } else if ((!operation.getBlocksCaller()) && (operation.getCausesSafepoint())) {
            getVMOperationControl().nonBlockingSafepointOperations.push(operation);
        } else if ((operation.getBlocksCaller()) && (!operation.getCausesSafepoint())) {
            getVMOperationControl().blockingNonSafepointOperations.push(operation);
        } else if ((operation.getBlocksCaller()) && (operation.getCausesSafepoint())) {
            getVMOperationControl().blockingSafepointOperations.push(operation);
        }
        getVMOperationControl().drain();
    } finally {
        if (needLockUnlock) {
            getVMOperationControl().releaseLock();
            if (needsCallback) {
                ThreadingSupportImpl.singleton().onSafepointCheckSlowpath(callbackTime, callbackValue);
            }
        }
    }
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 69 with Log

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

the class VMErrorSubstitutions method shutdown.

@Uninterruptible(reason = "Allow use in uninterruptible code.", calleeMustBe = false)
static void shutdown(String msg) {
    Log log = Log.log();
    log.autoflush(true);
    log.string("VMError.shouldNotReachHere: ").string(msg).newline();
    doShutdown(log);
}
Also used : Log(com.oracle.svm.core.log.Log) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 70 with Log

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

the class VMThreadCounterOperation method waitForTearDown.

/**
 * Wait (im)patiently for the VMThreads list to drain.
 */
private static boolean waitForTearDown() {
    final Log trace = Log.noopLog().string("[JavaThreads.waitForTearDown:").newline();
    final long warningNanos = SubstrateOptions.getTearDownWarningNanos();
    final String warningMessage = "JavaThreads.waitForTearDown is taking too long.";
    final long failureNanos = SubstrateOptions.getTearDownFailureNanos();
    final String failureMessage = "JavaThreads.waitForTearDown took too long.";
    final long startNanos = System.nanoTime();
    long loopNanos = startNanos;
    final AtomicBoolean printLaggards = new AtomicBoolean(false);
    final Log counterLog = ((warningNanos == 0) ? trace : Log.log());
    final VMThreadCounterOperation operation = new VMThreadCounterOperation(counterLog, printLaggards);
    for (; ; ) /* return */
    {
        final long previousLoopNanos = loopNanos;
        operation.enqueue();
        if (operation.getCount() == 1) {
            /* If I am the only thread, then the VM is ready to be torn down. */
            trace.string("  returns true]").newline();
            return true;
        }
        loopNanos = TimeUtils.doNotLoopTooLong(startNanos, loopNanos, warningNanos, warningMessage);
        final boolean fatallyTooLong = TimeUtils.maybeFatallyTooLong(startNanos, failureNanos, failureMessage);
        if (fatallyTooLong) {
            /* I took too long to tear down the VM. */
            trace.string("Took too long to tear down the VM.").newline();
            /*
                 * Debugging tip: Insert a `BreakpointNode.breakpoint()` here to stop in gdb or get
                 * a core file with the thread stacks. Be careful about believing the stack traces,
                 * though.
                 */
            return false;
        }
        /* If I took too long, print the laggards next time around. */
        printLaggards.set(previousLoopNanos != loopNanos);
        /* Loop impatiently waiting for threads to exit. */
        Thread.yield();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Log(com.oracle.svm.core.log.Log)

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