Move DEF(debug) to end of opcode list to preserve opcode numbering#2
Merged
Move DEF(debug) to end of opcode list to preserve opcode numbering#2
Conversation
The commit 1e05bd7 added OP_debug to quickjs-opcode.h but did not regenerate the pre-compiled bytecode files. This shifted all opcode numbers by +1, causing the interpreter to misparse the bytecode stream and trigger "invalid atom index" errors. Regenerated all bytecode files using `make codegen` with the updated qjsc compiler that includes the OP_debug opcode. Agent-Logs-Url: https://github.com/G-Yong/quickjs/sessions/9ded3eef-eaab-421f-a1d7-0fca19fee48d Co-authored-by: G-Yong <21030893+G-Yong@users.noreply.github.com>
Instead of inserting OP_debug at position 1 (which shifted all subsequent opcode numbers and broke pre-compiled bytecode), place it after all short opcodes at the end of the opcode list. This way: - All regular and short opcodes keep their upstream positions - OP_debug gets a new unique index (246) that doesn't conflict - Future upstream merges won't cause bytecode incompatibilities - The codegen check passes with no stale bytecode Agent-Logs-Url: https://github.com/G-Yong/quickjs/sessions/96e96c96-17d4-40c3-8131-ec6375bb30c8 Co-authored-by: G-Yong <21030893+G-Yong@users.noreply.github.com>
…ode list Place the new OP_debug opcode after all short opcodes instead of right after OP_invalid. Inserting it near the top of the table shifts every subsequent opcode number by one, which silently invalidates all pre-compiled bytecode files (gen/*.c, builtin-*.h) and causes "invalid atom index" errors at runtime. By appending it at the end of the DEF list (but before the temporary 'def' opcodes), no existing opcode value changes, so the checked-in bytecode files remain valid and no regeneration step is required. OP_debug is only emitted at compile time when a debug context is active (JS_NewDebugContext) and never appears in pre-compiled bytecode, so its exact numeric value is irrelevant to stored bytecode compatibility. Agent-Logs-Url: https://github.com/G-Yong/quickjs/sessions/33150476-2312-48c9-98b4-113ff7039512 Co-authored-by: G-Yong <21030893+G-Yong@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
G-Yong
April 1, 2026 06:42
View session
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.
Inserting
DEF(debug, 1, 0, 0, none)at position 1 (afterOP_invalid) shifts every subsequent opcode number by +1, invalidating all pre-compiled bytecode files (gen/*.c,builtin-*.h) and causing"invalid atom index"errors at runtime.DEF(debug)to end of opcode list — placed after all short opcodes, before temporarydefopcodes. No existing opcode values change, so checked-in bytecode files remain valid with no regeneration needed.OP_debugis only emitted when a debug context is active (JS_NewDebugContext) and never appears in pre-compiled bytecode, so its numeric position is unconstrained.