@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; }
@Override public IsolateThread createIsolate(CreateIsolateParameters parameters) throws IsolateException { if (!SubstrateOptions.SpawnIsolates.getValue()) { throw new IsolateException(ISOLATES_DISABLED_MESSAGE); } CEntryPointCreateIsolateParameters params = StackValue.get(CEntryPointCreateIsolateParameters.class); params.setReservedSpaceSize(parameters.getReservedAddressSpaceSize()); params.setVersion(1); IsolateThreadPointer isolateThreadPtr = StackValue.get(IsolateThreadPointer.class); throwOnError(CEntryPointNativeFunctions.createIsolate(params, WordFactory.nullPointer(), isolateThreadPtr)); return isolateThreadPtr.read(); }
@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; }
@Override public IsolateThread attachCurrentThread(Isolate isolate) throws IsolateException { IsolateThreadPointer isolateThread = StackValue.get(IsolateThreadPointer.class); throwOnError(CEntryPointNativeFunctions.attachThread(isolate, isolateThread)); return isolateThread.read(); }