Format:QuickJS bytecode
| Magic | first byte = BC_VERSION (29 in quickjs-ng 0.17) |
|---|---|
| On this wiki | Facts · Code · Notes · Topics |
Binary object format of QuickJS (JS_WriteObject / qjsc): the first byte is BC_VERSION, followed by (quickjs-ng) a u32 checksum, a LEB128 atom table and tagged objects.
Header (quickjs-ng)
| Field | Size | Meaning |
|---|---|---|
| version | u8 | BC_VERSION, 29 at quickjs-ng commit 081d50c |
| checksum | u32 | covers the data after it; 0xFFFFFFFF skips the check |
| atom count | LEB128 | number of atoms used by this object |
| atoms | each: type u8 plus string, or 0x80 / 0xC0 forms for built-in constant atoms | |
| object | tagged value (tag byte, then payload) |
There is no magic string: identify a blob by a plausible first byte plus an atom count and readable atom strings. Unverified: original Bellard releases use another BC_VERSION and may lack the checksum, so the byte also tells the fork.
Tags
BC_TAG_ values start at 1: NULL, UNDEFINED, BOOL_FALSE, BOOL_TRUE, INT32, FLOAT64, STRING, OBJECT, ARRAY, BIG_INT, TEMPLATE_OBJECT, FUNCTION_BYTECODE, MODULE, TYPED_ARRAY, ARRAY_BUFFER, SHARED_ARRAY_BUFFER, REGEXP, DATE, OBJECT_VALUE, OBJECT_REFERENCE, MAP, SET, SYMBOL (23 tags in the pinned quickjs-ng).
Write flags
JS_WRITE_OBJ_BYTECODE 1, SAB 4, REFERENCE 8, STRIP_SOURCE 16, STRIP_DEBUG 32.
Notes
The reader refuses other versions with invalid version (%d expected=%d): the immediate compared in JS_ReadObjectAtoms gives the exact version a game uses. Do not load untrusted bytecode with JS_READ_OBJ_BYTECODE: the format is not validated.
Code & repositories
- https://github.com/quickjs-ng/quickjs @
081d50c2792c16763f0e4a62ee4fdfb902b15a67· license: MIT
quickjs-ng fork. Useful without running: quickjs.c (BCTagEnum, JS_WriteObject/JS_ReadObject near line 38470), quickjs-opcode.h, qjsc.c.
Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries