mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-02 07:43:42 +08:00
Every unbounded recursion repeats some cycle of the call graph, so a stack check in one function of each cycle bounds it. stackCheckedFunctions now picks a feedback vertex set of the stack-check graph greedily (the function with the most caller-callee pairs first) instead of checking every function on a cycle, and adds a check where a run of unchecked cycle functions would exceed 32 calls, so the stack used between two checks stays of the same order as before. Worker entry polls follow: a synchronous function on a cycle that may throw needs no entry poll, since a descent that never returns ends at a checked function of its cycle. NoThrow contracts keep the model in which every function on a cycle checks, a superset that does not depend on the choice.