Skip to content

Commit 4350a9f

Browse files
committed
Fix using OP_push_bigint_i32 opcode
1 parent 68d4017 commit 4350a9f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

quickjs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24832,7 +24832,17 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
2483224832
if (JS_VALUE_GET_TAG(val) == JS_TAG_INT) {
2483324833
emit_op(s, OP_push_i32);
2483424834
emit_u32(s, JS_VALUE_GET_INT(val));
24835+
} else if (JS_VALUE_GET_TAG(val) == JS_TAG_SHORT_BIG_INT) {
24836+
int64_t v;
24837+
v = JS_VALUE_GET_SHORT_BIG_INT(val);
24838+
if (v >= INT32_MIN && v <= INT32_MAX) {
24839+
emit_op(s, OP_push_bigint_i32);
24840+
emit_u32(s, v);
24841+
} else {
24842+
goto large_number;
24843+
}
2483524844
} else {
24845+
large_number:
2483624846
if (emit_push_const(s, val, 0) < 0)
2483724847
return -1;
2483824848
}
@@ -32895,6 +32905,7 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
3289532905
break;
3289632906

3289732907
case OP_push_bigint_i32:
32908+
{
3289832909
/* transform i32(val) neg -> i32(-val) */
3289932910
val = get_i32(bc_buf + pos + 1);
3290032911
if (val != INT32_MIN
@@ -32912,6 +32923,8 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
3291232923
pos_next = cc.pos;
3291332924
break;
3291432925
}
32926+
}
32927+
goto no_change;
3291532928

3291632929
case OP_push_const:
3291732930
case OP_fclosure:

0 commit comments

Comments
 (0)