########################################################################
# https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
#
-# -sMEMORY64=2 builds and loads but dies when we do things like:
-#
-# new Uint8Array(wasm.heap8u().buffer, ptr, n)
-#
-# because ptr is now a BigInt, so is invalid for passing to arguments
-# which have strict must-be-a-Number requirements. That aspect will
-# make any eventual port to 64-bit address space painful, as such
-# constructs are found all over the place in the source code. We can
-# potentially replace all such uses with Number(ptr) as a
-# workaround. WASM 3.0[^wasm3] says that browsers will be limited to
-# 16gb, which is still well, well within range of
-# Number.MAX_SAFE_INTEGER. i.e. such a hack, though unsightly, would
-# seem to pose no inherent problems. The hard part will be finding all
-# such cases.
-#
-# Notes related to getting it working with MEMORY64 with emcc
-# versions 4.0.11-15:
-#
-# WebAssembly.Table.get(ARG) wants BigInt if MEMORY64=1 but a number
-# if MEMORY64=2.
-#
-# Requires wasm-strip 1.0.36 (maybe 1.0.35, but not 1.0.34) or
-# will fail to strip with "tables may not be 64-bit".
-#
-# [^wasm3]: https://webassembly.org/news/2025-09-17-wasm-3.0/
+# 64-bit build requires wasm-strip 1.0.36 (maybe 1.0.35, but not
+# 1.0.34) or will fail to strip with "tables may not be 64-bit".
########################################################################
ifneq (0,$(emcc.MEMORY64))
emcc.INITIAL_MEMORY.32 = 33554432
emcc.INITIAL_MEMORY.16 = 16777216
emcc.INITIAL_MEMORY.8 = 8388608
-emcc.INITIAL_MEMORY ?= 16
+emcc.INITIAL_MEMORY ?= 8
ifeq (,$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY)))
$(error emcc.INITIAL_MEMORY must be one of: 8, 16, 32, 64, 96, 128 (megabytes))
endif
--minify 0 \
-sALLOW_TABLE_GROWTH \
-sMEMORY64=$(emcc.MEMORY64) \
+ -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.8) \
-sABORTING_MALLOC \
-sSTRICT_JS=0 \
-sENVIRONMENT=web,worker \
}finally{
delete f._running;
wMsg('working','end');
+ wMsg('wasm-info', {
+ pointerSize: sqlite3.wasm.ptr.size,
+ heapSize: sqlite3.wasm.heap8().byteLength
+ });
}
},
resetDb: function f(){
}
//console.debug("worker: onmessage.data",ev);
switch(ev.type){
- case 'shellExec': Sqlite3Shell.exec(ev.data); return;
- case 'db-reset': Sqlite3Shell.resetDb(); return;
- case 'interrupt': Sqlite3Shell.interrupt(); return;
- /** Triggers the export of the current db. Fires an
- event in the form:
-
- {type:'db-export',
- data:{
- filename: name of db,
- buffer: contents of the db file (Uint8Array),
- error: on error, a message string and no buffer property.
- }
- }
- */
- case 'db-export': {
- const fn = Sqlite3Shell.dbFilename();
- stdout("Exporting",fn+".");
- const fn2 = fn ? fn.split(/[/\\]/).pop() : null;
- try{
- if(!fn2) toss("DB appears to be closed.");
- const buffer = sqlite3.capi.sqlite3_js_db_export(
- Sqlite3Shell.dbHandle()
- );
- wMsg('db-export',{filename: fn2, buffer: buffer.buffer}, [buffer.buffer]);
- }catch(e){
- console.error("Export failed:",e);
- /* Post a failure message so that UI elements disabled
- during the export can be re-enabled. */
- wMsg('db-export',{
- filename: fn,
- error: e.message
- });
- }
+ case 'shellExec': Sqlite3Shell.exec(ev.data); return;
+ case 'db-reset': Sqlite3Shell.resetDb(); return;
+ case 'interrupt': Sqlite3Shell.interrupt(); return;
+ /** Triggers the export of the current db. Fires an
+ event in the form:
+
+ {type:'db-export',
+ data:{
+ filename: name of db,
+ buffer: contents of the db file (Uint8Array),
+ error: on error, a message string and no buffer property.
+ }
+ }
+ */
+ case 'db-export': {
+ const fn = Sqlite3Shell.dbFilename();
+ stdout("Exporting",fn+".");
+ const fn2 = fn ? fn.split(/[/\\]/).pop() : null;
+ try{
+ if(!fn2) toss("DB appears to be closed.");
+ const buffer = sqlite3.capi.sqlite3_js_db_export(
+ Sqlite3Shell.dbHandle()
+ );
+ wMsg('db-export',{filename: fn2, buffer: buffer.buffer}, [buffer.buffer]);
+ }catch(e){
+ console.error("Export failed:",e);
+ /* Post a failure message so that UI elements disabled
+ during the export can be re-enabled. */
+ wMsg('db-export',{
+ filename: fn,
+ error: e.message
+ });
+ }
+ return;
+ }
+ case 'open': {
+ /* Expects: {
+ buffer: ArrayBuffer | Uint8Array,
+ filename: the filename for the db. Any dir part is stripped.
+ }
+ */
+ const opt = ev.data;
+ let buffer = opt.buffer;
+ stderr('open():',fixmeOPFS);
+ if(buffer instanceof ArrayBuffer){
+ buffer = new Uint8Array(buffer);
+ }else if(!(buffer instanceof Uint8Array)){
+ stderr("'open' expects {buffer:Uint8Array} containing an uploaded db.");
return;
}
- case 'open': {
- /* Expects: {
- buffer: ArrayBuffer | Uint8Array,
- filename: the filename for the db. Any dir part is
- stripped.
- }
- */
- const opt = ev.data;
- let buffer = opt.buffer;
- stderr('open():',fixmeOPFS);
- if(buffer instanceof ArrayBuffer){
- buffer = new Uint8Array(buffer);
- }else if(!(buffer instanceof Uint8Array)){
- stderr("'open' expects {buffer:Uint8Array} containing an uploaded db.");
- return;
+ buffer.set([1,1], 18)/*force db out of WAL mode*/;
+ const fn = (
+ opt.filename
+ ? opt.filename.split(/[/\\]/).pop().replace(/["'\s]/g,'_')
+ : ("db-"+((Math.random() * 10000000) | 0)+
+ "-"+((Math.random() * 10000000) | 0)+".sqlite3")
+ );
+ try {
+ /* We cannot delete the existing db file until the new one
+ is installed, which means that we risk overflowing our
+ quota (if any) by having both the previous and current
+ db briefly installed in the virtual filesystem. */
+ const fnAbs = '/'+fn;
+ const oldName = Sqlite3Shell.dbFilename();
+ if(oldName && oldName===fnAbs){
+ /* We cannot create the replacement file while the current file
+ is opened, nor does the shell have a .close command, so we
+ must temporarily switch to another db... */
+ Sqlite3Shell.exec('.open :memory:');
+ fiddleModule.FS.unlink(fnAbs);
}
- buffer.set([1,1], 18)/*force db out of WAL mode*/;
- const fn = (
- opt.filename
- ? opt.filename.split(/[/\\]/).pop().replace(/["'\s]/g,'_')
- : ("db-"+((Math.random() * 10000000) | 0)+
- "-"+((Math.random() * 10000000) | 0)+".sqlite3")
- );
- try {
- /* We cannot delete the existing db file until the new one
- is installed, which means that we risk overflowing our
- quota (if any) by having both the previous and current
- db briefly installed in the virtual filesystem. */
- const fnAbs = '/'+fn;
- const oldName = Sqlite3Shell.dbFilename();
- if(oldName && oldName===fnAbs){
- /* We cannot create the replacement file while the current file
- is opened, nor does the shell have a .close command, so we
- must temporarily switch to another db... */
- Sqlite3Shell.exec('.open :memory:');
- fiddleModule.FS.unlink(fnAbs);
- }
- fiddleModule.FS.createDataFile("/", fn, buffer, true, true);
- Sqlite3Shell.exec('.open '+fnAbs);
- if(oldName && oldName!==fnAbs){
- try{fiddleModule.fsUnlink(oldName)}
- catch(e){/*ignored*/}
- }
- stdout("Replaced DB with",fn+".");
- }catch(e){
- stderr("Error installing db",fn+":",e.message);
+ fiddleModule.FS.createDataFile("/", fn, buffer, true, true);
+ Sqlite3Shell.exec('.open '+fnAbs);
+ if(oldName && oldName!==fnAbs){
+ try{fiddleModule.fsUnlink(oldName)}
+ catch(e){/*ignored*/}
}
- return;
+ stdout("Replaced DB with",fn+".");
+ }catch(e){
+ stderr("Error installing db",fn+":",e.message);
}
+ return;
+ }
};
sqlite3.config.warn("Unknown fiddle-worker message type:",ev);
};
].join(' ');
SF.echo("SQLite version",a.innerText);
});
+ SF.addMsgHandler('wasm-info', (ev)=>{
+ const v = ev.data;
+ SF.e.wasmInfo.innerText = 'WASM: '+(
+ 4===v.pointerSize ? 32 : 64
+ )+'-bit'
+ //+' heap size: '+Number(v.heapSize)
+ // Heap size is not changing even when loading a huge db?
+ ;
+ });
/* querySelectorAll() proxy */
const EAll = function(/*[element=document,] cssSelector*/){
SF.e ={
about: E('#view-about'),
split: E('#view-split'),
+ wasmInfo: E('#opt-wasm-info'),
terminal: E('#view-terminal'),
hideInTerminal: EAll('.hide-in-terminal'
/* Elements to hide when in terminal mode */)
SF.addMsgHandler('working',function f(ev){
switch(ev.data){
- case 'start': /* See notes in preStartWork(). */; return;
- case 'end':
- preStartWork._.pageTitle.innerText = preStartWork._.pageTitleOrig;
- btnShellExec.innerText = preStartWork._.btnLabel;
- btnShellExec.removeAttribute('disabled');
- btnInterrupt.setAttribute('disabled','disabled');
- return;
+ case 'start': /* See notes in preStartWork(). */; return;
+ case 'end':
+ preStartWork._.pageTitle.innerText = preStartWork._.pageTitleOrig;
+ btnShellExec.innerText = preStartWork._.btnLabel;
+ btnShellExec.removeAttribute('disabled');
+ btnInterrupt.setAttribute('disabled','disabled');
+ return;
}
console.warn("Unhandled 'working' event:",ev.data);
});
data-config='autoClearOutput'>
<label for='opt-cb-autoclear'>Auto-clear output</label>
</span>
+ <span class='labeled-input'>
+ <span id='opt-wasm-info'>WASM: ???</span>
+ </span>
</div>
</fieldset><!-- .options -->
-C Improve\sdb-close-time\scleanup\sin\sthe\sface\sof\sWASM\senvironments\swhich\swrap\swasm.exports\sin\snullary\swrappers.
-D 2025-09-21T21:37:44.732
+C Remove\ssome\sstale\smakefile\scomments.\sAdd\sa\slittle\swidget\sto\sfiddle's\stoolbar\swhich\sshows\swhether\sit's\srunning\sin\s32-\sor\s64-bit\smode.\sReduce\sfiddle's\sstarting\smemory\sto\s8MB.
+D 2025-09-21T22:08:05.410
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F ext/session/sqlite3session.h 7404723606074fcb2afdc6b72c206072cdb2b7d8ba097ca1559174a80bc26f7a
F ext/session/test_session.c 8766b5973a6323934cb51248f621c3dc87ad2a98f023c3cc280d79e7d78d36fb
F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
-F ext/wasm/GNUmakefile 66dcdb324e598d3acb995936779b0d6ab21eaccf9cbad15c2355bcaca83cef5a
+F ext/wasm/GNUmakefile 0d44bd3fb861f062b27ec86c43e62230b43d7f0125c1dc6e48b71082385e97cd
F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7
F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
F ext/wasm/demo-worker1.js 08720227e98fa5b44761cf6e219269cee3e9dd0421d8d91459535da776950314
F ext/wasm/dist.make 57f5da2f0de5a297b5a0bc39ffec736380050578240ab24d864c2ff1b3634a3b
F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f
-F ext/wasm/fiddle.make 732b5ba2d5c164080f7918eb4a82447a0039254867d775ba7603bd8bce2b6ac3
-F ext/wasm/fiddle/fiddle-worker.js 52c67e450414cf010349b3758a3d7b0d859343eab6b794450297fa23e8d7e510
-F ext/wasm/fiddle/fiddle.js f0b96f978c7c77fea8d092aa79c77849ce111d7b1ba60ffba07675009682184e
-F ext/wasm/fiddle/index.html 17c7d6b21f40fbf462162c4311b63d760b065e419d9f5a96534963b0e52af940
+F ext/wasm/fiddle.make 7ed14ba851d331b62ea9ddfcdb62184ff853c5620c3856631310ca0f9633ef93
+F ext/wasm/fiddle/fiddle-worker.js 7798af02e672e088ff192716f80626c8895e19301a65b8af6d5d12b2d13d2451
+F ext/wasm/fiddle/fiddle.js 84fd75967e0af8b69d3dd849818342227d0f81d13db92e0dcbc63649b31a4893
+F ext/wasm/fiddle/index.html a27b8127ef9ecf19612da93b2a6a73bdb3777b5c56b5450bb7200a94bc108ff9
F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf188f024b3730
F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d
F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P d078aff7817ccd4f891024e55703519307a53815d472086bf3d42b2be28698b3
-R 51ab76aa9ee6d425c9d874d1286e989e
+P fbb63634eab83fda0090fe2c38bda735b497fd6e57dd36344559962e396dbb17
+R d67582423b2c2c6929b0f1d8cd9476c3
U stephan
-Z 2f08594990dc8fea327b2a90ca76573b
+Z e195b384ebace9a48fcf96bc6ce65ea3
# Remove this line to create a well-formed Fossil manifest.
-fbb63634eab83fda0090fe2c38bda735b497fd6e57dd36344559962e396dbb17
+e99730f96e13f7497a871fdcc5eaa4187835f005a759f0fc79bbfe982f454437