]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Install sqlite3_malloc/sqlite3_free() as the JS-side WASM allocator (as opposed to...
authorstephan <stephan@noemail.net>
Wed, 30 Nov 2022 11:50:16 +0000 (11:50 +0000)
committerstephan <stephan@noemail.net>
Wed, 30 Nov 2022 11:50:16 +0000 (11:50 +0000)
FossilOrigin-Name: 95c78f6b46e0d8efa4313061f47677479f48610b7a7261dc8d0fb1859aca2ad9

ext/wasm/api/sqlite3-api-cleanup.js
ext/wasm/api/sqlite3-api-prologue.js
ext/wasm/tester1.c-pp.js
manifest
manifest.uuid

index 0ec0fbfbe386fe6951db397f6238eb117dbd4c51..30cd64b0538797fe383038e317d0eb74708d39ce 100644 (file)
@@ -22,12 +22,10 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build
   */
   const SABC = Object.assign(
     Object.create(null), {
-      Module: Module /* ==> Currently needs to be exposed here for
-                        test code. NOT part of the public API. */,
       exports: Module['asm'],
       memory: Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */
     },
-    self.sqlite3ApiConfig || Object.create(null)
+    self.sqlite3ApiConfig || {}
   );
 
   /**
index 59cdab9295238afdfd2666e3b7bda5904c4b7a34..31cd8aa539f49a3bcfa177e8263730087d70e111 100644 (file)
 
    - `allocExportName`: the name of the function, in `exports`, of the
      `malloc(3)`-compatible routine for the WASM environment. Defaults
-     to `"malloc"`.
+     to `"sqlite3_malloc"`. Beware that using any allocator other than
+     sqlite3_malloc() may require care in certain client-side code
+     regarding which allocator is uses. Notably, sqlite3_deserialize()
+     and sqlite3_serialize() can only safely use memory from different
+     allocators under very specific conditions.
 
    - `deallocExportName`: the name of the function, in `exports`, of
      the `free(3)`-compatible routine for the WASM
-     environment. Defaults to `"free"`.
+     environment. Defaults to `"sqlite3_free"`.
 
    - `wasmfsOpfsDir`[^1]: if the environment supports persistent
      storage using OPFS-over-WASMFS , this directory names the "mount
@@ -104,8 +108,8 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
       }
       return !!self.BigInt64Array;
     })(),
-    allocExportName: 'malloc',
-    deallocExportName: 'free',
+    allocExportName: 'sqlite3_malloc',
+    deallocExportName: 'sqlite3_free',
     wasmfsOpfsDir: '/opfs'
   }, apiConfig || {});
 
@@ -727,8 +731,8 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
     return pRet;
   };
 
-  const keyAlloc = config.allocExportName || 'malloc',
-        keyDealloc =  config.deallocExportName || 'free';
+  const keyAlloc = config.allocExportName,
+        keyDealloc =  config.deallocExportName;
   for(const key of [keyAlloc, keyDealloc]){
     const f = wasm.exports[key];
     if(!(f instanceof Function)) toss3("Missing required exports[",key,"] function.");
index 0c32c1b071548de3e87c3290e31c980dd931db70..08f5480b54de5c4d218d9bd5d9e644bf6f58c357 100644 (file)
@@ -336,6 +336,10 @@ self.sqlite3InitModule = sqlite3InitModule;
 
   ////////////////////////////////////////////////////////////////////
   T.g('Basic sanity checks')
+    .t("JS wasm-side allocator === sqlite3_malloc()", function(sqlite3){
+      T.assert(wasm.alloc.impl === wasm.exports.sqlite3_malloc)
+        .assert(wasm.dealloc === wasm.exports.sqlite3_free);
+    })
     .t('Namespace object checks', function(sqlite3){
       const wasmCtypes = wasm.ctype;
       T.assert(wasmCtypes.structs[0].name==='sqlite3_vfs').
index fe90f1f943943673b003fc84df2307d9f4e58116..557b4aef570663ff51448df13b9f411e253ece79 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Simplify\show\sthe\sOPFS\sVFS\sasync\sproxy\scopies\sinitial\sstate\ssent\sto\sit\sfrom\sthe\ssynchronous\sside\sof\sthe\sconnection.\sMake\sthe\slock-wait\stime\sa\smultiple\sof\sthe\swait-loop\stimeout\sinterval.
-D 2022-11-30T08:37:17.860
+C Install\ssqlite3_malloc/sqlite3_free()\sas\sthe\sJS-side\sWASM\sallocator\s(as\sopposed\sto\sreplacing\sC-level's\smalloc()/free()\swith\sthem).\sAll\stests\swork\sand\sthis\seliminates\sthe\spotential\sfor\sallocator\sdiscrepancies\swhen\susing\sthe\s(de)serialize\sAPIs.
+D 2022-11-30T11:50:16.116
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -502,10 +502,10 @@ F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e
 F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08902f15c34720ee4a1
 F ext/wasm/api/post-js-header.js d6ab3dfef4a06960d28a7eaa338d4e2a1a5981e9b38718168bbde8fdb2a439b8
 F ext/wasm/api/pre-js.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f9e91c1d5f
-F ext/wasm/api/sqlite3-api-cleanup.js 6a22a3287b34a2b4b0f8127614242e8307cce31ac060eb705a89a6d04dcb1028
+F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
 F ext/wasm/api/sqlite3-api-glue.js 03c40b65530d67bb2748b7380aea5fd1534500f812b76a6b401066dcd7fc4116
 F ext/wasm/api/sqlite3-api-oo1.js 06ad2079368e16cb9f182c18cd37bdc3932536856dff4f60582d0ca5f6c491a8
-F ext/wasm/api/sqlite3-api-prologue.js e1db3935e1deb1340c1dc0c0e4730b2b88254d616841ebd5bc6bb1b90b32657f
+F ext/wasm/api/sqlite3-api-prologue.js e63bcd1d1942d3313bd11e76ac1fccdd3e34ba54a48b8c8296db8dd892705dbc
 F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f
 F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
 F ext/wasm/api/sqlite3-opfs-async-proxy.js 9963c78bf6e5ccb5ba28e8597851bd9d980e86803b6d341cc985e586aef10c82
@@ -555,7 +555,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
 F ext/wasm/test-opfs-vfs.js 44363db07b2a20e73b0eb1808de4400ca71b703af718d0fa6d962f15e73bf2ac
 F ext/wasm/tester1-worker.html 5ef353348c37cf2e4fd0b23da562d3275523e036260b510734e9a3239ba8c987
 F ext/wasm/tester1.c-pp.html 74aa9b31c75f12490653f814b53c3dd39f40cd3f70d6a53a716f4e8587107399
-F ext/wasm/tester1.c-pp.js 5820d578b67835aaf651230663dd207237071ee1f16f11a9c5168500aae04a50
+F ext/wasm/tester1.c-pp.js c39594bb1a0272a08a1544277a29c1ed920b4c4877611591e7c3185744ae2431
 F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
 F ext/wasm/tests/opfs/concurrency/test.js bfc3d7e27b207f0827f12568986b8d516a744529550b449314f5c21c9e9faf4a
 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@@ -2065,8 +2065,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 3b037caa2fa07b6c44c485574e9e5dc71f4a8e82bc902c1321bb0b918b139c74
-R e3e2fc506276773f57deed8b914e8dd1
+P eddafafffa634a42ceeed70aa3fc58be130527612157a4bf4ff9e65c7f6dc26c
+R 40e47e8cbba6f9c6283963002c627e97
 U stephan
-Z 98f64cec6c8eaf42e6c02ddc6003f146
+Z 339b33401805070aa414e2061b0a89bf
 # Remove this line to create a well-formed Fossil manifest.
index 20dcd52ad49b6a8229756d5a675bf853f72d5719..01d15d876412bc7b68e6be2db2d4a41c4312fbbe 100644 (file)
@@ -1 +1 @@
-eddafafffa634a42ceeed70aa3fc58be130527612157a4bf4ff9e65c7f6dc26c
\ No newline at end of file
+95c78f6b46e0d8efa4313061f47677479f48610b7a7261dc8d0fb1859aca2ad9
\ No newline at end of file