diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2017-08-30 10:49:40 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2017-08-30 10:49:40 +0200 |
commit | 9b1f88cd263f8ce84a1aa2f52833f61b3e5852f8 (patch) | |
tree | 291321cd85efc6a82300dc510697525a39b6d862 | |
parent | 7003241364e9a8172039714a8b41baeb832d6c07 (diff) | |
download | pacrunner-9b1f88cd263f8ce84a1aa2f52833f61b3e5852f8.tar.gz |
duktape: Import v2.1.1
-rw-r--r-- | duktape/duk_config.h | 6 | ||||
-rw-r--r-- | duktape/duktape.c | 85 | ||||
-rw-r--r-- | duktape/duktape.h | 14 |
3 files changed, 72 insertions, 33 deletions
diff --git a/duktape/duk_config.h b/duktape/duk_config.h index 7c53949..95bdde6 100644 --- a/duktape/duk_config.h +++ b/duktape/duk_config.h @@ -1,9 +1,9 @@ /* * duk_config.h configuration header generated by genconfig.py. * - * Git commit: 1f1f51a4f9595ffe8def0e9ba45b20f14679393a - * Git describe: v2.1.0 - * Git branch: master + * Git commit: 9c8fba6392d1913cb5359be7b8f386fa3cdd8b4d + * Git describe: v2.1.1 + * Git branch: v2.1-maintenance * * Supported platforms: * - Mac OSX, iPhone, Darwin diff --git a/duktape/duktape.c b/duktape/duktape.c index ba4572c..8d2a7fd 100644 --- a/duktape/duktape.c +++ b/duktape/duktape.c @@ -1,8 +1,8 @@ /* - * Single source autogenerated distributable for Duktape 2.1.0. + * Single source autogenerated distributable for Duktape 2.1.1. * - * Git commit 1f1f51a4f9595ffe8def0e9ba45b20f14679393a (v2.1.0). - * Git branch master. + * Git commit 9c8fba6392d1913cb5359be7b8f386fa3cdd8b4d (v2.1.1). + * Git branch v2.1-maintenance. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and * licensing information. @@ -10567,7 +10567,7 @@ DUK_INTERNAL const duk_uint8_t duk_builtins_data[3819] = { 109,29,13,49,74,6,192,95,72,188,6,196,55,74,188,6,247,91,80,136,26,32,104, 220,205,56,1,98,234,52,122,98,136,14,72,110,152,162,132,148,35,61,49,70,7, 48,55,76,81,194,206,52,104,180,197,45,192,80,175,4,100,77,10,2,101,56,161, -166,65,113,162,98,8,3,131,7,169,35,36,57,176,0,0,0,0,0,40,116,208,45,158, +166,65,113,162,98,8,3,131,7,169,35,36,57,176,0,0,0,0,16,40,116,208,45,158, 10,225,223,132,17,13,43,176,228,3,0,167,129,32,17,133,134,32,25,80,220,40, 240,25,26,44,32,240,24,200,44,24,240,56,156,199,128,83,193,17,7,4,13,128,0, 10,79,202,28,223,195,1,197,72,196,141,159,220,7,48,33,7,8,3,152,49,117,60, @@ -10746,7 +10746,7 @@ DUK_INTERNAL const duk_uint8_t duk_builtins_data[3819] = { 109,29,13,49,74,6,192,95,72,188,6,196,55,74,188,6,247,91,80,136,26,32,104, 220,205,56,1,98,234,52,122,98,136,14,72,110,152,162,132,148,35,61,49,70,7, 48,55,76,81,194,206,52,104,180,197,45,192,80,175,4,100,77,10,2,101,56,161, -166,65,113,162,98,8,3,131,7,169,35,36,57,176,16,52,232,64,0,0,0,0,45,158, +166,65,113,162,98,8,3,131,7,169,35,36,57,176,16,52,232,80,0,0,0,0,45,158, 10,225,223,132,17,13,43,176,228,3,0,167,129,32,17,133,134,32,25,80,220,40, 240,25,26,44,32,240,24,200,44,24,240,56,156,199,128,83,193,17,7,4,13,128,0, 10,79,202,28,223,195,1,197,72,196,141,159,220,7,48,33,7,8,3,152,49,117,60, @@ -10925,7 +10925,7 @@ DUK_INTERNAL const duk_uint8_t duk_builtins_data[3819] = { 29,13,49,74,6,192,95,72,188,6,196,55,74,188,6,247,91,80,136,26,32,104,220, 205,56,1,98,234,52,122,98,136,14,72,110,152,162,132,148,35,61,49,70,7,48, 55,76,81,194,206,52,104,180,197,45,192,80,175,4,100,77,10,2,101,56,161,166, -65,113,162,98,8,3,131,7,169,35,36,57,176,0,40,116,208,0,0,0,0,45,158,10, +65,113,162,98,8,3,131,7,169,35,36,57,176,16,40,116,208,0,0,0,0,45,158,10, 225,223,132,17,13,43,176,228,3,0,167,129,32,17,133,134,32,25,80,220,40,240, 25,26,44,32,240,24,200,44,24,240,56,156,199,128,83,193,17,7,4,13,128,0,10, 79,202,28,223,195,1,197,72,196,141,159,220,7,48,33,7,8,3,152,49,117,60,240, @@ -13631,8 +13631,9 @@ static duk_uint8_t *duk__load_func(duk_context *ctx, duk_uint8_t *p, duk_uint8_t /* If _Formals wasn't present in the original function, the list * here will be empty. Same happens if _Formals was present but - * had zero length. We can omit _Formals from the result if its - * length is zero and matches nargs. + * had zero length. We'll omit the _Formals list if it is empty, + * regardless of whether it was present in the original or not, + * this is a workaround for https://github.com/svaarala/duktape/issues/1513. */ duk_push_array(ctx); /* _Formals */ for (arr_idx = 0; ; arr_idx++) { @@ -13644,7 +13645,16 @@ static duk_uint8_t *duk__load_func(duk_context *ctx, duk_uint8_t *p, duk_uint8_t } duk_put_prop_index(ctx, -2, arr_idx); } - if (arr_idx == 0 && h_fun->nargs == 0) { + if (arr_idx == 0) { + /* Omitting _Formals when the list is empty is technically + * incorrect because the result will differ from the input + * function. This could matter for function templates if: + * _Formals exists, _Formals.length == 0, and nargs > 0. + * This doesn't happen in practice. But if it did, it would + * affect the .length property of function instances created + * from the closure (0 with _Formals present, nargs with + * _Formals absent). + */ duk_pop(ctx); } else { duk_compact_m1(ctx); @@ -13800,7 +13810,7 @@ DUK_EXTERNAL void duk_call(duk_context *ctx, duk_idx_t nargs) { DUK_ASSERT(thr != NULL); idx_func = duk_get_top(ctx) - nargs - 1; - if (idx_func < 0 || nargs < 0) { + if (DUK_UNLIKELY(idx_func < 0 || nargs < 0)) { /* note that we can't reliably pop anything here */ DUK_ERROR_TYPE_INVALID_ARGS(thr); } @@ -13827,7 +13837,7 @@ DUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs) { DUK_ASSERT(thr != NULL); idx_func = duk_get_top(ctx) - nargs - 2; /* must work for nargs <= 0 */ - if (idx_func < 0 || nargs < 0) { + if (DUK_UNLIKELY(idx_func < 0 || nargs < 0)) { /* note that we can't reliably pop anything here */ DUK_ERROR_TYPE_INVALID_ARGS(thr); } @@ -13866,7 +13876,7 @@ DUK_EXTERNAL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs) { DUK_ASSERT(thr != NULL); idx_func = duk_get_top(ctx) - nargs - 1; /* must work for nargs <= 0 */ - if (idx_func < 0 || nargs < 0) { + if (DUK_UNLIKELY(idx_func < 0 || nargs < 0)) { /* We can't reliably pop anything here because the stack input * shape is incorrect. So we throw an error; if the caller has * no catch point for this, a fatal error will occur. Another @@ -13904,7 +13914,7 @@ DUK_EXTERNAL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs) { DUK_ASSERT(thr != NULL); idx_func = duk_get_top(ctx) - nargs - 2; /* must work for nargs <= 0 */ - if (idx_func < 0 || nargs < 0) { + if (DUK_UNLIKELY(idx_func < 0 || nargs < 0)) { /* See comments in duk_pcall(). */ DUK_ERROR_TYPE_INVALID_ARGS(thr); return DUK_EXEC_ERROR; /* unreachable */ @@ -13944,6 +13954,7 @@ DUK_LOCAL duk_ret_t duk__pcall_prop_raw(duk_context *ctx, void *udata) { } DUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs) { + duk_hthread *thr = (duk_hthread *) ctx; duk__pcall_prop_args args; /* @@ -13955,6 +13966,10 @@ DUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_i args.obj_idx = obj_idx; args.nargs = nargs; + if (DUK_UNLIKELY(nargs < 0)) { + DUK_ERROR_TYPE_INVALID_ARGS(thr); + return DUK_EXEC_ERROR; /* unreachable */ + } /* Inputs: explicit arguments (nargs), +1 for key. If the value stack * does not contain enough args, an error is thrown; this matches @@ -13970,7 +13985,7 @@ DUK_EXTERNAL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function fu DUK_ASSERT_CTX_VALID(ctx); DUK_ASSERT(thr != NULL); - if (duk_get_top(ctx) < nargs || nrets < 0) { + if (DUK_UNLIKELY(duk_get_top(ctx) < nargs || nargs < 0 || nrets < 0)) { /* See comments in duk_pcall(). */ DUK_ERROR_TYPE_INVALID_ARGS(thr); return DUK_EXEC_ERROR; /* unreachable */ @@ -14035,6 +14050,10 @@ DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs) { /* [... constructor arg1 ... argN] */ + if (DUK_UNLIKELY(nargs < 0)) { + /* note that we can't reliably pop anything here */ + DUK_ERROR_TYPE_INVALID_ARGS(thr); + } idx_cons = duk_require_normalize_index(ctx, -nargs - 1); DUK_DDD(DUK_DDDPRINT("top=%ld, nargs=%ld, idx_cons=%ld", @@ -14204,6 +14223,7 @@ DUK_LOCAL duk_ret_t duk__pnew_helper(duk_context *ctx, void *udata) { } DUK_EXTERNAL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs) { + duk_hthread *thr = (duk_hthread *) ctx; duk_int_t rc; DUK_ASSERT_CTX_VALID(ctx); @@ -14216,6 +14236,11 @@ DUK_EXTERNAL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs) { * wrapper. */ + if (DUK_UNLIKELY(nargs < 0)) { + DUK_ERROR_TYPE_INVALID_ARGS(thr); + return DUK_EXEC_ERROR; /* unreachable */ + } + rc = duk_safe_call(ctx, duk__pnew_helper, (void *) &nargs /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/); return rc; } @@ -17641,9 +17666,11 @@ DUK_EXTERNAL void duk_require_stack(duk_context *ctx, duk_idx_t extra) { } DUK_EXTERNAL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top) { + duk_hthread *thr; duk_size_t min_new_size; DUK_ASSERT_CTX_VALID(ctx); + thr = (duk_hthread *) ctx; if (DUK_UNLIKELY(top < 0)) { /* Clamping to zero makes the API more robust to calling code @@ -17652,7 +17679,7 @@ DUK_EXTERNAL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top) { top = 0; } - min_new_size = top + DUK_VALSTACK_INTERNAL_EXTRA; + min_new_size = (thr->valstack_bottom - thr->valstack) + top + DUK_VALSTACK_INTERNAL_EXTRA; return duk_valstack_resize_raw(ctx, min_new_size, /* min_new_size */ 0 /* no shrink */ | /* flags */ @@ -17661,9 +17688,11 @@ DUK_EXTERNAL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top) { } DUK_EXTERNAL void duk_require_stack_top(duk_context *ctx, duk_idx_t top) { + duk_hthread *thr; duk_size_t min_new_size; DUK_ASSERT_CTX_VALID(ctx); + thr = (duk_hthread *) ctx; if (DUK_UNLIKELY(top < 0)) { /* Clamping to zero makes the API more robust to calling code @@ -17672,7 +17701,7 @@ DUK_EXTERNAL void duk_require_stack_top(duk_context *ctx, duk_idx_t top) { top = 0; } - min_new_size = top + DUK_VALSTACK_INTERNAL_EXTRA; + min_new_size = (thr->valstack_bottom - thr->valstack) + top + DUK_VALSTACK_INTERNAL_EXTRA; (void) duk_valstack_resize_raw(ctx, min_new_size, /* min_new_size */ 0 /* no shrink */ | /* flags */ @@ -26769,7 +26798,7 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_slice_shared(duk_context *ctx) { res_proto_bidx); DUK_ASSERT(h_bufobj != NULL); - h_bufobj->length = slice_length; + DUK_ASSERT(h_bufobj->length == 0); h_bufobj->shift = h_this->shift; /* inherit */ h_bufobj->elem_type = h_this->elem_type; /* inherit */ h_bufobj->is_typedarray = magic & 0x01; @@ -26800,12 +26829,14 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_slice_shared(duk_context *ctx) { h_bufobj->buf = h_val; DUK_HBUFFER_INCREF(thr, h_val); + h_bufobj->length = slice_length; DUK_ASSERT(h_bufobj->offset == 0); duk_pop(ctx); /* reachable so pop OK */ } else { h_bufobj->buf = h_val; DUK_HBUFFER_INCREF(thr, h_val); + h_bufobj->length = slice_length; h_bufobj->offset = (duk_uint_t) (h_this->offset + start_offset); /* Copy the .buffer property, needed for TypedArray.prototype.subarray(). @@ -31227,6 +31258,7 @@ DUK_INTERNAL duk_ret_t duk_bi_function_prototype_apply(duk_context *ctx) { /* XXX: [[Construct]] newTarget currently unsupported */ DUK_ERROR_UNSUPPORTED((duk_hthread *) ctx); } + duk_set_top(ctx, 2); /* chop off extra arguments: [ constructor argArray ] */ idx_args = 1; break; } @@ -42589,7 +42621,7 @@ DUK_LOCAL const char * const duk__debug_getinfo_hobject_keys[] = { "newenv", "namebinding", "createargs", - "have_finalizer" + "have_finalizer", "exotic_array", "exotic_stringobj", "exotic_arguments", @@ -42659,7 +42691,7 @@ DUK_LOCAL void duk__debug_getinfo_bitmask(duk_hthread *thr, const char * const * for (;;) { mask = *masks++; - if (!mask) { + if (mask == 0) { break; } key = *keys++; @@ -42741,6 +42773,10 @@ DUK_LOCAL void duk__debug_handle_get_heap_obj_info(duk_hthread *thr, duk_heap *h DUK_D(DUK_DPRINT("debug command GetHeapObjInfo")); DUK_UNREF(heap); + DUK_ASSERT(sizeof(duk__debug_getinfo_hstring_keys) / sizeof(const char *) == sizeof(duk__debug_getinfo_hstring_masks) / sizeof(duk_uint_t) - 1); + DUK_ASSERT(sizeof(duk__debug_getinfo_hobject_keys) / sizeof(const char *) == sizeof(duk__debug_getinfo_hobject_masks) / sizeof(duk_uint_t) - 1); + DUK_ASSERT(sizeof(duk__debug_getinfo_hbuffer_keys) / sizeof(const char *) == sizeof(duk__debug_getinfo_hbuffer_masks) / sizeof(duk_uint_t) - 1); + h = duk_debug_read_any_ptr(thr); if (!h) { duk_debug_write_error_eom(thr, DUK_DBG_ERR_UNKNOWN, "invalid target"); @@ -60162,6 +60198,8 @@ DUK_LOCAL void duk__handle_bound_chain_for_call(duk_hthread *thr, duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_LENGTH); /* -> [ ... func this arg1 ... argN _Args length ] */ len = (duk_idx_t) duk_require_int(ctx, -1); duk_pop(ctx); + + duk_require_stack(ctx, len); for (i = 0; i < len; i++) { /* XXX: very slow - better to bulk allocate a gap, and copy * from args_array directly (we know it has a compact array @@ -70948,8 +70986,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_unary_op(duk_hthread *thr, duk_idx if (DUK_TVAL_IS_NUMBER(tv)) { d1 = DUK_TVAL_GET_NUMBER(tv); } else { - d1 = duk_to_number(ctx, idx_src); /* side effects, perform in-place */ - DUK_ASSERT(DUK_TVAL_IS_NUMBER(DUK_GET_TVAL_POSIDX(ctx, idx_src))); + d1 = duk_to_number_tval(ctx, tv); /* side effects */ } if (opcode == DUK_OP_UNP) { @@ -71001,7 +71038,9 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_not(duk_hthread *thr, duk_uint_f else #endif /* DUK_USE_FASTINT */ { - i1 = duk_to_int32(ctx, idx_src); /* side effects */ + duk_push_tval(ctx, tv); + i1 = duk_to_int32(ctx, -1); /* side effects */ + duk_pop_unsafe(ctx); } /* Result is always fastint compatible. */ @@ -81024,7 +81063,7 @@ DUK_INTERNAL void duk_lexer_parse_re_ranges(duk_lexer_ctx *lex_ctx, duk_re_range DUK__ADVANCECHARS(lex_ctx, 1); /* eat ']' before finishing */ break; } else if (x == DUK_ASC_MINUS) { - if (start >= 0 && !dash && DUK__L0() != DUK_ASC_RBRACKET) { + if (start >= 0 && !dash && DUK__L1() != DUK_ASC_RBRACKET) { /* '-' as a range indicator */ dash = 1; continue; diff --git a/duktape/duktape.h b/duktape/duktape.h index 614954e..d10e803 100644 --- a/duktape/duktape.h +++ b/duktape/duktape.h @@ -1,13 +1,13 @@ /* - * Duktape public API for Duktape 2.1.0. + * Duktape public API for Duktape 2.1.1. * * See the API reference for documentation on call semantics. The exposed, * supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API" * comments. Other parts of the header are Duktape internal and related to * e.g. platform/compiler/feature detection. * - * Git commit 1f1f51a4f9595ffe8def0e9ba45b20f14679393a (v2.1.0). - * Git branch master. + * Git commit 9c8fba6392d1913cb5359be7b8f386fa3cdd8b4d (v2.1.1). + * Git branch v2.1-maintenance. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and * licensing information. @@ -151,16 +151,16 @@ * development snapshots have 99 for patch level (e.g. 0.10.99 would be a * development version after 0.10.0 but before the next official release). */ -#define DUK_VERSION 20100L +#define DUK_VERSION 20101L /* Git commit, describe, and branch for Duktape build. Useful for * non-official snapshot builds so that application code can easily log * which Duktape snapshot was used. Not available in the Ecmascript * environment. */ -#define DUK_GIT_COMMIT "1f1f51a4f9595ffe8def0e9ba45b20f14679393a" -#define DUK_GIT_DESCRIBE "v2.1.0" -#define DUK_GIT_BRANCH "master" +#define DUK_GIT_COMMIT "9c8fba6392d1913cb5359be7b8f386fa3cdd8b4d" +#define DUK_GIT_DESCRIBE "v2.1.1" +#define DUK_GIT_BRANCH "v2.1-maintenance" /* External duk_config.h provides platform/compiler/OS dependent * typedefs and macros, and DUK_USE_xxx config options so that |