mirror of
https://github.com/bellard/quickjs.git
synced 2025-12-31 05:39:10 +03:00
slightly faster lexical variable assignment
This commit is contained in:
@@ -168,6 +168,7 @@ DEF( set_var_ref, 3, 1, 1, var_ref) /* must come after put_var_ref */
|
|||||||
DEF(set_loc_uninitialized, 3, 0, 0, loc)
|
DEF(set_loc_uninitialized, 3, 0, 0, loc)
|
||||||
DEF( get_loc_check, 3, 0, 1, loc)
|
DEF( get_loc_check, 3, 0, 1, loc)
|
||||||
DEF( put_loc_check, 3, 1, 0, loc) /* must come after get_loc_check */
|
DEF( put_loc_check, 3, 1, 0, loc) /* must come after get_loc_check */
|
||||||
|
DEF( set_loc_check, 3, 1, 1, loc) /* must come after put_loc_check */
|
||||||
DEF( put_loc_check_init, 3, 1, 0, loc)
|
DEF( put_loc_check_init, 3, 1, 0, loc)
|
||||||
DEF(get_loc_checkthis, 3, 0, 1, loc)
|
DEF(get_loc_checkthis, 3, 0, 1, loc)
|
||||||
DEF(get_var_ref_check, 3, 0, 1, var_ref)
|
DEF(get_var_ref_check, 3, 0, 1, var_ref)
|
||||||
|
|||||||
15
quickjs.c
15
quickjs.c
@@ -18346,6 +18346,18 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
|||||||
sp--;
|
sp--;
|
||||||
}
|
}
|
||||||
BREAK;
|
BREAK;
|
||||||
|
CASE(OP_set_loc_check):
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
idx = get_u16(pc);
|
||||||
|
pc += 2;
|
||||||
|
if (unlikely(JS_IsUninitialized(var_buf[idx]))) {
|
||||||
|
JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE);
|
||||||
|
goto exception;
|
||||||
|
}
|
||||||
|
set_value(ctx, &var_buf[idx], JS_DupValue(ctx, sp[-1]));
|
||||||
|
}
|
||||||
|
BREAK;
|
||||||
CASE(OP_put_loc_check_init):
|
CASE(OP_put_loc_check_init):
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
@@ -34757,7 +34769,7 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
|
|||||||
/* Transformation: dup put_x(n) drop -> put_x(n) */
|
/* Transformation: dup put_x(n) drop -> put_x(n) */
|
||||||
int op1, line2 = -1;
|
int op1, line2 = -1;
|
||||||
/* Transformation: dup put_x(n) -> set_x(n) */
|
/* Transformation: dup put_x(n) -> set_x(n) */
|
||||||
if (code_match(&cc, pos_next, M3(OP_put_loc, OP_put_arg, OP_put_var_ref), -1, -1)) {
|
if (code_match(&cc, pos_next, M4(OP_put_loc, OP_put_loc_check, OP_put_arg, OP_put_var_ref), -1, -1)) {
|
||||||
if (cc.line_num >= 0) line_num = cc.line_num;
|
if (cc.line_num >= 0) line_num = cc.line_num;
|
||||||
op1 = cc.op + 1; /* put_x -> set_x */
|
op1 = cc.op + 1; /* put_x -> set_x */
|
||||||
pos_next = cc.pos;
|
pos_next = cc.pos;
|
||||||
@@ -34865,6 +34877,7 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
|
|||||||
goto no_change;
|
goto no_change;
|
||||||
#endif
|
#endif
|
||||||
case OP_put_loc:
|
case OP_put_loc:
|
||||||
|
case OP_put_loc_check:
|
||||||
case OP_put_arg:
|
case OP_put_arg:
|
||||||
case OP_put_var_ref:
|
case OP_put_var_ref:
|
||||||
if (OPTIMIZE) {
|
if (OPTIMIZE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user