ReviewOS

zig-utils/zig-js

ABI: implement exception scopes and termination control

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

Parent

Scope

Implement the 18 shared pinned exception/termination imports:

  • all six TopExceptionScope__* operations;
  • JSGlobalObject__clearExceptionExceptTermination, clearTerminationException, createOutOfMemoryError, requestTermination, throwOutOfMemoryError, and throwStackOverflow;
  • JSC__VM__clearHasTerminationRequest, executionForbidden, hasTerminationRequest, notifyNeedTermination, setExecutionForbidden;
  • JSC__JSValue__isTerminationException.

Acceptance criteria

  • The caller-provided 8/56-byte, 8-aligned TopExceptionScope storage retains exact VM identity, supports pure vs trap-aware exception reads, unconditional clear, assertion checking, and safe destruction without escaping stack storage.
  • Termination requests are VM-shared and thread-safe; trap-aware scope lookup materializes one stable termination exception, while pure lookup does not process a pending request.
  • Normal exceptions clear through clearExceptionExceptTermination; termination remains and returns false until clearTerminationException clears both the request and thrown termination exception.
  • VM request and execution-forbidden controls preserve the pinned behavior, including the source contract where setExecutionForbidden makes execution forbidden regardless of the boolean argument.
  • OOM creation returns a selected-realm Error without throwing; OOM and stack-overflow throw operations publish exact Error kinds while preserving the first pending exception.
  • Focused coverage includes 8- and 56-byte scope buffers, sibling realms/VM identity, normal and primitive exceptions, pending requests, materialization order, stable exception identity, classification, clearing/resumption, foreign/invalid pointers, forbidden state, OOM/stack errors, and first-exception preservation.
  • Inventories, README/API evidence, and parent trackers are regenerated from checked-in results.
9 days ago

Implemented and documented on main.

Evidence:

  • 929284a6 — 18 pinned exception-scope, termination, VM-control, and native-error imports plus regenerated inventories
  • 0de075b8 — README/API/Home/ABI evidence and current counts
  • zig build test-home-private-abi -Doptimize=Debug — 136/136 linked runtime matrix passed
  • zig build home-private-abi-audit bun-private-abi-audit — Home 137/431 (294 pending), Bun 131/421 (290 pending), zero drift/unclassified entries

Coverage includes both caller storage layouts, sibling/foreign VM isolation, normal and primitive exceptions, pure/trap-aware ordering, stable termination identity/classification, selective and explicit clearing, pinned set-only execution-forbidden behavior, selected-realm OOM/stack errors, null boundaries, and first-exception preservation. Benchmark results were intentionally not rerun or altered because this is an ABI-only slice.

Sign in to comment on this issue.