Memregion pool no handle (#26110)

Co-authored-by: SirOlaf <34164198+SirOlaf@users.noreply.github.com>
(cherry picked from commit 43f7631b1c)
This commit is contained in:
Andreas Rumpf
2026-08-17 12:22:53 +02:00
committed by narimiran
parent 84a5613c35
commit 4feb16edff
8 changed files with 460 additions and 59 deletions

View File

@@ -19,6 +19,13 @@ when not defined(useNimRtl):
threadType = ThreadType.NimThread
when hasThreadLocalAllocator and not emulatedThreadVars:
proc setupForeignThreadGc*() {.gcsafe, raises: [].} =
initThreadAllocator()
proc tearDownForeignThreadGc*() {.gcsafe, raises: [].} =
releaseThreadAllocator()
when defined(gcDestructors):
proc deallocThreadStorage(p: pointer) = c_free(p)
else:
@@ -79,6 +86,8 @@ else:
deallocThreadStorage(thrd.rawStack)
proc threadProcWrapStackFrame[TArg](thrd: ptr Thread[TArg]) {.raises: [].} =
when hasThreadLocalAllocator:
initThreadAllocator()
when defined(boehmgc):
boehmGC_call_with_stack_base(threadProcWrapDispatch[TArg], thrd)
elif not defined(nogc) and not defined(gogc) and not defined(gcRegions) and not usesDestructors:
@@ -93,6 +102,8 @@ proc threadProcWrapStackFrame[TArg](thrd: ptr Thread[TArg]) {.raises: [].} =
when declared(deallocOsPages): deallocOsPages()
else:
threadProcWrapDispatch(thrd)
when hasThreadLocalAllocator:
releaseThreadAllocator()
template nimThreadProcWrapperBody*(closure: untyped): untyped =
var thrd = cast[ptr Thread[TArg]](closure)