Skip to content

fix(wave-1): ECMA-404 JSON.parse, process exit/rejections, worker Date/exit, CLI flags (v0.10.9) - #65

Merged
siktec-lab merged 2 commits into
mainfrom
fix/wave-1-v0.10.9
Nov 11, 2026
Merged

siktec-lab merged 2 commits into
mainfrom
fix/wave-1-v0.10.9

Conversation

@siktec-lab

@siktec-lab siktec-lab commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary (Wave 1 — v0.10.9)

Closes the Wave 1 issues covering ECMA-404 JSON.parse conformance & performance, process lifecycle & unhandled rejection/uncaught exception handling, worker_threads Date & process.exit semantics, and standard CLI flags.

1. Iterative ECMA-404 JSON.parse Engine (#47, #61)

  • Replaced the serde_json::Deserializer (try_fast_parse_json_str) fast-path and boa_parser + ByteCompiler reviver fallback in vendor/boa_engine/src/builtins/json/mod.rs with a direct iterative ECMA-404 state-machine parser (Json::parse_ecma404) over JsStrVariant::Latin1(&[u8]) and JsStrVariant::Utf16(&[u16]).
  • Exact IEEE-754 Floats & Overflow: Uses fast_float2::parse::<f64, _> for exact round-to-nearest-even f64 conversion (9007199254740993.0 === 9007199254740992, 1e23, subnormals), unboxed 15-digit exact integer accumulation, -0.0 preservation, and ±Infinity on exponent overflow (1e400, -1e400).
  • UTF-16 Lone Surrogates & Fast Escapes: Preserves unpaired high/low surrogates (\ud800, \udfff) in both JSON.parse and JSON.stringify (try_fast_stringify), zero-copy slices unescaped strings, and chunks Latin-1 escaped strings via extend_from_slice into a 1-byte JsStr::latin1 buffer.
  • Deep Nesting (MAX_DEPTH = 2048), Direct Slot Insertion & reviver context.source: Uses an explicit heap-allocated Vec<ContainerFrame> stack (O(1) C/Rust call stack) supporting up to 2048 nesting levels, direct PropertyMap::insert_data_property slot insertion on fresh objects, and primitive source-span tracking for reviver context.source.

2. Process Lifecycle, Exit Codes, Unhandled Rejections & Uncaught Exceptions (#48)

  • Implemented __slice_process_exit(code) native host binding returning an uncatchable PanicError (is_catchable() == false) so process.exit(code) immediately unwinds past try / catch, Promise reactions, microtasks, and timers.
  • Wired SliceHostHooks::promise_rejection_tracker on boa_engine::Context to track rejected Promises (Track / Handled). Unhandled rejections after microtask draining either dispatch process.emit('unhandledRejection', reason, promise) or fail with Uncaught (in promise) <reason> and exit code 1.
  • Added process.on('beforeExit'), process.on('exit'), process.on('uncaughtException'), process.on('uncaughtExceptionMonitor'), and process.exitCode propagation gated behind a DIRTY_PROCESS bitmask for zero overhead when process is untouched.

3. worker_threads Date Serialization & process.exit(code) (#57)

  • Removed the catchable JS process.exit override in 18_intl.js so workers calling process.exit(code) (even when process is referenced) invoke __slice_process_exit(code), immediately notifying worker_self_set_listening(false, Some(code)) and propagating child_isolate.last_exit_code() to worker.on('exit', code).
  • Updated __serReplacer / __serReviver in 09_workers.js to check this[k] instanceof Date prior to Date.prototype.toJSON coercion (preserving Date instances, Invalid Date, NaN, and ±Infinity across workerData, postMessage, and MessageChannel).

4. CLI Ergonomics (#49, #63)

  • Added -e / --eval, -p / --print, -c / --check (slice check), -v / -V / --version, stdin (- and piped stdin), process.argv script argument forwarding, and non-zero process exit code propagation.

@siktec-lab
siktec-lab merged commit d3b6c0d into main Nov 11, 2026
3 checks passed
@siktec-lab
siktec-lab deleted the fix/wave-1-v0.10.9 branch November 11, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment