ReviewOS

zig-utils/zig-js

GC compaction: expose exact C status and movement metrics

#356
Closed chris opened this 9 days ago ·
9 days ago

Parent: #336 Related: #334, #337, #351, #355 Roadmap: #144, #134

The newly added C compaction extension currently returns bool, conflating unsupported execution states, an already-dense heap, planning OOM, and successful movement. Backward compatibility is not a constraint before stabilization, so make the boundary exact now.

Scope

  • Define a public extension status enum for unsupported, no-candidates, out-of-memory, and compacted.
  • Return the exact status from ZJSContextCompactGarbage.
  • Expose optional moved-cell and moved-byte outputs, initialized deterministically for every status.
  • Update C, Objective-C, docs, inventories, and callback/quiescent tests.

Acceptance

  • Native callback/JIT/invalid contexts report unsupported explicitly.
  • Dense heaps report no-candidates rather than generic failure.
  • Successful movement reports compacted with nonzero exact metrics.
  • OOM remains distinguishable and output values are deterministic.
  • C/Objective-C embedding audits and focused sanitizer configurations pass.
9 days ago

Implemented and pushed as b50bbd7e. ZJSContextCompactGarbage now returns the public four-state ZJSGCCompactionStatus and fills optional moved-cell/moved-byte outputs. Outputs are zeroed before validation, so invalid context, active native callback, dense fixed point, and forced planning OOM are exact and deterministic; successful fragmented movement reports nonzero metrics. The Objective-C witness now creates real tail fragmentation instead of assuming address churn.

Validation: Debug/ReleaseSafe/TSan focused runs each 3/3 with zero leaks; C/C++ host, Objective-C host, C API audit (117/117 public, 21 extensions, 354 private), Objective-C audit (108/108), relocation inventory, and diff check passed.

Sign in to comment on this issue.