Search in sources :

Example 41 with Uninterruptible

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

the class CEntryPointNativeFunctions method tearDownIsolate.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "tear_down_isolate", documentation = { "Tears down the passed isolate, waiting for any attached threads to detach from", "it, then discards the isolate's objects, threads, and any other state or context", "that is associated with it.", "Returns 0 on success, or a non-zero value on failure." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int tearDownIsolate(Isolate isolate) {
    int result = CEntryPointActions.enterAttachThread(isolate);
    if (result != 0) {
        CEntryPointActions.leave();
        return result;
    }
    result = CEntryPointActions.leaveTearDownIsolate();
    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)

Example 42 with Uninterruptible

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

the class CEntryPointNativeFunctions method attachThread.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "attach_thread", documentation = { "Attaches the current thread to the passed isolate.", "On failure, returns a non-zero value. On success, writes the address of the", "created isolate thread structure to the passed pointer and returns 0.", "If the thread has already been attached, the call succeeds and also provides", "the thread's isolate thread structure." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int attachThread(Isolate isolate, IsolateThreadPointer thread) {
    int result = CEntryPointActions.enterAttachThread(isolate);
    if (result == 0) {
        thread.write(CEntryPointContext.getCurrentIsolateThread());
        result = CEntryPointActions.leave();
    }
    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)

Example 43 with Uninterruptible

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

the class CEntryPointNativeFunctions method getCurrentIsolate.

@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "current_isolate", documentation = { "Given an isolate thread structure for the current thread, determines to which", "isolate it belongs and returns the address of its isolate structure.  If an", "error occurs, returns NULL instead." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static Isolate getCurrentIsolate(IsolateThread thread) {
    int result = CEntryPointActions.enter(thread);
    if (result != 0) {
        return WordFactory.nullPointer();
    }
    Isolate isolate = CEntryPointContext.getCurrentIsolate();
    if (CEntryPointActions.leave() != 0) {
        isolate = WordFactory.nullPointer();
    }
    return isolate;
}
Also used : Isolate(org.graalvm.nativeimage.Isolate) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 44 with Uninterruptible

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

the class PthreadThreadLocal method initialize.

@Uninterruptible(reason = "Called from uninterruptible code. Too early for safepoints.")
public void initialize() {
    CIntPointer keyPtr = StackValue.get(SizeOf.get(CIntPointer.class));
    PthreadVMLockSupport.checkResult(Pthread.pthread_key_create(keyPtr, WordFactory.nullPointer()), "pthread_key_create");
    key = keyPtr.read();
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 45 with Uninterruptible

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

the class DarwinSubstitutions method nanoTime.

@Substitute
@Uninterruptible(reason = "Does basic math after a few simple system calls")
private static long nanoTime() {
    final Util_java_lang_System utilJavaLangSystem = ImageSingletons.lookup(Util_java_lang_System.class);
    if (utilJavaLangSystem.fastTime) {
        return mach_absolute_time();
    }
    if (!utilJavaLangSystem.timeBaseValid) {
        MachTimebaseInfo timeBaseInfo = StackValue.get(SizeOf.get(MachTimebaseInfo.class));
        if (mach_timebase_info(timeBaseInfo) == 0) {
            if (timeBaseInfo.getdenom() == 1 && timeBaseInfo.getnumer() == 1) {
                utilJavaLangSystem.fastTime = true;
                return mach_absolute_time();
            }
            utilJavaLangSystem.factor = (double) timeBaseInfo.getnumer() / (double) timeBaseInfo.getdenom();
        }
        utilJavaLangSystem.timeBaseValid = true;
    }
    if (utilJavaLangSystem.factor != 0) {
        return (long) (mach_absolute_time() * utilJavaLangSystem.factor);
    }
    /* High precision time is not available, fall back to low precision. */
    timeval timeval = StackValue.get(SizeOf.get(timeval.class));
    timezone timezone = WordFactory.nullPointer();
    gettimeofday(timeval, timezone);
    return timeval.tv_sec() * 1_000_000_000L + timeval.tv_usec() * 1_000L;
}
Also used : Time.timezone(com.oracle.svm.core.posix.headers.Time.timezone) MachTimebaseInfo(com.oracle.svm.core.posix.headers.darwin.DarwinTime.MachTimebaseInfo) Time.timeval(com.oracle.svm.core.posix.headers.Time.timeval) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) Substitute(com.oracle.svm.core.annotate.Substitute)

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