Search in sources :

Example 1 with Isolate

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

the class PosixCEntryPointSnippets method enterSnippet.

@Snippet
public static int enterSnippet(IsolateThread thread) {
    Isolate isolate;
    if (MultiThreaded.getValue()) {
        if (thread.isNull()) {
            return Errors.NULL_ARGUMENT;
        }
        writeCurrentVMThread(thread);
        isolate = PosixVMThreads.IsolateTL.get(thread);
    } else {
        // single-threaded
        if (SpawnIsolates.getValue()) {
            if (thread.isNull()) {
                return Errors.NULL_ARGUMENT;
            }
        } else if (!thread.equal(CEntryPointSetup.SINGLE_THREAD_SENTINEL)) {
            return Errors.UNATTACHED_THREAD;
        }
        isolate = (Isolate) ((Word) thread).subtract(CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND);
    }
    if (UseHeapBaseRegister.getValue()) {
        setHeapBase(PosixIsolates.getHeapBase(isolate));
    }
    if (MultiThreaded.getValue()) {
        Safepoint.transitionNativeToJava();
    }
    return Errors.NO_ERROR;
}
Also used : Word(org.graalvm.compiler.word.Word) Isolate(org.graalvm.nativeimage.Isolate) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 2 with Isolate

use of org.graalvm.nativeimage.Isolate 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)

Aggregations

Isolate (org.graalvm.nativeimage.Isolate)2 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 Snippet (org.graalvm.compiler.api.replacements.Snippet)1 Word (org.graalvm.compiler.word.Word)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1