镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Bridge: implement managed references, identity, and lifetime semantics #159

Closed

Description

@chrisbbreuer

Parent: #138
Depends on: Objective-C inventory and core behavior children

Implement cycle-safe Objective-C/JavaScript ownership rather than relying on incidental NSObject or arena lifetime.

Acceptance:

  • Implement JSManagedValue factory/init/value behavior and conditional clearing after collection.
  • Implement JSVirtualMachine addManagedReference:withOwner: and removeManagedReference:withOwner: with exact owner/object pair semantics.
  • Make wrapper caches preserve Objective-C/JavaScript identity without creating permanent retain cycles.
  • Define VM/context/thread/autorelease ownership, teardown order, cross-VM rejection, and weak/strong transitions.
  • Add forced-GC, autorelease-pool, nested graph, duplicate add/remove, owner death, context death, and long-running leak/finalization tests.
  • Add fault-injection coverage for every bridge allocation/registration rollback path.
    Child issue:
  • Bridge: add collection epochs and arena reachability for managed values #161 — collection epochs and arena reachability for conditional managed-value clearing

Activity

  1. chrisbbreuer commented on Jul 17, 2026

    @chrisbbreuer
    MemberAuthor

    First managed-lifetime slice landed through e1de668. JSManagedValue now uses a real JavaScript WeakRef for object targets, keeps primitives directly, and JSVirtualMachine owner relations promote targets strongly without retaining owners. Focused ARC evidence covers primitive/object identity, owner add/remove, cross-VM rejection, weak-owner teardown, and no premature loss under the current VM-lifetime arena policy. All six managed-value/VM declarations are inventoried implemented; the issue remains open for arbitrary exported-wrapper identity, autorelease/VM teardown stress, and collecting-context-group evidence (current groups intentionally retain arena values until VM teardown).

  2. chrisbbreuer commented on Jul 17, 2026

    @chrisbbreuer
    MemberAuthor

    Wrapper identity/lifetime evidence is now complete through e45bc02: Objective-C objects round-trip with pointer identity, JS object reads return canonical JSValue wrappers by strict equality even when raw C handle addresses differ, temporary VM/context/native graphs release at autorelease-pool teardown, weak owners are not retained, and cross-VM value/managed relations raise NSInvalidArgumentException. The pinned differential is 8/8 rows (bc1860c0e6e8d919). Wrapper-cache and ownership-definition acceptance boxes are checked; conditional collection, exact duplicate relation accounting, deeper stress/fault injection remain open.

  3. chrisbbreuer commented on Jul 17, 2026

    @chrisbbreuer
    MemberAuthor

    Lifetime evidence advanced through bc4d89b and c38f621. Managed roots now live on their owners, so owner death deterministically releases the rooted JSValue graph; export method/prototype caches retain raw VM-lifetime handles instead of context-retaining JSValue wrappers. zig build test-objc-api-evidence passes 200 VM/context/autorelease teardown cycles, ASan+UBSan, and Apple leaks with 0 leaked bytes. Remaining scope is explicit: conditional mid-VM clearing cannot occur under the current VM-lifetime arena policy, and bridge allocation/registration rollback still needs fault injection.

  4. chrisbbreuer commented on Jul 17, 2026

    @chrisbbreuer
    MemberAuthor

    Completed through f29ca38 with child #161 closed. Managed factories and conditional clearing, exact owner/object relations, identity caches, teardown and cross-VM rules, forced-GC/autorelease/nested/duplicate/owner-death/context-death stress, 200-cycle sanitizer/leak evidence, and deterministic rollback injection are all implemented and documented.

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