Remove some dead JS code and tweak some docs.

FossilOrigin-Name: 0ee495452c014680697aa9035c245024df127a52d1820ab0e02580a015d96ecb
This commit is contained in:
stephan 2022-12-08 04:19:38 +00:00
parent 1eb1b59b89
commit ab8b22a03d
7 changed files with 50 additions and 53 deletions

View File

@ -13,7 +13,7 @@
A Worker which manages asynchronous OPFS handles on behalf of a
synchronous API which controls it via a combination of Worker
messages, SharedArrayBuffer, and Atomics. It is the asynchronous
counterpart of the API defined in sqlite3-api-opfs.js.
counterpart of the API defined in sqlite3-vfs-opfs.js.
Highly indebted to:
@ -343,16 +343,6 @@ const installAsyncProxy = function(self){
const affirmNotRO = function(opName,fh){
if(fh.readOnly) toss(opName+"(): File is read-only: "+fh.filenameAbs);
};
const affirmLocked = function(opName,fh){
//if(!fh.syncHandle) toss(opName+"(): File does not have a lock: "+fh.filenameAbs);
/**
Currently a no-op, as speedtest1 triggers xRead() without a
lock (that seems like a bug but it's currently uninvestigated).
This means, however, that some OPFS VFS routines may trigger
acquisition of a lock but never let it go until xUnlock() is
called (which it likely won't be if xLock() was not called).
*/
};
/**
We track 2 different timers: the "metrics" timer records how much
@ -393,7 +383,6 @@ const installAsyncProxy = function(self){
*/
let flagAsyncShutdown = false;
/**
Asynchronous wrappers for sqlite3_vfs and sqlite3_io_methods
methods, as well as helpers like mkdir(). Maintenance reminder:
@ -427,11 +416,11 @@ const installAsyncProxy = function(self){
},
xAccess: async (filename)=>{
mTimeStart('xAccess');
/* OPFS cannot support the full range of xAccess() queries sqlite3
calls for. We can essentially just tell if the file is
accessible, but if it is it's automatically writable (unless
it's locked, which we cannot(?) know without trying to open
it). OPFS does not have the notion of read-only.
/* OPFS cannot support the full range of xAccess() queries
sqlite3 calls for. We can essentially just tell if the file
is accessible, but if it is then it's automatically writable
(unless it's locked, which we cannot(?) know without trying
to open it). OPFS does not have the notion of read-only.
The return semantics of this function differ from sqlite3's
xAccess semantics because we are limited in what we can
@ -519,7 +508,6 @@ const installAsyncProxy = function(self){
let rc = 0;
wTimeStart('xFileSize');
try{
affirmLocked('xFileSize',fh);
const sz = await (await getSyncHandle(fh,'xFileSize')).getSize();
state.s11n.serialize(Number(sz));
}catch(e){
@ -615,7 +603,6 @@ const installAsyncProxy = function(self){
let rc = 0, nRead;
const fh = __openFiles[fid];
try{
affirmLocked('xRead',fh);
wTimeStart('xRead');
nRead = (await getSyncHandle(fh,'xRead')).read(
fh.sabView.subarray(0, n),
@ -659,7 +646,6 @@ const installAsyncProxy = function(self){
const fh = __openFiles[fid];
wTimeStart('xTruncate');
try{
affirmLocked('xTruncate',fh);
affirmNotRO('xTruncate', fh);
await (await getSyncHandle(fh,'xTruncate')).truncate(size);
}catch(e){
@ -696,7 +682,6 @@ const installAsyncProxy = function(self){
const fh = __openFiles[fid];
wTimeStart('xWrite');
try{
affirmLocked('xWrite',fh);
affirmNotRO('xWrite', fh);
rc = (
n === (await getSyncHandle(fh,'xWrite'))

View File

@ -538,6 +538,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
try{return func(...arguments) || 0;}
catch(e){
if(!(e instanceof sqlite3.WasmAllocError)){
wasm.dealloc(wasm.getPtrValue(pzErr));
wasm.setPtrValue(pzErr, wasm.allocCString(e.message));
}
return vt.xError(methodName, e);

View File

@ -75,7 +75,7 @@
</li>
<li>The easiest way to try different optimization levels is,
from this directory:
<pre>$ rm -f speedtest1.js; make -e emcc_opt='-O2' speedtest1.js</pre>
<pre>$ rm -f jswasm/speedtest1.js; make -e emcc_opt='-O2' speedtest1</pre>
Then reload this page. -O2 seems to consistently produce the fastest results.
</li>
</ul>

View File

@ -40,9 +40,9 @@
<script src="jswasm/speedtest1.js"></script>
<script>(function(){
/**
If this environment contains OPFS, this function initializes it and
returns the name of the dir on which OPFS is mounted, else it returns
an empty string.
If this environment contains WASMFS with OPFS, this function
initializes it and returns the name of the dir on which OPFS is
mounted, else it returns an empty string.
*/
const wasmfsDir = function f(wasmUtil){
if(undefined !== f._) return f._;

View File

@ -22,12 +22,14 @@
groups and individual tests can be assigned a predicate function
which determines whether to run them or not, and this is
specifically intended to be used to toggle certain tests on or off
for the main/worker threads.
for the main/worker threads or the availability (or not) of
optional features such as int64 support.
Each test group defines a state object which gets applied as each
test function's `this`. Test functions can use that to, e.g., set up
a db in an early test and close it in a later test. Each test gets
passed the sqlite3 namespace object as its only argument.
Each test group defines a single state object which gets applied as
the test functions' `this` for all tests in that group. Test
functions can use that to, e.g., set up a db in an early test and
close it in a later test. Each test gets passed the sqlite3
namespace object as its only argument.
*/
/*
This file is intended to be processed by c-pp to inject (or not)
@ -1680,6 +1682,7 @@ self.sqlite3InitModule = sqlite3InitModule;
return rc;
}catch(e){
if(!(e instanceof sqlite3.WasmAllocError)){
wasm.dealloc(wasm.getPtrValue, pzErr);
wasm.setPtrValue(pzErr, wasm.allocCString(e.message));
}
return vth.xError('xConnect',e);
@ -1883,10 +1886,10 @@ self.sqlite3InitModule = sqlite3InitModule;
callback sets an error string. */;
const modConfig = {
/* catchExceptions changes how the methods are wrapped */
catchExceptions: false,
catchExceptions: true,
name: "vtab2test",
methods:{
xConnect: function(pDb, pAux, argc, argv, ppVtab, pzErr){
xCreate: function(pDb, pAux, argc, argv, ppVtab, pzErr){
if(throwOnConnect){
sqlite3.SQLite3Error.toss(
throwOnConnect,
@ -1967,7 +1970,7 @@ self.sqlite3InitModule = sqlite3InitModule;
}
}/*methods*/
};
const doEponymous =
const doEponymousOnly =
/* Bug (somewhere): non-eponymous is behaving as is
the call to sqlite3_create_module() is missing
or failed:
@ -1976,29 +1979,36 @@ self.sqlite3InitModule = sqlite3InitModule;
=> sqlite3 result code 1: no such module: vtab2test
*/ true;
if(doEponymous){
modConfig.methods.xConnect =
modConfig.methods.xCreate;
if(doEponymousOnly){
warn("Reminder: non-eponymous mode is still not working here.",
"Details are in the code comments.");
"Details are in the code comments.");
modConfig.methods.xCreate = 0;
}else{
modConfig.methods.xCreate = (...args)=>0;
/*(...args)=>{
try{return modConfig.methods.xConnect(...args)}
catch(e){return vth.xError('xConnect',e)}
};*/
}
const tmplMod = vth.setupModule(modConfig);
T.assert(tmplMod instanceof capi.sqlite3_module)
.assert(1===tmplMod.$iVersion);
if(doEponymous){
if(doEponymousOnly){
if(modConfig.methods.xCreate !== 0){
T.assert(modConfig.methods.xCreate === modConfig.methods.xConnect)
.assert(tmplMod.$xCreate === tmplMod.$xConnect);
}else{
T.assert(0 === tmplMod.$xCreate);
}
}else{
//T.assert(tmplMod.$xCreate !== tmplMod.$xConnect);
}
this.db.onclose.disposeThese.push(tmplMod);
this.db.checkRc(capi.sqlite3_create_module(
this.db, modConfig.name, tmplMod, 0
this.db.pointer, modConfig.name, tmplMod.pointer, 0
));
if(!doEponymous){
if(!doEponymousOnly){
this.db.exec([
"create virtual table testvtab2 using ",
modConfig.name,
@ -2007,7 +2017,7 @@ self.sqlite3InitModule = sqlite3InitModule;
}
const list = this.db.selectArrays(
["SELECT a,b FROM ",
(doEponymous ? modConfig.name : "testvtab2"),
(doEponymousOnly ? modConfig.name : "testvtab2"),
" where a<9999 and b>1 order by a, b"
]/* Query is shaped so that it will ensure that some
constraints end up in xBestIndex(). */
@ -2041,7 +2051,8 @@ self.sqlite3InitModule = sqlite3InitModule;
})
.t({
name: 'kvvfs in main thread',
predicate: ()=>(isUIThread() ? true : "No local/sessionStorage in Worker"),
predicate: ()=>(isUIThread()
|| "local/sessionStorage are unavailable in a Worker"),
test: function(sqlite3){
const filename = this.kvvfsDbFile = 'session';
const pVfs = capi.sqlite3_vfs_find('kvvfs');
@ -2086,7 +2097,7 @@ self.sqlite3InitModule = sqlite3InitModule;
delete this.kvvfsUnlink;
delete this.JDb;
}
}/*kvvfs sqlite3_js_vfs_create_file()*/)
}/*kvvfs sqlite3_js_vfs_create_file()*/)
;/* end kvvfs tests */
////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
C Work\son\san\salternate\s(slightly\ssimpler)\sapproach\sto\sbinding\sJS\svtabs.\sNon-eponymous\svtabs\sare\snot\sworking,\sfor\sreasons\sas\syet\sunknown.
D 2022-12-07T07:22:34.835
C Remove\ssome\sdead\sJS\scode\sand\stweak\ssome\sdocs.
D 2022-12-08T04:19:38.945
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -508,8 +508,8 @@ F ext/wasm/api/sqlite3-api-oo1.js 416e6398721a4cbb80ddfa3d7b303216790f1d344efdbb
F ext/wasm/api/sqlite3-api-prologue.js 1380e933325c11786b2afc93fc8ff88c2fd1ffeac3e0081da35e5a7317f20e09
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 f79dd8d98ef3e0b55c10bb2bee7a3840fa967318e1f577c156aafc34664271d1
F ext/wasm/api/sqlite3-v-helper.js c0c56d4fb1272140629ac858297a825e0a8e04005df92c70ef4a4aa75d4d4645
F ext/wasm/api/sqlite3-opfs-async-proxy.js 7795b84b66a7a8dedc791340709b310bb497c3c72a80bef364fa2a58e2ddae3f
F ext/wasm/api/sqlite3-v-helper.js 963fb63493ce7efdae3c434e2dbd45e6a5c0b6566ea8ac533116941d03b9dc23
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 8ec510fee735c646fb18a3b99f0ca5ca461f9e066c43cdc404d7144f12ae6ed6
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
F ext/wasm/api/sqlite3-wasm.c 723522a6c2a2463884a83fa1cc7ae5770deaaf0856a1058cc1023b2bfa1c898b
@ -545,9 +545,9 @@ F ext/wasm/module-symbols.html 980680c8acfa3c8ae6a5aa223512d1b8e78040ced20f8ba2c
F ext/wasm/scratchpad-wasmfs-main.html 20cf6f1a8f368e70d01e8c17200e3eaa90f1c8e1029186d836d14b83845fbe06
F ext/wasm/scratchpad-wasmfs-main.js 4c140457f4d6da9d646a49addd91edb6e9ad1643c6c48e3258b5bce24725dc18
F ext/wasm/speedtest1-wasmfs.html bc28eb29b69a73864b8d7aae428448f8b7e1de81d8bfb9bba99541322054dbd0
F ext/wasm/speedtest1-worker.html e94cecebcbb9d187647025edd04d37af9789dfba98c2cc439b549b5ae8a8bc93
F ext/wasm/speedtest1-worker.html fe6b36a63de1012bb9fb4d2fb888b6de9c589c21b0aa3ae054459b0093e077bf
F ext/wasm/speedtest1-worker.js 13b57c4a41729678a1194014afec2bd5b94435dcfc8d1039dfa9a533ac819ee1
F ext/wasm/speedtest1.html e4c4e5c1c8ec1ad13c995e346e4216a1df152fd2c5cd17e0793b865b2f3c5000
F ext/wasm/speedtest1.html ff048b4a623aa192e83e143e48f1ce2a899846dd42c023fdedc8772b6e3f07da
F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
@ -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 d43f3c131d88f10d00aff3e328fed13c858d674ea2ff1ff90225506137f85aa9
F ext/wasm/tester1.c-pp.html d34bef3d48e5cbc1c7c06882ad240fec49bf88f5f65696cc2c72c416933aa406
F ext/wasm/tester1.c-pp.js 661c9461fa104f231ff9e767c89ba1fc4a4af6a61db076772ca634d562afd35d
F ext/wasm/tester1.c-pp.js cf8d0c4ecf255886b6cb7e0d8e5f54a091d06584f5f3b20bc8f2128692fffcdf
F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@ -2067,8 +2067,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 6a2723fe3f28dd94328d901e64e1e9ee9a1b2e9eeaed6c54038a5b83c914db78
R 8623f61e63ac3c807b096f8d7028ccc0
P 6a0fefb93bcccd950df211cf5c2f49660c7b92115dd01b2b508a4ab9e3ab3d23
R f94a2c459277216db79da2d45589f3a1
U stephan
Z 80cda1da5b829b2851b20f834a26edf8
Z b8f7b8c54d4f2428fc7b85ce6a8bd62e
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
6a0fefb93bcccd950df211cf5c2f49660c7b92115dd01b2b508a4ab9e3ab3d23
0ee495452c014680697aa9035c245024df127a52d1820ab0e02580a015d96ecb