This is an automated email from the ASF dual-hosted git repository. nickva pushed a commit to branch quickjs-update-jsn-4-new-release in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 7705ec3fc7e9cc2f4a66c31bf3523f46ba781119 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Thu Jun 4 13:11:10 2026 -0400 QuickJS update: faster math ops, return checks, new release * New release 2026-06-04 https://github.com/bellard/quickjs/commit/3d5e064e9dd67c70f7962836505a7fa067bf0a4e * Check return values of fallible functions https://github.com/bellard/quickjs/commit/ccfe0764eddc17bc531dcf9fc69f9ee3a2b3e0e2 * Fuzz targets for ES6 modules, JSON, RegExp, and bytecode https://github.com/bellard/quickjs/commit/8b045501f92617951060ffb31f9db0be745195d9 * Doc updates https://github.com/bellard/quickjs/commit/cfc846a31c5b60130ca02d121932438bcfc94cd1 * More generic `cpu_count()` for non Linux systems for tests https://github.com/bellard/quickjs/commit/ad1e7bd3ce00544f86c254fde1f3db20fefa089f * Fixed microbench with d8 https://github.com/bellard/quickjs/commit/92a3d4d5ea04c98c462161fb881ee00b78176d73 --- .../patches/01-spidermonkey-185-mode.patch | 6 +- src/couch_quickjs/patches/02-test262-errors.patch | 4 +- src/couch_quickjs/quickjs/Changelog | 3 + src/couch_quickjs/quickjs/VERSION | 2 +- src/couch_quickjs/quickjs/quickjs.c | 74 ++++++++++++++++++---- src/couch_quickjs/quickjs/run-test262.c | 9 ++- 6 files changed, 79 insertions(+), 19 deletions(-) diff --git a/src/couch_quickjs/patches/01-spidermonkey-185-mode.patch b/src/couch_quickjs/patches/01-spidermonkey-185-mode.patch index 5466852aa..19e9316f9 100644 --- a/src/couch_quickjs/patches/01-spidermonkey-185-mode.patch +++ b/src/couch_quickjs/patches/01-spidermonkey-185-mode.patch @@ -1,6 +1,6 @@ ---- quickjs-master/quickjs.c 2026-06-03 10:18:26 -+++ quickjs/quickjs.c 2026-06-03 14:25:58 -@@ -31873,10 +31873,24 @@ +--- quickjs-master/quickjs.c 2026-06-04 08:53:29 ++++ quickjs/quickjs.c 2026-06-04 13:06:09 +@@ -31922,10 +31922,24 @@ if (s->token.val == TOK_FUNCTION || (token_is_pseudo_keyword(s, JS_ATOM_async) && peek_token(s, TRUE) == TOK_FUNCTION)) { diff --git a/src/couch_quickjs/patches/02-test262-errors.patch b/src/couch_quickjs/patches/02-test262-errors.patch index f1ee61e58..a41cc408f 100644 --- a/src/couch_quickjs/patches/02-test262-errors.patch +++ b/src/couch_quickjs/patches/02-test262-errors.patch @@ -1,5 +1,5 @@ ---- quickjs-master/test262_errors.txt 2026-06-03 10:18:26 -+++ quickjs/test262_errors.txt 2026-06-03 14:25:58 +--- quickjs-master/test262_errors.txt 2026-06-04 08:53:29 ++++ quickjs/test262_errors.txt 2026-06-04 13:06:09 @@ -23,6 +23,8 @@ test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-export-star-as-from-and-import-star-as-and-export.js:74: SyntaxError: export 'foo' in module 'test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-import-star-as-and-export.js' is ambiguous test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-export-star-as-from.js:75: SyntaxError: export 'foo' in module 'test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-export-star-as-from.js' is ambiguous diff --git a/src/couch_quickjs/quickjs/Changelog b/src/couch_quickjs/quickjs/Changelog index 697193f3e..f5c536b19 100644 --- a/src/couch_quickjs/quickjs/Changelog +++ b/src/couch_quickjs/quickjs/Changelog @@ -1,3 +1,5 @@ +2026-06-04: + - added custom malloc for small blocks (11% faster on bench-v8) - micro optimizations (30% faster on bench-v8) - added resizable array buffers @@ -8,6 +10,7 @@ - added added Map and WeakMap upsert methods - added Math.sumPrecise() - added regexp duplicate named groups +- added base64 and hexadecimal encodings for Uint8Array - misc bug fixes 2025-09-13: diff --git a/src/couch_quickjs/quickjs/VERSION b/src/couch_quickjs/quickjs/VERSION index 433b8f85b..ba2d8bcde 100644 --- a/src/couch_quickjs/quickjs/VERSION +++ b/src/couch_quickjs/quickjs/VERSION @@ -1 +1 @@ -2025-09-13 +2026-06-04 diff --git a/src/couch_quickjs/quickjs/quickjs.c b/src/couch_quickjs/quickjs/quickjs.c index 05d4fd031..40bb08c1b 100644 --- a/src/couch_quickjs/quickjs/quickjs.c +++ b/src/couch_quickjs/quickjs/quickjs.c @@ -19733,9 +19733,24 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj, sp[-2] = JS_NewInt32(ctx, r); } sp--; - } else if (JS_VALUE_IS_BOTH_FLOAT(op1, op2)) { - sp[-2] = __JS_NewFloat64(ctx, JS_VALUE_GET_FLOAT64(op1) + - JS_VALUE_GET_FLOAT64(op2)); + } else if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1)) || + JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op2))) { + double d1, d2; + if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1))) { + d1 = JS_VALUE_GET_FLOAT64(op1); + } else if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { + d1 = JS_VALUE_GET_INT(op1); + } else { + goto add_slow_case; + } + if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op2))) { + d2 = JS_VALUE_GET_FLOAT64(op2); + } else if (JS_VALUE_GET_TAG(op2) == JS_TAG_INT) { + d2 = JS_VALUE_GET_INT(op2); + } else { + goto add_slow_case; + } + sp[-2] = __JS_NewFloat64(ctx, d1 + d2); sp--; } else if (JS_IsString(op1) && JS_IsString(op2)) { sp[-2] = JS_ConcatString(ctx, op1, op2); @@ -19743,6 +19758,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj, if (JS_IsException(sp[-1])) goto exception; } else { + add_slow_case: sf->cur_pc = pc; if (js_add_slow(ctx, sp)) goto exception; @@ -19813,9 +19829,24 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj, sp[-2] = JS_NewInt32(ctx, r); } sp--; - } else if (JS_VALUE_IS_BOTH_FLOAT(op1, op2)) { - sp[-2] = __JS_NewFloat64(ctx, JS_VALUE_GET_FLOAT64(op1) - - JS_VALUE_GET_FLOAT64(op2)); + } else if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1)) || + JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op2))) { + double d1, d2; + if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1))) { + d1 = JS_VALUE_GET_FLOAT64(op1); + } else if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { + d1 = JS_VALUE_GET_INT(op1); + } else { + goto binary_arith_slow; + } + if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op2))) { + d2 = JS_VALUE_GET_FLOAT64(op2); + } else if (JS_VALUE_GET_TAG(op2) == JS_TAG_INT) { + d2 = JS_VALUE_GET_INT(op2); + } else { + goto binary_arith_slow; + } + sp[-2] = __JS_NewFloat64(ctx, d1 - d2); sp--; } else { goto binary_arith_slow; @@ -19845,8 +19876,24 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj, } sp[-2] = JS_NewInt32(ctx, r); sp--; - } else if (JS_VALUE_IS_BOTH_FLOAT(op1, op2)) { - d = JS_VALUE_GET_FLOAT64(op1) * JS_VALUE_GET_FLOAT64(op2); + } else if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1)) || + JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op2))) { + double d1, d2; + if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1))) { + d1 = JS_VALUE_GET_FLOAT64(op1); + } else if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { + d1 = JS_VALUE_GET_INT(op1); + } else { + goto binary_arith_slow; + } + if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op2))) { + d2 = JS_VALUE_GET_FLOAT64(op2); + } else if (JS_VALUE_GET_TAG(op2) == JS_TAG_INT) { + d2 = JS_VALUE_GET_INT(op2); + } else { + goto binary_arith_slow; + } + d = d1 * d2; mul_fp_res: sp[-2] = __JS_NewFloat64(ctx, d); sp--; @@ -28671,7 +28718,8 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, int chunk_size = pos_expr - pos_next; int offset = bc->size - pos_next; int i; - dbuf_claim(bc, chunk_size); + if (dbuf_claim(bc, chunk_size)) + return -1; dbuf_put(bc, bc->buf + pos_next, chunk_size); memset(bc->buf + pos_next, OP_nop, chunk_size); /* `next` part ends with a goto */ @@ -29077,7 +29125,8 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, int chunk_size = pos_body - pos_cont; int offset = bc->size - pos_cont; int i; - dbuf_claim(bc, chunk_size); + if (dbuf_claim(bc, chunk_size)) + goto fail; dbuf_put(bc, bc->buf + pos_cont, chunk_size); memset(bc->buf + pos_cont, OP_nop, chunk_size); /* increment part ends with a goto */ @@ -38019,11 +38068,14 @@ static int JS_WriteObjectRec(BCWriterState *s, JSValueConst obj) case JS_TAG_STRING_ROPE: { JSValue str; + int ret; str = JS_ToString(s->ctx, obj); if (JS_IsException(str)) goto fail; - JS_WriteObjectRec(s, str); + ret = JS_WriteObjectRec(s, str); JS_FreeValue(s->ctx, str); + if (ret) + goto fail; } break; case JS_TAG_FUNCTION_BYTECODE: diff --git a/src/couch_quickjs/quickjs/run-test262.c b/src/couch_quickjs/quickjs/run-test262.c index 8e2a7e7a5..81811b58d 100644 --- a/src/couch_quickjs/quickjs/run-test262.c +++ b/src/couch_quickjs/quickjs/run-test262.c @@ -151,7 +151,7 @@ static int cpu_count(void) count += 1 & (procmask >> i); return count; } -#else +#elif defined(__linux__) /* return the number of available physical cores or -1 if not available */ static int get_cpu_info_physical_cores(void) { @@ -215,7 +215,12 @@ static int cpu_count(void) n = 1; return n; } -#endif /* !_WIN32 */ +#else /* __linux__ */ +static int cpu_count(void) +{ + return sysconf(_SC_NPROCESSORS_ONLN); +} +#endif /* !__linux__ */ static void init_thread_local_storage(ThreadLocalStorage *tls) {
