mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
A postMessage or workerData graph whose objects and arrays are all frozen, ordinary and hold only primitives, strings and such containers is now shared by pointer: every node and string becomes immortal (rc == SIZE_MAX, so retains, releases and the cycle collector skip it and nothing frees it), strings cache their key hash first, and the nodes leave the sender's cycle buffers. Posting an already published root is O(1). Anything else is cloned as before; SCRIPTC_PUBLISH=0 turns publication off and SCRIPTC_PUBLISH_TRACE=1 reports each choice. With the receiver freezing what it receives (Node's clone is not frozen) and no identity comparison across messages, the behavior matches Node's structured clone. Published nodes leave the RC audit's live counts, since they are never freed, and the small-integer dyn cache becomes process-wide (filled before main): a published graph can outlive the thread that created its nodes, and the thread-local table died with its thread. The new corpus program pins that contract both ways, including a worker-published graph read after the worker exited and a shallowly frozen graph that must still be cloned.