ReviewOS

zig-utils/zig-js

C embedding: schedule moving GC for the next safe JIT checkpoint

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

Parent: #336 Related: #351, #355, #356, #359

#359 added a safe scheduled-moving boundary for Zig embedders, but C and Objective-C hosts can currently only attempt immediate quiescent compaction. Expose the same scheduling primitive without permitting movement inside an arbitrary native callback.

Scope:

  • add a C extension that returns whether a precise-GC context accepted a pending compaction request;
  • invalid, arena-backed, and unsupported contexts fail deterministically without state changes;
  • requests made inside a native callback only set the pending bit; direct reentrant compaction remains unsupported;
  • after the callback unwinds, a warmed baseline numeric tier may consume the request at its movement-safe checkpoint, or a later quiescent direct call may consume it;
  • prove a protected C handle survives the scheduled in-tier move, while unprotected raw-value lifetime documentation remains explicit;
  • update the public extension header, API inventory/audit, Objective-C host coverage, relocation docs, release matrix, and concise README only if the public boundary changes its statement.

Acceptance:

  • the scheduling call is visible and signature-complete in C/C++/Objective-C headers and audits;
  • a callback-scheduled request remains non-moving during callback execution and is consumed at the declared native checkpoint;
  • exact compaction metrics remain available through the existing direct status API, and protected-handle identity/semantics survive;
  • Debug, ReleaseSafe, TSan, C/C++ and Objective-C hosts, and all ABI inventories are green.
9 days ago

Implemented and pushed in 7b82cf9. ZJSContextRequestGarbageCompaction is now a signature-complete C/Objective-C extension and returns false for null or arena contexts. The C witness protects its callback argument, proves immediate reentrant compaction remains unsupported, schedules movement, unwinds, then enters a warmed numeric tier that consumes the request at its movement-safe checkpoint. The protected wrapper remains valid while its payload address changes and properties survive. Objective-C also schedules then consumes through the direct boundary. Debug, ReleaseSafe, and TSan each passed 8/8 with zero leaks; C/C++ and Objective-C hosts, 117/117 C audit plus 22 extensions/354 private exports, 108/108 Objective-C audit, relocation inventory, and release matrix validation are green.

Sign in to comment on this issue.