Skip to content

ABI: implement generic no-copy ArrayBuffer and TypedArray adoption #218

Description

@chrisbbreuer

Parent: #134
Profile umbrella: #140
Home inventory: #163
Bun inventory: #164
Builds on: #215, #216, and #217

Implement the pinned private-JSC no-copy exports:

  • Bun__makeArrayBufferWithBytesNoCopy
  • Bun__makeTypedArrayWithBytesNoCopy

Acceptance criteria:

  • ArrayBuffer creation adopts the exact non-empty byte pointer and length without copying.
  • TypedArray creation supports every pinned numeric TypedArrayType tag: Int8, Uint8, Uint8Clamped, Int16, Uint16, Int32, Uint32, Float16, Float32, Float64, BigInt64, and BigUint64.
  • TypedArray length is floor(byte_length / element_size) while the adopted backing ArrayBuffer retains the full byte length, matching JSC for trailing bytes.
  • TypeNone, DataView, unknown tags, and non-empty null pointers fail explicitly through the private pending exception boundary.
  • Empty input returns live zero-length objects without dereferencing the pointer.
  • The caller-supplied deallocator and context run exactly once at GC/realm teardown; null deallocators are supported without inventing ownership callbacks.
  • Allocation or view-construction failures release transferred storage exactly once and never publish a partial object.
  • Focused tests and the Home consumer fixture cover pointer identity, all tags, trailing bytes, empty input, invalid tags, callback context, exactly-once release, and public accessor compatibility.
  • Inventories, ABI docs, README scorecard, and parent trackers publish the verified counts; benchmark scores remain unchanged unless a benchmark path is rerun.

Completed evidence

Implemented in d8396f26 and documented in c8ffaf00. Focused tests passed 3/3 with zero leaks; the batched engine/consumer/audit gate passed 15/15; the Home consumer fixture passed 198/198. Home is 199/431 implemented (232 pending), Bun core is 193/421 (228 pending), and the public classifier reports 117 public, 19 extensions, and 203 private/support exports.

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