Skip to content

ABI: implement private Promise creation, downcasts, and wrapping #189

Description

@chrisbbreuer

Parent: #140
Tracks: #163, #164
Depends on: #180

Implement the coherent native Promise and aliased InternalPromise creation/downcast/wrapping slice shared by the pinned Home and Bun private-JSC profiles.

Exact ABI scope

  • JSC__AnyPromise__wrap
  • JSC__JSPromise__create
  • JSC__JSPromise__rejectedPromise
  • JSC__JSPromise__rejectedPromiseValue
  • JSC__JSPromise__resolvedPromise
  • JSC__JSPromise__resolvedPromiseValue
  • JSC__JSPromise__wrap
  • JSC__JSValue__asInternalPromise
  • JSC__JSValue__asPromise
  • JSC__JSValue__createInternalPromise

Acceptance

  • Create fresh pending promises in the selected global realm with the selected Promise.prototype.
  • Treat JSInternalPromise as the pinned ABI alias of JSPromise; both downcasts accept only live native Promise cells from any live VM and reject primitives, ordinary objects, exception cells, and empty values.
  • Make pointer-returning and encoded-value constructors preserve the exact promise cell/handle contract.
  • Make resolved/rejected constructors store the exact supplied value directly without thenable assimilation; same-VM sibling values are accepted and foreign-VM values fail with a VM-shared TypeError.
  • Match JSPromise__wrap: consume callback exceptions into rejection, reject returned Error instances, pass through returned native promises unchanged, and directly fulfill ordinary callback results.
  • Match AnyPromise__wrap: settle the supplied pending native promise, consume callback exceptions into rejection, reject returned Error instances, and use normal Promise resolution for ordinary results including thenable assimilation and self-resolution rejection.
  • Cover callback reentrancy, exception identity/clearing, value identity, realm/prototype selection, already-settled targets, and invalid handles in the combined compile-link-runtime fixture.
  • Regenerate Home/Bun inventories, keep exact ABI verification green, update README/ABI documentation and parent issue evidence, and publish focused validation results.

JSC__JSValue___then and application-specific async/rejection notification hooks are intentionally outside this child because they require the separate host-function/reaction callback ABI rather than this creation and settlement boundary.

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