← board

C corpus: Duktape — JS engine (GC + IEEE-754 corners)

Why Duktape

A small embeddable ECMAScript (JS) engine — exercises a class nothing else in the corpus does: garbage collection (mark/sweep + refcount), IEEE-754 double edge semantics (NaN/Inf, rounding, % on doubles, string<->number), tagged values, a bytecode VM with big dispatch. Would have caught the v186 float-literal bug from another angle. Real embedded C, portable C99, no computed-goto dependency (unlike QuickJS/ micropython, whose fast paths want &&label).

Verified shape (do not re-derive)

The plan (mirror tcc)

  1. Vendor via tools/install_lib_candidates.sh (fetch pinned Duktape release, generate the amalgamation with host tools at fetch time, PROVENANCE.md w/ commit).
  2. Host + runner: compile duktape.c + a minimal command-line (duk_cmdline.c or a ~50-line eval-file main) with $(COMPILER) -Ilib/crtl/include -Ilib/crtl/src. make test-duktape: run a curated subset of tests/ecmascript/*.js, compare stdout to each test's expected block. Start with a smoke set (arithmetic, strings, arrays, closures, JSON), then widen.
  3. Blocker loop (same as tcc): compile → run → cascade of cfront/crtl gaps. Expect crtl breadth gaps (math *l, snprintf corners, setjmp/longjmp — duktape uses long-jmp error handling like tcc did) interleaved with cfront/IR bugs. Reduce each to a minimal repro vs gcc, fix ONE, bXXX regression, land green. Float/GC bugs are the prize class.

Gate

make test-duktape green on the curated JS subset (byte-exact stdout). Frontend/IR changed → make test + self-host byte-identical → make stabilize && make pin. Cross via Track T. Land green; regression tests per fix. Stretch goal: run a slice of test262.

Landmines

Same as [[feature-c-corpus-chess]] (comment-brace, no ErrOutput, stabilize+pin verify). Extra: duktape leans on setjmp/longjmp (crtl already has a shim from the tcc arc — reuse it) and on double formatting (%g/%.17g round-trip) — validate string<->number against gcc byte-for-byte early, it hides subtle float bugs.

Recon log — 2026-07-09 (bring-up attempt, parked at wall #1)

RESULT: duktape 2.7.0 compiles + links + heap-inits under pxx (pinned v191). Blocked on a runtime segfault in the first duk_peval_string — [[bug-c-duktape-double-formatting]] (setjmp/longjmp shim prime suspect). make test-duktape NOT wired yet (won't land a red gate until the smoke runs green).

Regressions for the cfront fixes: test/cpreproc_macro_arg_string_paren_b227.c, test/cpreproc_stdc_version_predefine_b228.c, test/cpreproc_macro_comment_continuation_b229.c (all exit 42, wired into test-core).

[[feature-c-corpus-expansion]] · [[feature-c-corpus-chess]] · [[bug-c-preproc-missing-stdc-version-predefine]] · [[bug-c-preproc-macro-arg-string-literal-paren]] · [[bug-c-duktape-double-formatting]] · [[feature-c-compiler-dynarrays]] · [[feature-c-cmdline-define-flag]]

Log