optimized post_inc and post_dec

This commit is contained in:
Fabrice Bellard
2025-10-07 19:10:27 +02:00
parent 8e8eefb922
commit e5de89fb3f

View File

@@ -19045,11 +19045,42 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
}
BREAK;
CASE(OP_post_inc):
CASE(OP_post_dec):
{
JSValue op1;
int val;
op1 = sp[-1];
if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) {
val = JS_VALUE_GET_INT(op1);
if (unlikely(val == INT32_MAX))
goto post_inc_slow;
sp[0] = JS_NewInt32(ctx, val + 1);
} else {
post_inc_slow:
sf->cur_pc = pc;
if (js_post_inc_slow(ctx, sp, opcode))
goto exception;
}
sp++;
}
BREAK;
CASE(OP_post_dec):
{
JSValue op1;
int val;
op1 = sp[-1];
if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) {
val = JS_VALUE_GET_INT(op1);
if (unlikely(val == INT32_MIN))
goto post_dec_slow;
sp[0] = JS_NewInt32(ctx, val - 1);
} else {
post_dec_slow:
sf->cur_pc = pc;
if (js_post_inc_slow(ctx, sp, opcode))
goto exception;
}
sp++;
}
BREAK;
CASE(OP_inc_loc):
{