Fix bytecode stack frame printing (#686)

Handle OP_get_loc0_loc1 specially. Fixes an off-by-one when printing
variable names.

Fixes: https://github.com/quickjs-ng/quickjs/issues/683
This commit is contained in:
Ben Noordhuis 2024-11-14 22:50:42 +01:00 committed by GitHub
parent 6d7448ed3e
commit b5d41818e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28783,8 +28783,17 @@ static void dump_byte_code(JSContext *ctx, int pass,
printf(",%u", get_u16(tab + pos + 8)); printf(",%u", get_u16(tab + pos + 8));
break; break;
case OP_FMT_none_loc: case OP_FMT_none_loc:
idx = (op - OP_get_loc0_loc1) % 4; if (op == OP_get_loc0_loc1) {
goto has_loc; printf(" 0, 1 ; ");
if (var_count > 0)
print_atom(ctx, vars[0].var_name);
if (var_count > 1)
print_atom(ctx, vars[1].var_name);
} else {
idx = (op - OP_get_loc0) % 4;
goto has_loc;
}
break;
case OP_FMT_loc8: case OP_FMT_loc8:
idx = get_u8(tab + pos); idx = get_u8(tab + pos);
goto has_loc; goto has_loc;