mirror of
https://github.com/bellard/quickjs.git
synced 2025-11-15 10:12:14 +03:00
optimized post_inc and post_dec
This commit is contained in:
39
quickjs.c
39
quickjs.c
@@ -19045,11 +19045,42 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
||||
}
|
||||
BREAK;
|
||||
CASE(OP_post_inc):
|
||||
{
|
||||
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):
|
||||
sf->cur_pc = pc;
|
||||
if (js_post_inc_slow(ctx, sp, opcode))
|
||||
goto exception;
|
||||
sp++;
|
||||
{
|
||||
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):
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user