The whole VM in a snapshot
A snapshot holds the runtime, context, all objects, the heap, atoms and pending promise jobs.
Source:quickjs-wasi, README
quickjs-wasi puts QuickJS-ng inside a WebAssembly sandbox and lets you snapshot it. It is what most people reach for when they want QuickJS on a server. Here is what that costs, and what tinyscript does instead.
QuickJS on a server needs a sandbox around it, and wiring one up by hand is fiddly work.
quickjs-wasi, from Vercel Labs, compiles QuickJS-ng to a WASI reactor of about 1.4 MB and drives it from TypeScript in Node.js, Deno, Bun or a browser. Each VM is its own WebAssembly instance, with no shared memory between VMs.
Because all of the engine's state lives in linear memory, a snapshot is a copy of that memory, and a restore writes it into a fresh instance. That is a neat trick, and it works today.
A snapshot holds the runtime, context, all objects, the heap, atoms and pending promise jobs.
Source:quickjs-wasi, README
It does no implicit file or network I/O; overriding clock_time_get and random_get fixes Date.now(), Math.random and crypto.
Source:quickjs-wasi, README
Two engines in a row, a WebAssembly engine running an interpreter, pay twice for every instruction.
We built tinyscript so the sandbox is the engine itself: it only asks for a buffer and talks through messages, so nothing has to be wrapped around it. On native upstream QuickJS's own workloads, it retires fewer instructions on 17 of 18.
The trade is coverage. QuickJS-ng runs far more of the language than tinyscript does today, and quickjs-wasi runs anywhere WebAssembly does.
| Question | quickjs-wasi | tinyscript |
|---|---|---|
| Language | QuickJS-ng, scripts only | 62.9% of test262 in strict mode |
| Bounding a call | An interrupt that throws | Exact fuel; the call continues |
| Saving a run | Whole-VM snapshots between calls | Sessions saved as their values |
| Boundary | One WebAssembly instance per VM | A message interface in your process |
Most readers need one answer: which engine to try first.