@@ -1281,6 +1281,7 @@ static __exception int js_set_length64(JSContext *ctx, JSValue obj,
1281
1281
static void free_arg_list(JSContext *ctx, JSValue *tab, uint32_t len);
1282
1282
static JSValue *build_arg_list(JSContext *ctx, uint32_t *plen,
1283
1283
JSValue array_arg);
1284
+ static JSValue js_create_array(JSContext *ctx, int len, JSValue *tab);
1284
1285
static bool js_get_fast_array(JSContext *ctx, JSValue obj,
1285
1286
JSValue **arrpp, uint32_t *countp);
1286
1287
static JSValue JS_CreateAsyncFromSyncIterator(JSContext *ctx,
@@ -13713,26 +13714,6 @@ static JSValue js_build_mapped_arguments(JSContext *ctx, int argc,
13713
13714
return JS_EXCEPTION;
13714
13715
}
13715
13716
13716
- static JSValue js_build_rest(JSContext *ctx, int first, int argc, JSValue *argv)
13717
- {
13718
- JSValue val;
13719
- int i, ret;
13720
-
13721
- val = JS_NewArray(ctx);
13722
- if (JS_IsException(val))
13723
- return val;
13724
- for (i = first; i < argc; i++) {
13725
- ret = JS_DefinePropertyValueUint32(ctx, val, i - first,
13726
- js_dup(argv[i]),
13727
- JS_PROP_C_W_E);
13728
- if (ret < 0) {
13729
- JS_FreeValue(ctx, val);
13730
- return JS_EXCEPTION;
13731
- }
13732
- }
13733
- return val;
13734
- }
13735
-
13736
13717
static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj)
13737
13718
{
13738
13719
JSObject *p;
@@ -15148,9 +15129,11 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
15148
15129
BREAK;
15149
15130
CASE(OP_rest):
15150
15131
{
15151
- int first = get_u16(pc);
15132
+ int i, n, first = get_u16(pc);
15152
15133
pc += 2;
15153
- *sp++ = js_build_rest(ctx, first, argc, argv);
15134
+ i = min_int(first, argc);
15135
+ n = argc - i;
15136
+ *sp++ = js_create_array(ctx, n, &argv[i]);
15154
15137
if (unlikely(JS_IsException(sp[-1])))
15155
15138
goto exception;
15156
15139
}
0 commit comments