use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.
the class VMThreadCounterOperation method createThread.
private static Thread createThread(IsolateThread isolateThread) {
/*
* Either the main thread, or VMThread was started a different way. Create a new Thread
* object and remember it for future calls, so that currentThread always returns the same
* object.
*/
// The thread has not been launched as java.lang.Thread, so we consider it a daemon thread.
boolean isDaemon = true;
final Thread thread = JavaThreads.fromTarget(new Target_java_lang_Thread(null, null, isDaemon));
if (!assignJavaThread(isolateThread, thread, true)) {
return currentThread.get(isolateThread);
}
return thread;
}
use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.
the class Deoptimizer method deoptimizeFrame.
/**
* Deoptimizes the given frame.
*
* @param ignoreNonDeoptimizable if set to true, a frame that cannot be deoptimized is ignored
* instead of raising an error (use for deoptimzation testing only).
*/
@NeverInline("Inlining of this method would require that we have deopt targets for callees of this method (SVM internals).")
public static void deoptimizeFrame(Pointer sourceSp, boolean ignoreNonDeoptimizable, SpeculationReason speculation) {
DeoptimizedFrame deoptFrame = Deoptimizer.checkDeoptimized(sourceSp);
if (deoptFrame != null) {
/* Already deoptimized, so nothing to do. */
registerSpeculationFailure(deoptFrame.getSourceInstalledCode(), speculation);
return;
}
IsolateThread currentThread = CEntryPointContext.getCurrentIsolateThread();
VMOperation.enqueueBlockingSafepoint("DeoptimizeFrame", () -> Deoptimizer.deoptimizeFrameOperation(sourceSp, ignoreNonDeoptimizable, speculation, currentThread));
}
use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.
the class PinnedAllocatorImpl method open.
@Override
public PinnedAllocator open() {
if (phase != LifeCyclePhase.INITIALIZED) {
throw new PinnedAllocationLifecycleError("PinnedAllocatorImpl.open: Already opened.");
}
if (openPinnedAllocator.get() != null) {
throw new PinnedAllocationLifecycleError("PinnedAllocatorImpl.open: Only one PinnedAllocator can be open per thread");
}
/*
* Push this pinnedAllocatorImpl to the list of pinned allocators and try to find a pinned
* chunk to reuse.
*/
/* Capture "this", the tlab, and the current VMThread for the VMOperation. */
final PinnedAllocatorImpl pinnedAllocatorImpl = this;
final ThreadLocalAllocation.Descriptor tlab = ThreadLocalAllocation.pinnedTLAB.getAddress();
final IsolateThread requestingVMThread = CEntryPointContext.getCurrentIsolateThread();
VMOperation.enqueueBlockingSafepoint("PinnedAllocatorImpl.open", () -> {
openPinnedAllocator.set(requestingVMThread, this);
pinnedAllocatorImpl.phase = LifeCyclePhase.OPENED;
pinnedAllocatorImpl.pushPinnedAllocatorImpl();
pinnedAllocatorImpl.tryReuseExistingChunk(tlab);
});
assert phase == LifeCyclePhase.OPENED : "PinnedAllocatorImpl.open: VMOperation failed to open.";
return this;
}
use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.
the class VMThreadCounterOperation method detachThread.
/**
* Detach the provided Java thread. Note that the Java thread might not have been created, in
* which case it is null and we have nothing to do.
*/
public static void detachThread(IsolateThread vmThread) {
/*
* Caller must hold the lock or I, and my callees, would have to be annotated as
* Uninterruptible.
*/
VMThreads.THREAD_MUTEX.assertIsLocked("Should hold the VMThreads mutex.");
// Disable thread-local allocation for this thread.
Heap.getHeap().disableAllocation(vmThread);
// Detach ParkEvents for this thread, if any.
final Thread thread = currentThread.get(vmThread);
if (thread == null) {
return;
}
detachParkEvent(getUnsafeParkEvent(thread));
detachParkEvent(getSleepParkEvent(thread));
if (!thread.isDaemon()) {
singleton().nonDaemonThreads.decrementAndGet();
}
}
use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.
the class VMThreadCounterOperation method getAllStackTraces.
static Map<Thread, StackTraceElement[]> getAllStackTraces() {
Map<Thread, StackTraceElement[]> result = new HashMap<>();
VMOperation.enqueueBlockingSafepoint("getAllStackTraces", () -> {
for (IsolateThread cur = VMThreads.firstThread(); cur.isNonNull(); cur = VMThreads.nextThread(cur)) {
result.put(JavaThreads.singleton().createIfNotExisting(cur), getStackTrace(cur));
}
});
return result;
}
Aggregations