Search in sources :

Example 36 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.

the class SubstrateSegfaultHandler method dispatch.

@CEntryPoint
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate in segfault signal handler.")
@Uninterruptible(reason = "Must be uninterruptible until it gets immune to safepoints", calleeMustBe = false)
private static void dispatch(int signalNumber, @SuppressWarnings("unused") siginfo_t sigInfo, ucontext_t uContext) {
    if (dispatchInProgress) {
        Log.log().newline().string("[ [ SubstrateSegfaultHandler already handling signal ").signed(signalNumber).string(" ] ]").newline();
        return;
    }
    dispatchInProgress = true;
    VMThreads.StatusSupport.setStatusIgnoreSafepoints();
    Log log = Log.log();
    log.autoflush(true);
    log.string("[ [ SubstrateSegfaultHandler caught signal ").signed(signalNumber).string(" ] ]").newline();
    GregsPointer gregs = uContext.uc_mcontext_gregs();
    long spValue = gregs.read(Signal.GregEnum.REG_RSP.getCValue());
    long ipValue = gregs.read(Signal.GregEnum.REG_RIP.getCValue());
    log.newline().string("General Purpose Register Set Values: ").newline();
    log.indent(true);
    log.string("RAX ").zhex(gregs.read(Signal.GregEnum.REG_RAX.getCValue())).newline();
    log.string("RBX ").zhex(gregs.read(Signal.GregEnum.REG_RBX.getCValue())).newline();
    log.string("RCX ").zhex(gregs.read(Signal.GregEnum.REG_RCX.getCValue())).newline();
    log.string("RDX ").zhex(gregs.read(Signal.GregEnum.REG_RDX.getCValue())).newline();
    log.string("RBP ").zhex(gregs.read(Signal.GregEnum.REG_RBP.getCValue())).newline();
    log.string("RSI ").zhex(gregs.read(Signal.GregEnum.REG_RSI.getCValue())).newline();
    log.string("RDI ").zhex(gregs.read(Signal.GregEnum.REG_RDI.getCValue())).newline();
    log.string("RSP ").zhex(spValue).newline();
    log.string("R8  ").zhex(gregs.read(Signal.GregEnum.REG_R8.getCValue())).newline();
    log.string("R9  ").zhex(gregs.read(Signal.GregEnum.REG_R9.getCValue())).newline();
    log.string("R10 ").zhex(gregs.read(Signal.GregEnum.REG_R10.getCValue())).newline();
    log.string("R11 ").zhex(gregs.read(Signal.GregEnum.REG_R11.getCValue())).newline();
    log.string("R12 ").zhex(gregs.read(Signal.GregEnum.REG_R12.getCValue())).newline();
    log.string("R13 ").zhex(gregs.read(Signal.GregEnum.REG_R13.getCValue())).newline();
    log.string("R14 ").zhex(gregs.read(Signal.GregEnum.REG_R14.getCValue())).newline();
    log.string("R15 ").zhex(gregs.read(Signal.GregEnum.REG_R15.getCValue())).newline();
    log.string("EFL ").zhex(gregs.read(Signal.GregEnum.REG_EFL.getCValue())).newline();
    log.string("RIP ").zhex(ipValue).newline();
    log.indent(false);
    SubstrateUtil.printDiagnostics(log, WordFactory.pointer(spValue), WordFactory.pointer(ipValue));
    log.string("Use runtime option -R:-InstallSegfaultHandler if you don't want to use SubstrateSegfaultHandler.").newline();
    log.newline().string("Bye bye ...").newline().newline();
    LogHandler.get().fatalError();
}
Also used : Log(com.oracle.svm.core.log.Log) GregsPointer(com.oracle.svm.core.posix.headers.Signal.GregsPointer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) RestrictHeapAccess(com.oracle.svm.core.annotate.RestrictHeapAccess)

Example 37 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.

the class PosixJavaLangSubstitutions method currentTimeMillis.

@Substitute
@Uninterruptible(reason = "Called from uninterruptible code.")
public static long currentTimeMillis() {
    timeval timeval = StackValue.get(SizeOf.get(timeval.class));
    timezone timezone = WordFactory.nullPointer();
    gettimeofday(timeval, timezone);
    return timeval.tv_sec() * 1_000L + timeval.tv_usec() / 1_000L;
}
Also used : Time.timezone(com.oracle.svm.core.posix.headers.Time.timezone) Time.timeval(com.oracle.svm.core.posix.headers.Time.timeval) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 38 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.

the class PosixJavaLangSubstitutions method writeEntirely.

@Uninterruptible(reason = "Called from uninterruptible code.")
static SignedWord writeEntirely(int fd, PointerBase buf, UnsignedWord count) {
    Pointer ptr = WordFactory.pointer(buf.rawValue());
    final Pointer end = ptr.add(count);
    SignedWord written;
    do {
        Errno.set_errno(0);
        written = UnistdNoTransitions.write(fd, ptr, end.subtract(ptr));
        if (written.greaterThan(0)) {
            ptr = ptr.add((int) written.rawValue());
        }
    } while (ptr.notEqual(end) && (written.notEqual(-1) || Errno.errno() == Errno.EINTR()));
    if (ptr.notEqual(buf)) {
        return WordFactory.signed(ptr.rawValue() - buf.rawValue());
    }
    return written;
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) Dirent.direntPointer(com.oracle.svm.core.posix.headers.Dirent.direntPointer) Pointer(org.graalvm.word.Pointer) SignedWord(org.graalvm.word.SignedWord) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 39 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible 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)

Example 40 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.

the class CEntryPointNativeFunctions method detachThread.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "detach_thread", documentation = { "Detaches the passed isolate thread from its isolate and discards any state or", "context that is associated with it. At the time of the call, no code may still", "be executing in the isolate thread's context.", "Returns 0 on success, or a non-zero value on failure." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int detachThread(IsolateThread thread) {
    int result = CEntryPointActions.enter(thread);
    if (result != 0) {
        CEntryPointActions.leave();
        return result;
    }
    result = CEntryPointActions.leaveDetachThread();
    return result;
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Aggregations

Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)54 Pointer (org.graalvm.word.Pointer)15 UnsignedWord (org.graalvm.word.UnsignedWord)9 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)7 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)5 IsolateThread (org.graalvm.nativeimage.IsolateThread)5 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)4 Safepoint (com.oracle.svm.core.thread.Safepoint)4 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)4 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)4 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)4 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)3 Substitute (com.oracle.svm.core.annotate.Substitute)3 Log (com.oracle.svm.core.log.Log)3 Time.timespec (com.oracle.svm.core.posix.headers.Time.timespec)3 Time.timeval (com.oracle.svm.core.posix.headers.Time.timeval)3 Time.timezone (com.oracle.svm.core.posix.headers.Time.timezone)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)3