From 61f31a33a073745be8946d33ecb84206d413c554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=AD=E8=8F=9C=E9=92=9F?= <312780179@qq.com> Date: Thu, 2 Apr 2026 14:13:59 +0800 Subject: [PATCH] fix: do not update last_opcode_pos when emitting OP_debug 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. --- quickjs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index da222d9d3..1c8e9ab12 100644 --- a/quickjs.c +++ b/quickjs.c @@ -23184,7 +23184,6 @@ static void emit_source_loc(JSParseState *s) dbuf_putc(bc, OP_source_loc); dbuf_put_u32(bc, s->token.line_num); dbuf_put_u32(bc, s->token.col_num); - fd->last_opcode_pos = bc->size; dbuf_putc(bc, OP_debug); }