v = v.join("");
n = -1;
}/*else if( 'bigint'===typeof n ){
- // tag:64-bit A workaround for when a stray BigInt, possibly
+ // tag:64bit A workaround for when a stray BigInt, possibly
// calculated via a pointer range, gets passed in here. This
// has been seen to happen in sqlite3_prepare_v3() via
// oo1.DB.exec().
"that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");
}
const pBlob = wasm.alloc(val.byteLength || 1);
- wasm.heap8().set(val.byteLength ? val : [0], pBlob)
+ wasm.heap8().set(val.byteLength ? val : [0], Number(pBlob))
rc = capi.sqlite3_bind_blob(stmt.pointer, ndx, pBlob, val.byteLength,
capi.SQLITE_WASM_DEALLOC);
break;
let pOut;
try{
const pSize = wasm.scopedAlloc(8/*i64*/ + wasm.pointerSizeof);
- const ppOut = pSize + 8;
+ const ppOut = wasm.ptrAdd(pSize, 8);
/**
Maintenance reminder, since this cost a full hour of grief
and confusion: if the order of pSize/ppOut are reversed in
*/
const zSchema = schema
? (wasm.isPtr(schema) ? schema : wasm.scopedAllocCString(''+schema))
- : 0;
+ : wasm.NullPtr;
let rc = wasm.exports.sqlite3__wasm_db_serialize(
pDb, zSchema, ppOut, pSize, 0
);
pOut = wasm.peekPtr(ppOut);
const nOut = wasm.peek(pSize, 'i64');
rc = nOut
- ? wasm.heap8u().slice(pOut, pOut + Number(nOut))
+ ? wasm.heap8u().slice(Number(pOut), Number(pOut) + Number(nOut))
: new Uint8Array();
return rc;
}finally{
if(n && !pBlob) sqlite3.WasmAllocError.toss(
"Cannot allocate memory for blob argument of",n,"byte(s)"
);
- arg = n ? wasm.heap8u().slice(pBlob, pBlob + Number(n)) : null;
+ arg = n
+ ? wasm.heap8u().slice(Number(pBlob), Number(pBlob) + Number(n))
+ : null;
break;
}
case capi.SQLITE_NULL:
do not.
*/
tgt.push(capi.sqlite3_value_to_js(
- wasm.peekPtr(pArgv + (wasm.pointerSizeof * i)),
+ wasm.peekPtr(wasm.ptrAdd(pArgv, wasm.pointerSizeof * i)),
throwIfCannotConvert
));
}
*/
sii.prototype.nthConstraint = function(n, asPtr=false){
if(n<0 || n>=this.$nConstraint) return false;
- const ptr = this.$aConstraint + (
+ const ptr = wasm.ptrAdd(
+ this.$aConstraint,
sii.sqlite3_index_constraint.structInfo.sizeof * n
);
return asPtr ? ptr : new sii.sqlite3_index_constraint(ptr);
*/
sii.prototype.nthConstraintUsage = function(n, asPtr=false){
if(n<0 || n>=this.$nConstraint) return false;
- const ptr = this.$aConstraintUsage + (
+ const ptr = wasm.ptrAdd(
+ this.$aConstraintUsage,
sii.sqlite3_index_constraint_usage.structInfo.sizeof * n
);
return asPtr ? ptr : new sii.sqlite3_index_constraint_usage(ptr);
*/
sii.prototype.nthOrderBy = function(n, asPtr=false){
if(n<0 || n>=this.$nOrderBy) return false;
- const ptr = this.$aOrderBy + (
+ const ptr = wasm.ptrAdd(
+ this.$aOrderBy,
sii.sqlite3_index_orderby.structInfo.sizeof * n
);
return asPtr ? ptr : new sii.sqlite3_index_orderby(ptr);
be a pointer type and is treated as the WASM numeric type
appropriate for the pointer size (==this.pointerIR).
- While likely not obvious, this routine and its poke()
- counterpart are how pointer-to-value _output_ parameters
- in WASM-compiled C code can be interacted with:
+ While possibly not obvious, this routine and its poke()
+ counterpart are how pointer-to-value _output_ parameters in
+ WASM-compiled C code can be interacted with:
```
const ptr = alloc(4);
poke32(ptr, 0); // clear the ptr's value
- aCFuncWithOutputPtrToInt32Arg( ptr ); // e.g. void foo(int *x);
+ aCFuncWithOutputPtrToInt32Arg(ptr); // e.g. void foo(int *x);
const result = peek32(ptr); // fetch ptr's value
dealloc(ptr);
```
try{
const ptr = scopedAlloc(4);
poke32(ptr, 0);
- aCFuncWithOutputPtrArg( ptr );
+ aCFuncWithOutputPtrArg(ptr);
result = peek32(ptr);
}finally{
scopedAllocPop(scope);
painful impact on performance. Rather than doing so, use
heapForSize() to fetch the heap object and read directly from it.
+ ACHTUNG #2: ptr may be a BigInt (and generally will be in 64-bit
+ builds) but this function must coerce it into a Number in order
+ to access the heap's contents. Ergo: BitInts outside of the
+ (extrardinarily genereous) address range exposed to browser-side
+ WASM may cause misbehavior.
+
See also: poke()
*/
target.peek = function f(ptr, type='i8'){
Returns `this`. (Prior to 2022-12-09 it returned this function.)
- ACHTUNG: calling this often, e.g. in a loop to populate a large
- chunk of memory, can have a noticably painful impact on
- performance. Rather than doing so, use heapForSize() to fetch the
- heap object and assign directly to it or use the heap's set()
- method.
+ ACHTUNG #1: see peek()'s ACHTUNG #1.
+
+ ACHTUNG #2: see peek()'s ACHTUNG #2.
*/
target.poke = function(ptr, value, type='i8'){
if (type.endsWith('*')) type = ptrIR;
target.cArgvToJs = (argc, pArgv)=>{
const list = [];
for(let i = 0; i < argc; ++i){
- const arg = target.peekPtr(pArgv + (target.pointerSizeof * i));
+ const arg = target.peekPtr(__ptrAdd(pArgv, target.pointerSizeof * i));
list.push( arg ? target.cstrToJs(arg) : null );
}
return list;
/* This Number(i) is unsatisfying but it enables i32-type args which
are inadvertently passed a BigInt (which is easy to do) to
play along instead of causing an exception about lack of implicit
- conversions from BigInt to Number. */
+ conversions from BigInt to Number. Or, more cryptically, a
+ function signature mismatch error without much context to track
+ it down. */
: (i)=>i|0
);
xArg
if(!this.pointer){
toss("Cannot set struct property on disposed instance.");
}
- if(null===v) v = 0;
+ if(null===v) v = __NullPtr;
else while(!isNumericValue(v)){
if(isAutoPtrSig(descr.signature) && (v instanceof StructType)){
// It's a struct instance: let's store its pointer value!
- v = v.pointer || 0;
+ v = v.pointer || __NullPtr;
if(dbg.setter) log("debug.setter:",xPropName,"resolved to",v);
break;
}
toss("Invalid value for pointer-type",xPropName+'.');
}
(
- new DataView(heap().buffer, Number(this.pointer) + descr.offset, descr.sizeof)
+ new DataView(heap().buffer, Number(this.pointer) + descr.offset,
+ descr.sizeof)
)[f._.setters[sigGlyph]](0, f._.sw[sigGlyph](v), isLittleEndian);
};
}
name:'Scalar UDFs',
test: function(sqlite3){
const db = this.db;
- db.createFunction("foo",(pCx,a,b)=>a+b);
+ db.createFunction(
+ "foo",
+ 1 ? (pCx,a,b)=>a+b
+ : (pCx,a,b)=>{
+ /*return sqlite3.capi.sqlite3_result_error_js(
+ db, sqlite3.capi.SQLITE_ERROR, "foo???"
+ );*/
+ console.debug("foo UDF", pCx, a, b);
+ return Number(a)+Number(b);
+ }
+ );
T.assert(7===db.selectValue("select foo(3,4)")).
assert(5===db.selectValue("select foo(3,?)",2)).
assert(5===db.selectValue("select foo(?,?2)",[1,4])).
.assert(wasm.isPtr(pVoid))
.assert(wasm.isPtr(aVals))
.assert(wasm.isPtr(aCols))
- .assert(+wasm.cstrToJs(wasm.peekPtr(aVals + wasm.pointerSizeof))
+ .assert(+wasm.cstrToJs(wasm.peekPtr(wasm.ptrAdd(aVals, wasm.pointerSizeof)))
=== 2 * +wasm.cstrToJs(wasm.peekPtr(aVals)));
return 0;
});
in the call :/ */));
const pMin = w.scopedAlloc(16);
- const pMax = pMin + 8;
+ const pMax = w.ptrAdd(pMin, 8);
const g64 = (p)=>w.peek64(p);
w.poke64([pMin, pMax], 0);
const minMaxI64 = [
ext/misc/templatevtab.c.
*/
const tmplMod = new sqlite3.capi.sqlite3_module();
- T.assert(0===tmplMod.$xUpdate);
+ T.assert(!tmplMod.$xUpdate);
tmplMod.setupModule({
catchExceptions: false,
methods: {
}
});
this.db.onclose.disposeAfter.push(tmplMod);
- T.assert(0===tmplMod.$xUpdate)
+ T.assert(!tmplMod.$xUpdate)
.assert(tmplMod.$xCreate)
.assert(tmplMod.$xCreate === tmplMod.$xConnect,
"setup() must make these equivalent and "+
-C Further\swork\son\s64-bit\sWASM\sbuilds.\sIt\snow\sgets\sthrough\sjust\sshy\sof\shalf\sof\stester1.js.
-D 2025-09-20T15:16:55.119
+C Get\sseveral\shundred\smore\slines\sof\stester1.js\srunning\sin\s64-bit\smode.
+D 2025-09-20T17:11:57.424
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F ext/wasm/api/post-js-header.js 53740d824e5d9027eb1e6fd59e216abbd2136740ce260ea5f0699ff2acb0a701
F ext/wasm/api/pre-js.c-pp.js 58f823de197e2c10d76179aa05410a593b7ae03e1ece983bb42ffd818e8857e1
F ext/wasm/api/sqlite3-api-cleanup.js 6341cb85c931044647ad4b12654a178c81f5a8fbeccdf4dc4f258e5a390d2241
-F ext/wasm/api/sqlite3-api-glue.c-pp.js 8d399c686b068427b4c9e51d68d9fc1f632ee9c89a1c49d3e2919744d68c622a
-F ext/wasm/api/sqlite3-api-oo1.c-pp.js c40857ef457c1243d40dd92602e362e7431500936b0358263e8caa115436e705
-F ext/wasm/api/sqlite3-api-prologue.js 1f3aa229e225f8f93e6011d64c7ecd1ac2e4a70b94d8f78f493e1a7dbb236e47
+F ext/wasm/api/sqlite3-api-glue.c-pp.js a122488b81054d85c744f20ae0447aa0676b14adcb6f6f9c47ec6344327afbde
+F ext/wasm/api/sqlite3-api-oo1.c-pp.js b926a070fbe9db3ac4f3b0bc5f006aa28350c62e1ec0949643e21f2db191ce5a
+F ext/wasm/api/sqlite3-api-prologue.js 99a5c4a48d26bf3ae6210fe789c1ba9a01106da28b29cd57a03760fd2aef7fdc
F ext/wasm/api/sqlite3-api-worker1.c-pp.js 760191cd13416e6f5adfd9fcc8a97fed5645c9e0a5fbac213a2d4ce2d79a4334
F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
F ext/wasm/api/sqlite3-opfs-async-proxy.js 9654b565b346dc609b75d15337f20acfa7af7d9d558da1afeb9b6d8eaa404966
F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d
F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 0f68a64e508598910e7c01214ae27d603dfc8baec6a184506fafac603a901931
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 4ab0704ee198de7d1059eccedc7703c931510b588d10af0ee36ea5b3ebbac284
-F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616
+F ext/wasm/api/sqlite3-vtab-helper.c-pp.js fb8335229cf14ef5649f1e0b54c0196854c992441846565fecb75023412f36cd
F ext/wasm/api/sqlite3-wasm.c 75c50e7721136b60e2132537e039f6b85991449c761090709c2d920c4b82f420
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 4ad256b4ff7f839ad18931ed35d46cced544207bd2209665ec552e193f7f4544
F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5
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 1b4b0b38b590221bad5d9d807b1d30127626ddc05f616182f01423ac8fcce089
+F ext/wasm/common/whwasmutil.js 091c3f0c669e4b151a159c3974dc2302875d282688118156606b536bb180d60a
F ext/wasm/config.make.in c424ae1cc3c89274520ad312509d36c4daa34a3fce5d0c688e5f8f4365e1049a
F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
F ext/wasm/fiddle/index.html 17c7d6b21f40fbf462162c4311b63d760b065e419d9f5a96534963b0e52af940
F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf188f024b3730
F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d
-F ext/wasm/jaccwabyt/jaccwabyt.js 45142de663ef1f933b082adcc0f5898d7353cdcebe7e0319178fedbc12132d28
+F ext/wasm/jaccwabyt/jaccwabyt.js 9a8b8097161164284249fbd3c08bf4aa86f917a0862ae9a01b7bc4ef7d921c29
F ext/wasm/jaccwabyt/jaccwabyt.md 1128e3563e7eff90b5a373395251fc76cb32386fad1fea6075b0f34a8f1b9bdf
F ext/wasm/mkwasmbuilds.c cc66cfaf8673ece3c30ca7fe28f6111481090648098a143ea619a8820b8fbe82
F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337
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 7f32d79407cce016cde0e884e364d5fb04addeb7cb7f43b30169cdd938589634
+F ext/wasm/tester1.c-pp.js 72bd2ed5b356ca18adb2e5bb2aa40f10c088d41dead68679c4c7bc54d38f1422
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
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P a5af46174a05e1414370884d1a99827af9286a60eff1c8ae1551e7fad3903f7a
-R 2adec1131b74b3b8137161b75e6957cf
+P c8deed31365898e1379d577298fc80ef08a5531999d5b54a9f14337febed0260
+R 81c442e049a311dffb6931b46cc3b75c
U stephan
-Z 0d524ac36a249cd8e25e154440f46d24
+Z 133106b4a0e2f429661a21a8027537f6
# Remove this line to create a well-formed Fossil manifest.
-c8deed31365898e1379d577298fc80ef08a5531999d5b54a9f14337febed0260
+f5105ee5defa042508a68a1f4e23b9fff46a1697b1a727e01c3edea3030fbcb5