From: stephan Date: Sun, 21 Sep 2025 23:15:12 +0000 (+0000) Subject: Minor internal optimizations in the wasm glue. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d49644650f79918ae6767ab72da9f8ca6a9221f;p=thirdparty%2Fsqlite.git Minor internal optimizations in the wasm glue. FossilOrigin-Name: fb053a27d94f9caedfddf28680e13836343745376e84c8008641df6bb517cd8b --- diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index 31ab522fa5..c3f8c4b00b 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -960,21 +960,25 @@ globalThis.WhWasmUtilInstaller = function(target){ validated except to ensure that it is a 32-bit integer with a value of 0 or greater. Likewise, it cannot verify whether the value actually refers to allocated memory in the WASM heap. + + Whether or not null or undefined are legal are context-dependent. + They generally are legal but this function does not treat them as + such because they're not strictly legal for passing as-is as WASM + integer arguments. */ - target.isPtr32 = (ptr)=>('number'===typeof ptr && (ptr===(ptr|0)) && ptr>=0); + target.isPtr32 = (ptr)=>( + 'number'===typeof ptr && ptr>=0 && ptr===(ptr|0) + ); - target.isPtr64 = (ptr)=>{ - if( 'bigint'===typeof ptr ){ - return ptr >= 0; - } - return ('number'===typeof ptr && ptr>=0 && (ptr===(ptr|0))); - }; + /** 64-bit counterpart of isPtr32() and falls back to that function + if ptr is not a BigInt. */ + target.isPtr64 = (ptr)=>( + ('bigint'===typeof ptr) ? ptr >= 0 : target.isPtr32(ptr) + ); /** - isPtr() is an alias for isPtr32(). If/when 64-bit WASM pointer - support becomes widespread, it will become an alias for either - isPtr32() or the as-yet-hypothetical isPtr64(), depending on a - configuration option. + isPtr() is an alias for isPtr32() or isPtr64(), depending on the + value of target.ptr.size. */ target.isPtr = (4===__ptrSize) ? target.isPtr32 : target.isPtr64; @@ -987,16 +991,14 @@ globalThis.WhWasmUtilInstaller = function(target){ target.heap8u(). */ target.cstrlen = function(ptr){ - if(!ptr) return null; + if(!ptr || !target.isPtr(ptr)) return null; ptr = Number(ptr) /*tag:64bit*/; - if(!target.isPtr(ptr)) return null; const h = heapWrappers().HEAP8U; let pos = ptr; for( ; h[pos] !== 0; ++pos ){} return Number(pos - ptr); }; - /** Internal helper to use in operations which need to distinguish between TypedArrays which are backed by a SharedArrayBuffer from those which are not. */ diff --git a/manifest b/manifest index be261c4236..16ce5ade0a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\sminor\soptimization\sin\swasm.realloc(). -D 2025-09-21T22:17:13.128 +C Minor\sinternal\soptimizations\sin\sthe\swasm\sglue. +D 2025-09-21T23:15:12.210 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -618,7 +618,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 01ff73506497bc72fb4befa728180fadbfce233cbc6d334349de20ac599f8680 +F ext/wasm/common/whwasmutil.js fb2a10747234ad720fbe713d7fecbad54abed30ac41355872e7c431f62c23e72 F ext/wasm/config.make.in c424ae1cc3c89274520ad312509d36c4daa34a3fce5d0c688e5f8f4365e1049a F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 @@ -2175,8 +2175,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 e99730f96e13f7497a871fdcc5eaa4187835f005a759f0fc79bbfe982f454437 -R 9a38d61e9abe1a9d6d9179c5e58b2364 +P 6a070f450ac9ee3d4d6a3e05ef8fa2071a684181ea160805e236c3bba226510a +R 4abaa719c3f0b3c283ef0653194b4d07 U stephan -Z 0a61aab390847ba2d3e72ee30f1990da +Z 0755752744575b5a7a7fc02264f08ee2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8f1f8ef83d..c76a2746e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a070f450ac9ee3d4d6a3e05ef8fa2071a684181ea160805e236c3bba226510a +fb053a27d94f9caedfddf28680e13836343745376e84c8008641df6bb517cd8b