Commit graph

1 commit

Author SHA1 Message Date
2a18860260 docs: gc-cycle sample — inferred GC + mark-sweep address/pointer flow
Design-first deliverable for iteration 7b (no runtime/compiler code yet).
docs/examples/gc-cycle explains, by example, how pointers flow through the heap
and the collector's mark-sweep logic:

- types.wo: Node (self-referential ?Node -> inferred `gc`/traced) vs Segment
  (acyclic -> `owned`, deterministically dropped)
- main.wo: ring_demo builds a->b->c->a and abandons it; owned_demo shows the
  drop path with no collector
- README.md: the model (ownership frees the 99%, tracing only the cyclic/
  aliased residue, inference decides), the 16-byte header rewrite (retire
  rc+borrow -> 8-byte sweep-list link, colors in flag bits), where a traced
  pointer lives (root via pc gc-mask / GCREF field / container), and the
  tri-color incremental algorithm with the Yuasa deletion barrier. Two mermaid
  step diagrams (heap+roots, collector cycle) + the owned contrast.

Grounded in the approved spec (2026-08-11-inferred-gc-mark-sweep-design.md) and
the real runtime structures (obj.h/wob.h: wo_hdr, WO_K_GCREF, arena, wo_obj_size).

Run status: honest — the sample does NOT build today; woc reports WO-E301
(use-after-move at the ring-closing store), which is exactly the aliasing that
"traced classes alias freely" unblocks under 7b. README records this.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 14:14:50 +02:00