Skip to content

ABI: implement strong and weak embedding references #209

Description

@chrisbbreuer

Parent

Scope

Implement the eight shared pinned reference imports:

  • Bun__StrongRef__clear
  • Bun__StrongRef__delete
  • Bun__StrongRef__new
  • Bun__StrongRef__set
  • Bun__WeakRef__clear
  • Bun__WeakRef__delete
  • Bun__WeakRef__get
  • Bun__WeakRef__new

Acceptance criteria

  • Strong references retain the exact value across full and nursery collection, and set atomically replaces the rooted value without leaking the previous root.
  • Weak references never retain their target, clear after collection when no strong path remains, and return the exact live value beforehand.
  • Primitive, object, symbol, empty, and null/invalid inputs follow the pinned consumer boundary without manufacturing foreign-VM values.
  • Reference wrappers record and enforce owning VM/global lifetime; cross-VM replacement is rejected deterministically.
  • clear and delete are idempotent where the consumer contract permits it, are safe after target collection, and do not leave collector-visible stale pointers.
  • The pinned WeakRefType and optional context are preserved for future callback/lifecycle behavior rather than discarded accidentally.
  • Concurrent root tracing versus set/clear/get/delete is synchronized and covered without collector or wrapper use-after-free.
  • Focused precise-GC, lifecycle, invalid-input, and multi-VM tests pass; Home/Bun inventories, combined fixture, API docs, README evidence, and parent trackers are regenerated.

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