mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
scr_ctx_swap now stores the callee-saved registers, stack pointer, and resume address into the outgoing ScrCtx and loads the incoming one, instead of pushing a frame onto the fiber's own stack. The register file lives where ucontext_t kept it: inside the heap ScrFiber for fibers and on the C stack for a resumer, so a suspended fiber's register-held pointers stay visible to heap scanners such as LeakSanitizer (fiber stacks are anonymous mappings they do not scan). Fresh fibers are seeded by writing the ScrCtx fields; only the top word of the new stack is touched. Layout asserts pin the struct offsets the assembly uses. The switch cost is unchanged or slightly lower (async-pipeline scale 10 on macOS arm64: 0.17-0.19 s vs 0.20-0.21 s).