static void leave() { int code = CEntryPointActions.leave(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
@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(IsolateThread isolateThread) { int result = CEntryPointActions.enter(isolateThread); if (result != 0) { CEntryPointActions.leave(); return result; } return CEntryPointActions.leaveTearDownIsolate(); }
@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; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished) @CEntryPointBuiltinImplementation(builtin = Builtin.ATTACH_THREAD) public static IsolateThread attachThread(Isolate isolate) { IsolateThread result = WordFactory.nullPointer(); int status = CEntryPointActions.enterAttachThread(isolate); if (status == 0) { result = CurrentIsolate.getCurrentThread(); status = CEntryPointActions.leave(); } return result; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished) @CEntryPointBuiltinImplementation(builtin = Builtin.DETACH_THREAD) public static int detachThread(IsolateThread thread) { int status = CEntryPointActions.enter(thread); if (status != 0) { CEntryPointActions.leave(); return status; } status = CEntryPointActions.leaveDetachThread(); return status; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished) @CEntryPointBuiltinImplementation(builtin = Builtin.TEAR_DOWN_ISOLATE) public static int tearDownIsolate(IsolateThread isolateThread) { int result = CEntryPointActions.enter(isolateThread); if (result != 0) { CEntryPointActions.leave(); return result; } result = CEntryPointActions.leaveTearDownIsolate(); return result; }
@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(CurrentIsolate.getCurrentThread()); result = CEntryPointActions.leave(); } return result; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished) @CEntryPointBuiltinImplementation(builtin = Builtin.CREATE_ISOLATE) public static IsolateThread createIsolate() { IsolateThread result = WordFactory.nullPointer(); int status = CEntryPointActions.enterCreateIsolate(WordFactory.nullPointer()); if (status == 0) { result = CurrentIsolate.getCurrentThread(); CEntryPointActions.leave(); } return result; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished) @CEntryPointBuiltinImplementation(builtin = Builtin.GET_ISOLATE) public static Isolate getIsolate(IsolateThread thread) { int status = CEntryPointActions.enter(thread); if (status != 0) { return WordFactory.nullPointer(); } Isolate isolate = CurrentIsolate.getIsolate(); if (CEntryPointActions.leave() != 0) { isolate = WordFactory.nullPointer(); } return isolate; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint(name = "get_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 = CurrentIsolate.getCurrentThread(); if (CEntryPointActions.leave() != 0) { thread = WordFactory.nullPointer(); } return thread; }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, publishAs = Publish.NotPublished) @CEntryPointBuiltinImplementation(builtin = Builtin.GET_CURRENT_THREAD) public static IsolateThread getCurrentThread(Isolate isolate) { int status = CEntryPointActions.enterIsolate(isolate); if (status != 0) { return WordFactory.nullPointer(); } IsolateThread thread = CurrentIsolate.getCurrentThread(); if (CEntryPointActions.leave() != 0) { thread = WordFactory.nullPointer(); } return thread; }
static void enter(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMInitArgs vmArgs) { if (!SubstrateOptions.SpawnIsolates.getValue()) { int error = CEntryPointActions.enterIsolate((Isolate) CEntryPointSetup.SINGLE_ISOLATE_SENTINEL); if (error != CEntryPointErrors.UNINITIALIZED_ISOLATE) { if (error == CEntryPointErrors.NO_ERROR) { CEntryPointActions.leave(); } CEntryPointActions.bailoutInPrologue(JNIErrors.JNI_EEXIST()); } } if (CEntryPointActions.enterCreateIsolate(WordFactory.nullPointer()) != 0) { CEntryPointActions.bailoutInPrologue(JNIErrors.JNI_ERR()); } } }
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON) @CEntryPoint(name = "create_isolate", documentation = { "Create a new isolate, considering the passed parameters (which may be NULL).", "Returns 0 on success, or a non-zero value on failure.", "On success, the current thread is attached to the created isolate, and the", "address of the isolate and the isolate thread are written to the passed pointers", "if they are not NULL."}) @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class) public static int createIsolate(CEntryPointCreateIsolateParameters params, IsolatePointer isolate, IsolateThreadPointer thread) { int result = CEntryPointActions.enterCreateIsolate(params); if (result == 0) { if (isolate.isNonNull()) { isolate.write(CurrentIsolate.getIsolate()); } if (thread.isNonNull()) { thread.write(CurrentIsolate.getCurrentThread()); } result = CEntryPointActions.leave(); } return result; }