Add versioned bytecode file support to qjsc and qjs#541
Open
zzjjob wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #540, which was automatically closed when the source fork was recreated.
Summary
qjsc -b/qjsc --bytecodeto write compiled scripts or modules directly to.qbcfilesqjs --bytecodeto load and execute those files, including module resolution, top-level await, and script argumentsCONFIG_VERSION, payload length, checksum, and reserved flagsMotivation
qjsccurrently emits C source or native executables, but it does not provide a direct file artifact for applications that want to compile JavaScript once and execute it later with the same QuickJS build. Using the rawJS_WriteObject()payload directly also provides no framing for compatibility or integrity checks.This change adds a small versioned container around the existing QuickJS bytecode representation. Files are intentionally bound to the exact QuickJS
CONFIG_VERSION; bytecode from another version is rejected with a clear diagnostic.Usage
When
-ois omitted,qjsc --bytecodewritesout.qbc. Bytecode output accepts exactly one input file and is not combined with byte-swapping.File format and trust model
The wrapper validates container structure, QuickJS version, payload length, and an FNV-1a checksum. The checksum detects accidental corruption; it is not a cryptographic signature or a sandbox boundary. As with other native bytecode formats,
.qbcfiles should be loaded only from trusted sources.Tests
make testThis PR contains only commit
a2c571acad9a4079fc0e29aacc4da7bbef94d4ffon top ofmaster.