fix: do not update last_opcode_pos when emitting OP_debug#3
Merged
Conversation
OP_debug is a transparent no-op (0 pop, 0 push) used solely for debugger breakpoints. Setting last_opcode_pos to point at OP_debug breaks all peephole optimizations that rely on get_prev_opcode(), because they see OP_debug instead of the real preceding opcode. Affected code paths include: - js_is_live_code(): misidentifies dead code as live - set_object_name(): fails to match OP_set_name / OP_set_class_name - lvalue parsing: falls into the default (invalid lvalue) branch - set_object_name_computed(): fails to rewrite opcodes This caused CI test failures when OP_debug was always emitted. Fix: stop updating last_opcode_pos in emit_source_loc(), making OP_debug transparent to the peephole optimizer, just like OP_source_loc already is.
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.
OP_debugis a transparent no-op (0 pop, 0 push) used solely for debugger breakpoints. The previous code inemit_source_loc()setlast_opcode_posto point atOP_debug:This breaks all peephole optimizations that rely on
get_prev_opcode(), because they seeOP_debuginstead of the real preceding opcode.Affected code paths
js_is_live_code()set_object_name()OP_set_name/OP_set_class_name, skips name assignmentset_object_name_computed()js_parse_unary)This caused CI test failures when
OP_debugwas always emitted (after removing theemit_debugflag).Fix
Remove
fd->last_opcode_pos = bc->size;fromemit_source_loc(), makingOP_debugtransparent to the peephole optimizer — just likeOP_source_localready is. Neither opcode updateslast_opcode_pos.