This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/main by this push:
     new 53c3c13c7 Update QuickJS
53c3c13c7 is described below

commit 53c3c13c7069e9aad6e0d6a7db9ea2f14c2debf5
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Fri Jun 20 14:04:15 2025 -0400

    Update QuickJS
    
     * Read byteOffset for detached buffers
     
https://github.com/bellard/quickjs/commit/00b1d8d0b2d06e540444245b54a8fd86ccf7260b
    
     * Add `Error.isError()`
     
https://github.com/bellard/quickjs/commit/098f221cf3124a4a423d089bae83b81ccf108d20
    
    Some tests were updated (more tests pass now) and the upstream changelog was
    updated, but already have most of those changes anyway.
    
    Also, update our maintenance scripts -- add a script used to adjust the 
patches
    themselves. Normally we just have to run `./update_and_apply_patches.sh` 
that
    clones QuickJS and applies our patch. But after some time the line numbers 
in
    our patch may start to drift vs the upstream `quickjs.c` file, so it helps 
to
    regerate the patch itself periodically. Assuming the local working 
directory is
    patched, call the `./update_patches.sh` script and it will clone a fresh
    QuickJS master and run a diff from that master to our working directory and
    make that a new patch.
---
 .../patches/01-spidermonkey-185-mode.patch         |  6 +++---
 src/couch_quickjs/quickjs/Changelog                | 15 +++++++++++++++
 src/couch_quickjs/quickjs/quickjs.c                | 22 ++++++++++++++++------
 src/couch_quickjs/quickjs/test262.conf             |  2 +-
 src/couch_quickjs/quickjs/test262_errors.txt       |  1 -
 src/couch_quickjs/update_and_apply_patches.sh      |  8 ++++----
 src/couch_quickjs/update_patches.sh                | 22 ++++++++++++++++++++++
 7 files changed, 61 insertions(+), 15 deletions(-)

diff --git a/src/couch_quickjs/patches/01-spidermonkey-185-mode.patch 
b/src/couch_quickjs/patches/01-spidermonkey-185-mode.patch
index 56711a4ab..d4a85a5a0 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   2025-05-24 09:43:14
-+++ quickjs/quickjs.c  2025-05-28 21:55:36
-@@ -30590,10 +30590,24 @@
+--- quickjs-master/quickjs.c   2025-06-14 05:51:48
++++ quickjs/quickjs.c  2025-06-20 13:56:52
+@@ -30599,10 +30599,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/quickjs/Changelog 
b/src/couch_quickjs/quickjs/Changelog
index 7cc33993d..b1443f5ad 100644
--- a/src/couch_quickjs/quickjs/Changelog
+++ b/src/couch_quickjs/quickjs/Changelog
@@ -1,3 +1,18 @@
+- added JSON modules and import attributes
+- added JS_PrintValue() API
+- qjs: pretty print objects in print() and console.log()
+- qjs: better promise rejection tracker heuristics
+- added RegExp v flag
+- added RegExp modifiers
+- added RegExp.escape
+- added Float16Array
+- added Promise.try
+- improved JSON parser spec conformance
+- qjs: improved compatibility of std.parseExtJSON() with JSON5 and
+  accept JSON5 modules
+- added JS_FreePropertyEnum() and JS_AtomToCStringLen() API
+- added Error.isError()
+
 2025-04-26:
 
 - removed the bignum extensions and qjscalc
diff --git a/src/couch_quickjs/quickjs/quickjs.c 
b/src/couch_quickjs/quickjs/quickjs.c
index 1cebe331f..10d28d6f1 100644
--- a/src/couch_quickjs/quickjs/quickjs.c
+++ b/src/couch_quickjs/quickjs/quickjs.c
@@ -39990,6 +39990,16 @@ static const JSCFunctionListEntry 
js_error_proto_funcs[] = {
     JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE 
),
 };
 
+static JSValue js_error_isError(JSContext *ctx, JSValueConst this_val,
+                                int argc, JSValueConst *argv)
+{
+    return JS_NewBool(ctx, JS_IsError(ctx, argv[0]));
+}
+
+static const JSCFunctionListEntry js_error_funcs[] = {
+    JS_CFUNC_DEF("isError", 1, js_error_isError),
+};
+
 /* AggregateError */
 
 /* used by C code. */
@@ -52291,6 +52301,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
                                 "Error", 1, 
JS_CFUNC_constructor_or_func_magic, -1);
     JS_NewGlobalCConstructor2(ctx, obj1,
                               "Error", ctx->class_proto[JS_CLASS_ERROR]);
+    JS_SetPropertyFunctionList(ctx, obj1, js_error_funcs, 
countof(js_error_funcs));
 
     /* Used to squelch a -Wcast-function-type warning. */
     JSCFunctionType ft = { .generic_magic = js_error_constructor };
@@ -54031,7 +54042,8 @@ static JSValue js_typed_array_subarray(JSContext *ctx, 
JSValueConst this_val,
                                        int argc, JSValueConst *argv)
 {
     JSValueConst args[4];
-    JSValue arr, byteOffset, ta_buffer;
+    JSValue arr, ta_buffer;
+    JSTypedArray *ta;
     JSObject *p;
     int len, start, final, count, shift, offset;
 
@@ -54048,12 +54060,10 @@ static JSValue js_typed_array_subarray(JSContext 
*ctx, JSValueConst this_val,
             goto exception;
     }
     count = max_int(final - start, 0);
-    byteOffset = js_typed_array_get_byteOffset(ctx, this_val, 0);
-    if (JS_IsException(byteOffset))
-        goto exception;
     shift = typed_array_size_log2(p->class_id);
-    offset = JS_VALUE_GET_INT(byteOffset) + (start << shift);
-    JS_FreeValue(ctx, byteOffset);
+    ta = p->u.typed_array;
+    /* Read byteOffset (ta->offset) even if detached */
+    offset = ta->offset + (start << shift);
     ta_buffer = js_typed_array_get_buffer(ctx, this_val, 0);
     if (JS_IsException(ta_buffer))
         goto exception;
diff --git a/src/couch_quickjs/quickjs/test262.conf 
b/src/couch_quickjs/quickjs/test262.conf
index 0966a594a..327759454 100644
--- a/src/couch_quickjs/quickjs/test262.conf
+++ b/src/couch_quickjs/quickjs/test262.conf
@@ -103,7 +103,7 @@ destructuring-assignment
 destructuring-binding
 dynamic-import
 error-cause
-Error.isError=skip
+Error.isError
 explicit-resource-management=skip
 exponentiation
 export-star-as-namespace-from-module
diff --git a/src/couch_quickjs/quickjs/test262_errors.txt 
b/src/couch_quickjs/quickjs/test262_errors.txt
index 9df6f749a..7dd3f7624 100644
--- a/src/couch_quickjs/quickjs/test262_errors.txt
+++ b/src/couch_quickjs/quickjs/test262_errors.txt
@@ -23,7 +23,6 @@ 
test262/test/staging/sm/TypedArray/prototype-constructor-identity.js:17: Test262
 test262/test/staging/sm/TypedArray/set-detached-bigint.js:27: Error: Assertion 
failed: expected exception SyntaxError, got RangeError: invalid array length
 test262/test/staging/sm/TypedArray/set-detached.js:112: RangeError: invalid 
array length
 test262/test/staging/sm/TypedArray/sort_modifications.js:12: Test262Error: 
Int8Array at index 0 for size 4 Expected SameValue(«0», «1») to be true
-test262/test/staging/sm/TypedArray/subarray.js:15: Test262Error: Expected 
SameValue(«0», «1») to be true
 test262/test/staging/sm/async-functions/async-contains-unicode-escape.js:45: 
Error: Assertion failed: expected exception SyntaxError, no exception thrown
 test262/test/staging/sm/async-functions/await-error.js:12: Test262Error: 
Expected SameValue(«false», «true») to be true
 test262/test/staging/sm/async-functions/await-in-arrow-parameters.js:33: 
Error: Assertion failed: expected exception SyntaxError, no exception thrown - 
AsyncFunction:(a = (b = await/r/g) => {}) => {}
diff --git a/src/couch_quickjs/update_and_apply_patches.sh 
b/src/couch_quickjs/update_and_apply_patches.sh
index 92fbb6355..87454c9c3 100755
--- a/src/couch_quickjs/update_and_apply_patches.sh
+++ b/src/couch_quickjs/update_and_apply_patches.sh
@@ -7,9 +7,6 @@ set -e
 # This is the main branch of the github mirror
 URL=https://github.com/bellard/quickjs/archive/refs/heads/master.zip
 #
-# The other alternatives:
-#   https://github.com/quickjs-ng/quickjs/commits/master/
-
 
 echo
 echo " * backup quickjs to quickjs.bak"
@@ -50,6 +47,9 @@ echo " * removing quickjs.bak"
 rm -rf quickjs.bak
 echo
 
-# Example how to generate patches:
+# Example how to update patches themselves:
 #
+# Run
+#  ./update_patches.sh
+# OR manually run after cloning and unzipping master.zip from quickjs:
 #  diff -u quickjs-master/quickjs.c quickjs/quickjs.c > 
patches/01-spidermonkey-185-mode.patch
diff --git a/src/couch_quickjs/update_patches.sh 
b/src/couch_quickjs/update_patches.sh
new file mode 100755
index 000000000..f14b5ab6f
--- /dev/null
+++ b/src/couch_quickjs/update_patches.sh
@@ -0,0 +1,22 @@
+# Update patches
+#
+# Call this script after using update_and_apply_patches.sh to adjust
+# the patches themselves. Sometimes line offsets drift and so this takes
+# a new diff from the master QuickJS vs current source tree and regenerates
+# the patch.
+
+set -e
+
+URL=https://github.com/bellard/quickjs/archive/refs/heads/master.zip
+
+echo " * wget ${URL}"
+rm -rf master.zip quickjs-master
+wget -q ${URL}
+echo " * unzip master.zip to quickjs-master"
+unzip -q -o master.zip
+echo " * updating 01-spidermonkey-185-mode.patch"
+set +e
+diff -u quickjs-master/quickjs.c quickjs/quickjs.c > 
patches/01-spidermonkey-185-mode.patch
+set -e
+echo " * cleaning up"
+rm -rf master.zip quickjs-master

Reply via email to