From 3515783d559835315ff1363bfbbd4db0e4902770 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 1 Jul 2025 17:38:08 +0000 Subject: [PATCH] Random JS cleanups and docs. FossilOrigin-Name: 5a2734bbf8b471fa27f8f4b687e4d24f64c7663b823908f1ee8cd21bb93beb98 --- ext/wasm/common/whwasmutil.js | 29 ++++++++++++++--------------- ext/wasm/tester1.c-pp.js | 8 ++------ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index b4d8f691b8..71f3a7df6c 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -10,7 +10,7 @@ *********************************************************************** - The whwasmutil is developed in conjunction with the Jaccwabyt + whwasmutil.js is developed in conjunction with the Jaccwabyt project: https://fossil.wanderinghorse.net/r/jaccwabyt @@ -40,7 +40,7 @@ APIs such as its "FS" (virtual filesystem) API. Loading of such things still requires using Emscripten's glue, but the post-load utility APIs provided by this code are still usable as replacements - for their sub-optimally-documented Emscripten counterparts. + (not necessarily drop-in) for their Emscripten counterparts. Intended usage: @@ -119,7 +119,7 @@ - `memory`: a WebAssembly.Memory object representing the WASM memory. _Alternately_, the `memory` property can be set as `target.memory`, in particular if the WASM heap memory is - initialized in JS an _imported_ into WASM, as opposed to being + initialized in JS and _imported_ into WASM, as opposed to being initialized in WASM and exported to JS. - `__indirect_function_table`: the WebAssembly.Table object which @@ -320,13 +320,13 @@ globalThis.WhWasmUtilInstaller = function(target){ BigInt64Array/BigUint64Array, else it throws if passed 64 or one of those constructors. - Returns an integer-based TypedArray view of the WASM heap - memory buffer associated with the given block size. If passed - an integer as the first argument and unsigned is truthy then - the "U" (unsigned) variant of that view is returned, else the - signed variant is returned. If passed a TypedArray value, the - 2nd argument is ignored. Note that Float32Array and - Float64Array views are not supported by this function. + Returns an integer-based TypedArray view of the WASM heap memory + buffer associated with the given block size. If passed an integer + as the first argument and unsigned is truthy then the "U" + (unsigned) variant of that view is returned, else the signed + variant is returned. If passed a TypedArray value, the 2nd + argument is ignored. Float32Array and Float64Array views are not + supported by this function. Note that growth of the heap will invalidate any references to this heap, so do not hold a reference longer than needed and do @@ -342,8 +342,7 @@ globalThis.WhWasmUtilInstaller = function(target){ */ target.heapForSize = function(n,unsigned = true){ let ctor; - const c = (cache.memory && cache.heapSize === cache.memory.buffer.byteLength) - ? cache : heapWrappers(); + const c = heapWrappers(); switch(n){ case Int8Array: return c.HEAP8; case Uint8Array: return c.HEAP8U; case Int16Array: return c.HEAP16; case Uint16Array: return c.HEAP16U; @@ -407,7 +406,7 @@ globalThis.WhWasmUtilInstaller = function(target){ Supported letters: - `i` = int32 - - `p` = int32 ("pointer") + - `p` = int32 ("pointer") unless configured for 64-bit pointers - `j` = int64 - `f` = float32 - `d` = float64 @@ -435,7 +434,7 @@ globalThis.WhWasmUtilInstaller = function(target){ f._ = { // Map of signature letters to type IR values sigTypes: Object.assign(Object.create(null),{ - i: 'i32', p: 'i32', P: 'i32', s: 'i32', + i: 'i32', p: ptrIR, P: ptrIR, s: ptrIR, j: 'i64', f: 'f32', d: 'f64' }), // Map of type IR values to WASM type code values @@ -749,7 +748,7 @@ globalThis.WhWasmUtilInstaller = function(target){ method. */ target.poke = function(ptr, value, type='i8'){ - if (type.endsWith('*')) type = ptrIR; + if(type.endsWith('*')) type = ptrIR; const c = (cache.memory && cache.heapSize === cache.memory.buffer.byteLength) ? cache : heapWrappers(); for(const p of (Array.isArray(ptr) ? ptr : [ptr])){ diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 1111679cd7..9e332b9464 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3354,9 +3354,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; q = db.prepare("select a, b from t order by a"); let [ppOut, pnOut, pType] = P.allocPtr(3); const clearPtrs = ()=>{ - wasm.pokePtr(ppOut, 0); - wasm.poke32(pnOut, 0); - wasm.poke32(pType, 0); + wasm.pokePtr(ppOut, 0).poke32(pnOut, 0).poke32(pType, 0); }; const next = ()=>{ T.assert( q.step() ); @@ -3449,9 +3447,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; q = db.prepare("select a, b from t order by a"); let [ppOut, pnOut, pType] = P.allocPtr(3); const clearPtrs = ()=>{ - wasm.pokePtr(ppOut, 0); - wasm.poke32(pnOut, 0); - wasm.poke32(pType, 0); + wasm.pokePtr(ppOut, 0).poke32(pnOut, 0).poke32(pType, 0); }; const next = ()=>{ diff --git a/manifest b/manifest index cfe68cc48e..b8caab04c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Experimentally\sadd\sanother\soutput\spointer\sto\sthe\stext/blob_v2()\sfamily\swhich\sgets\sthe\ssqlite3_value_type()\sassigned\sto\sit\sif\sit's\snot\sNULL,\sbased\son\sfeedback\sin\sthe\sforum. -D 2025-07-01T16:38:58.203 +C Random\sJS\scleanups\sand\sdocs. +D 2025-07-01T17:38:08.691 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -661,7 +661,7 @@ F ext/wasm/c-pp.c cca55c5b55ebd8d29916adbedb0e40baa12caa9a2e8429f812683c308f9b0e F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f -F ext/wasm/common/whwasmutil.js 5e7fe4a2547831e003356c201ca28d9a0d6a19ab1fe2c8f63f82464fecd2cef7 +F ext/wasm/common/whwasmutil.js 209f9958133241e4c490347d613265752cc3f288ec4d6b0abd2a53b5acf8d2d9 F ext/wasm/config.make.in 4bc43443f768a61efd43cf995a5e618f58ac9afc0936706014193537d82c41cb F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 @@ -698,7 +698,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js be5aa80c98aae290fa9bd0296358f978ef0b9ff25b0106d3f96cc4cc3c5128b9 +F ext/wasm/tester1.c-pp.js 360ef22cf02a48192dbd4c33172a37d6656bcedda11335775bd681ec50b68bbb F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d5cb8080434bc13616d70aac516762ca8be622bf51a07f8c36d8657c410e03ce -R 76b92a6732359cdd07f9c1558852eff8 +P 4aab781d2abc64a39c53acd0faf6d60bb38afcce42f25bc8c0fa52b73df05312 +R 8e06e1907693b695373176fe3fdc205a U stephan -Z 59582194fce1a262d6667c3ee644c001 +Z e3cc89ebfecaca5d22dd5efe42afadb1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 51e2d90bc9..89445ade66 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4aab781d2abc64a39c53acd0faf6d60bb38afcce42f25bc8c0fa52b73df05312 +5a2734bbf8b471fa27f8f4b687e4d24f64c7663b823908f1ee8cd21bb93beb98 -- 2.47.2