quickjs demo

Compiles Fabrice Bellard’s QuickJS JavaScript engine with badc and runs QuickJS’s own test suite through the resulting qjs CLI.

Layout

Running

python3 demos/quickjs/setup.py     # fetch the source (needs a GitHub token while the repo is private)
python3 demos/quickjs/smoke.py     # build qjsc + qjs, run the tests
python3 demos/quickjs/bench.py     # badc vs clang, -O0 and -O

The smoke compiles the upstream source unmodified – no patch. DIRECT_DISPATCH (computed-goto opcode dispatch), CONFIG_ATOMICS and CONFIG_STACK_CHECK are left at their upstream defaults, which enable them on every supported host. CONFIG_ALL_UNICODE is enabled on top of the upstream default: it compiles libunicode’s normalization tables and the Unicode-aware String.prototype.normalize / localeCompare.

Test coverage

Windows is skipped. The engine itself is target-clean – quickjs.c compiles for windows-x64 and windows-arm64 – but quickjs-libc’s OS layer needs surface badc does not provide for Windows targets. Stubbing each in turn walks the chain: _putenv (quickjs-libc.c:774), then the POSIX directory API (DIR at quickjs-libc.c:2744; <dirent.h> is entirely #ifndef _WIN32), then struct _utimbuf (quickjs-libc.c:2910; badc keeps it in <sys/utime.h>, which <utime.h> does not pull in).

HAVE_CLOSEFROM follows the target: badc’s <unistd.h> declares closefrom on the Linux targets, where glibc 2.34 and later export it, and nowhere else – neither libSystem nor msvcrt has the function. Upstream gates the same define on a compile probe, so this matches what upstream would detect.

^ To the top