@Override public void detachThread(IsolateThread thread) throws IsolateException { throwOnError(CEntryPointNativeFunctions.detachThread(thread)); }
@Override public void afterRegistration(AfterRegistrationAccess access) { IsolateSupportImpl.initialize(); } }
@Override public IsolateThread getCurrentThread(Isolate isolate) throws IsolateException { return CEntryPointNativeFunctions.getCurrentThread(isolate); }
@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.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.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; }
@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(); }
@Override public IsolateThread attachCurrentThread(Isolate isolate) throws IsolateException { IsolateThreadPointer isolateThread = StackValue.get(IsolateThreadPointer.class); throwOnError(CEntryPointNativeFunctions.attachThread(isolate, isolateThread)); return isolateThread.read(); }
static void leave() { int code = CEntryPointActions.leave(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
static void enter(Isolate isolate) { int code = CEntryPointActions.enterIsolate(isolate); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
public static void enter(JNIEnvironment env) { CEntryPointActions.enter((IsolateThread) env); } }
static void leave() { int code = CEntryPointActions.leaveDetachThread(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
static void leave() { int code = CEntryPointActions.leaveTearDownIsolate(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
@Override public void tearDownIsolate(IsolateThread thread) throws IsolateException { if (SubstrateOptions.SpawnIsolates.getValue()) { throwOnError(CEntryPointNativeFunctions.tearDownIsolate(thread)); } else { throw new IsolateException(ISOLATES_DISABLED_MESSAGE); } }
@CEntryPoint @CEntryPointOptions(prologue = EnterNativeTruffleContextPrologue.class, epilogue = LeaveDetachThreadEpilogue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class) static void detachCurrentThread(@SuppressWarnings("unused") NativeTruffleContext context) { }
@Override public Isolate getIsolate(IsolateThread thread) throws IsolateException { return CEntryPointNativeFunctions.getIsolate(thread); }
private static void throwOnError(int code) { if (code != CEntryPointErrors.NO_ERROR) { String message = CEntryPointErrors.getDescription(code); throw new IsolateException(message); } } }
@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; }
static void enter(NativeTruffleEnv env) { CEntryPointActions.enter(env.isolateThread()); } }
@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; }