Skip to content

Bridge: add collection epochs and arena reachability for managed values #161

Description

@chrisbbreuer

Parent: #159
Related: #138, #144

Implement correct JSManagedValue conditional clearing before shared precise-GC context groups are available, without pretending the arena reclaimed storage. The bridge must distinguish semantic reachability from physical VM-lifetime allocation.

Acceptance:

  • Add a quiescent, cycle-safe reachability walk over every realm root in one JSContextGroupRef, traversing all strong runtime cell kinds and ignoring WeakRef/weak-collection edges.
  • Publish a collection epoch for JSGarbageCollect so managed values clear only after an explicit collection point, not merely on property access.
  • Keep managed values alive while any registered owner relation exists; owner death and exact add/remove pairs must update this state without retain cycles.
  • Clear an unowned JSManagedValue after collection when unreachable, while preserving targets reachable from globals, closures, promises/microtasks, modules, and sibling realms.
  • Add focused C/Zig reachability tests plus Objective-C forced-GC/system-JSC differential rows and fault-injection rollback tests.
  • Document that semantic weak clearing is immediate at the collection epoch even though arena storage is physically reclaimed only at VM teardown.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions