Skip to content

ABI: implement FFI host functions with native data #252

Description

@chrisbbreuer

Goal

Implement the four pinned Home/Bun FFI host-function exports as the next layer over #248 and #251: Bun__CreateFFIFunctionValue, Bun__CreateFFIFunctionWithDataValue, Bun__FFIFunction_getDataPtr, and Bun__FFIFunction_setDataPtr.

Parent tracking: #134, #140, #163, #164.

Required implementation

  • Reuse the exact JSC64 CallFrame callback path while preserving FFI symbol names, arity, callable metadata, and optional raw function-pointer field semantics.
  • Store nullable native data independently from engine-private callback metadata and expose exact get/set behavior only for validated FFI functions.
  • Preserve same-VM sibling calls, upstream constructor callbacks, nested/reentrant calls, pending exceptions, and precise-GC liveness; accept any valid FFI cell in data get/set while rejecting ordinary functions and immediates.
  • Define explicit behavior for null callbacks, null names/data, repeated mutation, dynamic-library metadata, and invalid/ordinary values.
  • Promote both inventories and update README/API/Home/ABI evidence.

Evidence gate

  • Compiled consumer invokes all four exports and validates exact CallFrame arguments plus native data through mutation, GC, sibling realms, and error paths.
  • Home/Bun inventories retain zero unclassified declarations.
  • Targeted host-function/FFI runtime matrix passes; broad testing remains batched.
  • Current benchmark remains linked unless measured workload code changes.

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