mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
Every heap dyn node carries a cycle header, so a member read of a parsed document (parsed[i], JSON.stringify's walk) left each container it touched in the candidate buffer and the collector traced the document over and over. JSON.parse now tags the containers it builds with one shared region that stays intact until the first store into any of them that could close a cycle (a reference store; primitive and immortal stores, removals and permutations keep it). Releases of intact containers skip buffering. The flag is per region, not per container: a cycle can run through a container that was never written (child.parent = root), and the last outside reference to it may be dropped from that container. The write barrier sits in the checked-dynamic writers (arr_push, obj_put, key_set, define_property, reflect_define, set_prototype, symbol and named-property tables, the reviver walk, unshift/splice/fill). A missed barrier would leak a cycle, which the RC audit reports; walks and teardowns are unchanged, so it cannot free live data. Also corrects the collector header comment, which listed dyn trees as headerless.