Skip to content

Commit 9490a6d

Browse files
committed
Fix using OP_push_bigint_i32 opcode
1 parent f6c5767 commit 9490a6d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

quickjs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24930,7 +24930,17 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
2493024930
if (JS_VALUE_GET_TAG(val) == JS_TAG_INT) {
2493124931
emit_op(s, OP_push_i32);
2493224932
emit_u32(s, JS_VALUE_GET_INT(val));
24933+
} else if (JS_VALUE_GET_TAG(val) == JS_TAG_SHORT_BIG_INT) {
24934+
int64_t v;
24935+
v = JS_VALUE_GET_SHORT_BIG_INT(val);
24936+
if (v >= INT32_MIN && v <= INT32_MAX) {
24937+
emit_op(s, OP_push_bigint_i32);
24938+
emit_u32(s, v);
24939+
} else {
24940+
goto large_number;
24941+
}
2493324942
} else {
24943+
large_number:
2493424944
if (emit_push_const(s, val, 0) < 0)
2493524945
return -1;
2493624946
}
@@ -32993,6 +33003,7 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
3299333003
break;
3299433004

3299533005
case OP_push_bigint_i32:
33006+
{
3299633007
/* transform i32(val) neg -> i32(-val) */
3299733008
val = get_i32(bc_buf + pos + 1);
3299833009
if (val != INT32_MIN
@@ -33010,6 +33021,8 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
3301033021
pos_next = cc.pos;
3301133022
break;
3301233023
}
33024+
}
33025+
goto no_change;
3301333026

3301433027
case OP_push_const:
3301533028
case OP_fclosure:

0 commit comments

Comments
 (0)