Subtrees โ
Simple explanation โ
Instead of allocating each syntax node separately, the runtime stores all nodes of a tree in one flat pool. Sharing and copying whole regions then means copying plain records, not chasing pointers.
Technical explanation โ
tree/subtree.zig defines Subtree: symbol, production id, byte/point spans, child slice location (children_start + child_count), parent index, named/descendant counts, flags (named, visible, extra, missing, error), and reuse_state (the LR state at the node's start). SubtreePool owns the two backing arrays. Children are u32 indices into the same pool, so cloning a region is a memcpy-style walk that rewrites parent links โ the mechanism behind incremental reuse.
