Format:V8 code cache
| Endianness | little-endian |
|---|---|
| On this wiki | Facts · Code · Notes · Topics |
The cachedData blob of V8 (Script::CreateCodeCache, node vm cachedData, bytenode .jsc): a header with magic, version hash, source hash, flag hash and checksums followed by the serialized bytecode payload.
Header (src/snapshot/code-serializer.h, SerializedCodeData)
All fields u32 except the source hash (SHA-256 sized, 32 bytes) at the head of V8 main:
| Offset | Field |
|---|---|
| 0 | magic number (kMagicNumber; depends on the build's external reference table size) |
| 4 | version hash (Version::Hash(): major, minor, build, patch, embedder string)
|
| 8 | source hash, 32 bytes |
| 40 | flag hash (FlagList::Hash())
|
| 44 | read-only snapshot checksum |
| 48 | payload length |
| 52 | trusted payload length |
| 56 | checksum |
| 60 | end of unaligned header; the payload starts at the pointer-aligned header size (64 on 64-bit) |
Older V8 versions have a smaller header (source hash was a u32 length-based value). The sanity check returns one of: success, magic number mismatch, version mismatch, source mismatch, flags mismatch, checksum mismatch, invalid header, length mismatch, read-only snapshot checksum mismatch.
Update (v8 bbe5d06b): the table above matches code-serializer.h lines 111-129 at that commit; the header ends at 60 and is padded to 64. The magic is 0xC0DE0000 XOR the external reference table size, so bytes 2-3 are DE C0 in every build. The source hash is either SHA-256 or a length word, see Fact:V8 code cache/behavior/Source hash is a SHA-256 or a length word. The order in which V8 rejects a cache is in Fact:V8 code cache/behavior/Order of rejection checks. The wire format is documented for bytenode in Tool:Bytenode.
Flag hash
ComputeFlagListHash hashes the names and values of every non-default flag plus build settings (ptr-compr when pointer compression is on, debug, x64-stack-16, flush-denormals). A cache made by a Node.js or Electron with other flags (for example --no-lazy, --jitless) is rejected with a flags mismatch even for the same V8 version.
Use
Tools such as bytenode ship JavaScript as these blobs with a dummy source. Reversing needs a matching V8 build: neither version nor flag hash is a stable format. Read from source at the pinned commit, not tested on real files.
Code & repositories
- https://github.com/v8/v8 @
6f9454b67e19ec749aebb8d9d8036735947d5489· license: BSD-3-Clause (declared by the contributor for the files used; GitHub reports BSD-3-Clause (read from LICENSE; GitHub's API was busy) for the repository)
V8 source (BSD-3-Clause). Useful without running: src/snapshot/snapshot.cc (blob header), src/snapshot/code-serializer.{h,cc} (code cache header), src/utils/version.cc, src/flags/flags.cc (ComputeFlagListHash).
Tested on: source read, not run: source read, not run · checked 2026-10-18 - https://github.com/bytenode/bytenode @
5562c8f31ce64cfbb4664ada71281feffe8172b9· license: MIT (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE; GitHub's API was busy) for the repository)
bytenode: compileCode, fixBytecode, readSourceHash, generateScript in lib/index.js (magic DE C0, dummy source of the original length, flag hash patch).
Tested on: source read, not run · checked 2026-10-19