ReviewOS

zig-utils/zig-js

ABI: implement private module-loader evaluation and import

#245
Closed chris opened this 9 days ago ·
9 days ago

Parent: #140 Related: #134, #163, #164, #208

Implement the three shared private module-loader entry points against zig-js own module registry, evaluator, and Promise runtime.

Scope

  • JSC__JSModuleLoader__evaluate
  • JSC__JSModuleLoader__loadAndEvaluateModule
  • JSModuleLoader__import

Acceptance

  • evaluate must decode source/origin/referrer byte spans safely, register the provided module under the normalized origin, import it with the referrer, return the exact Promise value, and write only the pinned exception out channel when setup fails.
  • loadAndEvaluateModule and import must decode the pinned BunString representation without userland coercion and return rooted Promise cells from the selected realm.
  • Preserve module cache identity, dependency/link/evaluation ordering, top-level-await settlement, namespace identity, circular graphs, repeated imports, and referrer-relative resolution.
  • Syntax, resolution, link, and evaluation failures must reject the returned Promise or publish the exact synchronous exception boundary required by each entry point; no swallowed errors or duplicate evaluation.
  • Reject invalid spans, foreign handles, and mismatched realms safely; keep source, registry records, namespaces, and pending Promise jobs precisely rooted.
  • Add focused and compiled-consumer fixtures, refresh both pinned inventories, update README/API/ABI integration evidence and parent issues, and publish committed verification.

GetterSetter null probes are deliberately not bundled here: they require real GetterSetter/CustomGetterSetter cell handles and will be tracked with that representation instead of returning fabricated booleans.

9 days ago

Completed and pushed directly to origin/main.

Commits:

  • fc108485 — implement all three private module-loader exports, persistent supplied/filesystem loading, Promise tri-state behavior, precise graph roots, and compiled consumer coverage
  • 472ea6cf — publish Home/Bun inventory counts and README/API/ABI evidence
  • f15f65ca — link the final README-removal gate (#246)

Implemented:

  • JSC__JSModuleLoader__evaluate with the pinned fulfilled namespace / rejected out-parameter / pending Promise behavior
  • JSC__JSModuleLoader__loadAndEvaluateModule and JSModuleLoader__import with exact BunString decoding and rooted Promise-cell handles
  • normalized origin/referrer resolution, supplied-source precedence, filesystem fallback, dependency and circular linking, stable cache/namespace identity, repeated imports, and top-level await
  • safe invalid spans, null BunString rejection, foreign-VM resolution rejection, non-duplicated evaluation, and consumed-rejection tracking
  • precise roots for deferred namespaces, cached evaluation errors, completion promises, namespace waiters, and pending namespace callbacks

Verification:

  • complete module batch: 33/33, zero leaks
  • Home compiled consumer: 246/246 runtime/link matrix
  • Home inventory: 247/431 implemented, 184 pending, zero unclassified
  • Bun core inventory: 241/421 implemented, 180 pending, zero unclassified
  • Home private JSType fixture: 20 cell kinds passed
  • consolidated engine run: 877 unaffected tests passed; it exposed one stale pre-existing import.meta weak-liveness assertion after persistent registry caching, which now deletes the exact registry key before collection and passes in the complete module/GC batch

Benchmark artifact 36a617b3 remains the current 1,540-sample README comparison because this ABI-only slice does not alter its workload.

Sign in to comment on this issue.