Problem
Precise Environment and Promise edges can point either to GC cells or to valid embedded/arena allocations. The generic Visitor.isManaged path safely accepts arbitrary pointers, but an unmanaged valid pointer can fall back to scanning the complete live-cell list. The embedded global Environment made that fallback especially expensive during young collections.
Implemented design
- persist exact immutable ownership on Environment.gc_managed and the existing Promise.gc_owned field immediately after allocation;
- derive ownership from the current thread active cell allocator, not merely from Context configuration;
- dispatch precise Environment and Promise edges directly through those flags;
- reject new markManaged pointee types at compile time until they provide explicit ownership metadata;
- keep broad Visitor.isManaged behavior unchanged for genuinely untrusted boundaries;
- require no zig-gc dependency API change.
Evidence
- alternating clean-baseline/current object_churn runs: 867.854 ms vs 824.063 ms median, about 5.0% less time;
- fresh final 100-job x 7-sample run: zig-js 871.043 ms vs JSC 120.567 ms, exact checksum 1030552128;
- symbolized profile reduced headerForPayload from roughly 1,800 samples to 28;
- full zig-js suite: 751/751 passed, 0 skipped/failed/leaked;
- benchmark harness: 7/7 passed.
Acceptance criteria
- Precise typed edges do not enter broad live-list fallback.
- Managed closure/environment/promise graphs survive full and minor collection.
- Embedded and arena-owned valid typed objects are rejected safely.
- Exact benchmark checksum remains 1030552128.
- Direct object_churn throughput materially improves.
- Focused tests and the final batched suite pass.