mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
When a script thread parks its allocator arena, each class slice still holds the pages past its bump pointer that were faulted in but never carved: the rest of the huge page the bump pointer is in, and the pages the pre-fault helper faulted in ahead of it. The same applies to region chunks when the thread exits. Until another thread claims the arena, nothing carves there, so a program that continues on threads that never claim it (parse threads ahead of a check on the main thread) kept them. - scr_sa_park_arena returns those pages with MADV_DONTNEED. The next thread to claim the arena faults them in again as it carves, and they read as zero, as fresh pages do. - scr_rgn_thread_exit returns each chunk's pages past its bump on worker threads; nothing carves in an exited thread's regions. - scr_mem_release_ahead drops pre-fault requests that overlap the range and waits for one in progress before returning it, so the helper does not fault the pages in again. - scr_alloc.test.c checks that a worker that shares and carves past the huge-page switch leaves no resident pages past its frontier, keeps its blocks, and that the next thread carves on from the frontier, zeroed.