Search in sources :

Example 11 with IsolateThread

use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.

the class PosixCEntryPointSnippets method enterIsolateMT.

@Uninterruptible(reason = "Thread state not set up yet")
@SubstrateForeignCallTarget
private static int enterIsolateMT(Isolate isolate) {
    int sanityError = PosixIsolates.checkSanity(isolate);
    if (sanityError != Errors.NO_ERROR) {
        return sanityError;
    }
    if (UseHeapBaseRegister.getValue()) {
        setHeapBase(PosixIsolates.getHeapBase(isolate));
    }
    if (!PosixVMThreads.isInitialized()) {
        return Errors.UNINITIALIZED_ISOLATE;
    }
    IsolateThread thread = PosixVMThreads.VMThreadTL.get();
    if (VMThreads.isNullThread(thread)) {
        return Errors.UNATTACHED_THREAD;
    }
    writeCurrentVMThread(thread);
    return Errors.NO_ERROR;
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) Safepoint(com.oracle.svm.core.thread.Safepoint) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 12 with IsolateThread

use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.

the class PosixCEntryPointSnippets method detachThreadSnippet.

@Snippet
public static int detachThreadSnippet() {
    int result = Errors.NO_ERROR;
    if (MultiThreaded.getValue()) {
        IsolateThread thread = CEntryPointContext.getCurrentIsolateThread();
        result = runtimeCall(DETACH_THREAD_MT, thread);
    }
    if (UseHeapBaseRegister.getValue()) {
        writeCurrentVMHeapBase(WordFactory.nullPointer());
    }
    return result;
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) Safepoint(com.oracle.svm.core.thread.Safepoint) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 13 with IsolateThread

use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.

the class SubstrateUtil method dumpVMThreads.

@NeverInline("catch implicit exceptions")
private static void dumpVMThreads(Log log) {
    log.string("VMThreads info:").newline();
    log.indent(true);
    for (IsolateThread vmThread = VMThreads.firstThread(); vmThread != VMThreads.nullThread(); vmThread = VMThreads.nextThread(vmThread)) {
        log.string("VMThread ").zhex(vmThread.rawValue()).spaces(2).string(VMThreads.StatusSupport.getStatusString(vmThread)).newline();
    }
    log.indent(false);
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 14 with IsolateThread

use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.

the class SubstrateUtil method printDiagnostics.

/**
 * Prints extensive diagnostic information to the given Log.
 */
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate during printing diagnostics.")
public static void printDiagnostics(Log log, Pointer sp, CodePointer ip) {
    if (diagnosticsInProgress) {
        log.string("Error: printDiagnostics already in progress.").newline();
        BreakpointNode.breakpoint();
        return;
    }
    diagnosticsInProgress = true;
    log.newline();
    try {
        dumpJavaFrameAnchors(log);
    } catch (Exception e) {
        dumpException(log, "dumpJavaFrameAnchors", e);
    }
    try {
        dumpDeoptStubPointer(log);
    } catch (Exception e) {
        dumpException(log, "dumpDeoptStubPointer", e);
    }
    try {
        dumpTopFrame(log, sp, ip);
    } catch (Exception e) {
        dumpException(log, "dumpTopFrame", e);
    }
    try {
        dumpVMThreads(log);
    } catch (Exception e) {
        dumpException(log, "dumpVMThreads", e);
    }
    IsolateThread currentThread = CEntryPointContext.getCurrentIsolateThread();
    try {
        dumpVMThreadState(log, currentThread);
    } catch (Exception e) {
        dumpException(log, "dumpVMThreadState", e);
    }
    try {
        dumpRecentVMOperations(log);
    } catch (Exception e) {
        dumpException(log, "dumpRecentVMOperations", e);
    }
    dumpRuntimeCompilation(log);
    try {
        dumpCounters(log);
    } catch (Exception e) {
        dumpException(log, "dumpCounters", e);
    }
    try {
        dumpStacktraceRaw(log, sp);
    } catch (Exception e) {
        dumpException(log, "dumpStacktraceRaw", e);
    }
    try {
        dumpStacktraceStage0(log, sp, ip);
    } catch (Exception e) {
        dumpException(log, "dumpStacktraceStage0", e);
    }
    try {
        dumpStacktraceStage1(log, sp, ip);
    } catch (Exception e) {
        dumpException(log, "dumpStacktraceStage1", e);
    }
    try {
        dumpStacktrace(log, sp, ip);
    } catch (Exception e) {
        dumpException(log, "dumpStacktrace", e);
    }
    if (VMOperationControl.isFrozen()) {
        for (IsolateThread vmThread = VMThreads.firstThread(); vmThread != VMThreads.nullThread(); vmThread = VMThreads.nextThread(vmThread)) {
            if (vmThread == CEntryPointContext.getCurrentIsolateThread()) {
                continue;
            }
            try {
                dumpStacktrace(log, vmThread);
            } catch (Exception e) {
                dumpException(log, "dumpStacktrace", e);
            }
        }
    }
    diagnosticsInProgress = false;
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) RestrictHeapAccess(com.oracle.svm.core.annotate.RestrictHeapAccess)

Example 15 with IsolateThread

use of org.graalvm.nativeimage.IsolateThread in project graal by oracle.

the class CEntryPointNativeFunctions method getCurrentThread.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "current_thread", documentation = { "Given an isolate to which the current thread is attached, returns the address of", "the thread's associated isolate thread structure.  If the current thread is not", "attached to the passed isolate or if another error occurs, returns NULL." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static IsolateThread getCurrentThread(Isolate isolate) {
    int result = CEntryPointActions.enterIsolate(isolate);
    if (result != 0) {
        return WordFactory.nullPointer();
    }
    IsolateThread thread = CEntryPointContext.getCurrentIsolateThread();
    if (CEntryPointActions.leave() != 0) {
        thread = WordFactory.nullPointer();
    }
    return thread;
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Aggregations

IsolateThread (org.graalvm.nativeimage.IsolateThread)20 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)5 Log (com.oracle.svm.core.log.Log)3 Safepoint (com.oracle.svm.core.thread.Safepoint)3 NeverInline (com.oracle.svm.core.annotate.NeverInline)2 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)2 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)2 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)2 Pointer (org.graalvm.word.Pointer)2 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)1 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)1 StackFrameVisitor (com.oracle.svm.core.stack.StackFrameVisitor)1 HashMap (java.util.HashMap)1 Snippet (org.graalvm.compiler.api.replacements.Snippet)1