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();
});
}
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();
}
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();
}
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);
}
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();
}
}
Aggregations