mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
The teardown of a type with children of its own type called itself for each child: a call, its register saves and the segment bookkeeping per node, 45 instructions per node in a binary tree. A record or standalone class whose every reference field holds its own type and that has no collector header now tears down in one loop. A child whose last reference the dead node held goes onto a pending list linked through its own count word, which it no longer needs, and the loop takes the list's first node next, so nodes are visited parent first. Each node frees its block as before (dispose observers, the RC audit, blocks of other arenas), the calling thread's blocks go into the teardown segment in visit order, and the segment goes onto the free list in one step, so a structure built parent first takes the blocks in its allocation order. Shared and immortal children keep their release. The loop needs no depth budget. Other teardowns keep the recursive form.