Initial build of speedtest1.wasm and speedtest1.html with which to run it.

FossilOrigin-Name: 4441535e3e54dc1881f700fa3878964eb8554a6790fd6aa32945f7cc104a8467
This commit is contained in:
stephan 2022-09-06 16:47:43 +00:00
parent 09aa80d109
commit 100b496dd2
5 changed files with 165 additions and 13 deletions

View File

@ -33,6 +33,10 @@ dir.jacc := jaccwabyt
dir.common := common
CLEAN_FILES := *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~
sqlite3.c := $(dir.top)/sqlite3.c
$(sqlite3.c):
$(MAKE) -C $(dir.top) sqlite3.c
SQLITE_OPT = \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_RTREE \
@ -53,8 +57,6 @@ SQLITE_OPT = \
# ^^^ MEMSYS5 is hypothetically useful for non-Emscripten builds but
# requires adding more infrastructure and fixing one spot in the
# sqlite3 internals which calls malloc() early on.
$(dir.top)/sqlite3.c:
$(MAKE) -C $(dir.top) sqlite3.c
# SQLITE_OMIT_LOAD_EXTENSION: if this is true, sqlite3_vfs::xDlOpen
# and friends may be NULL.
@ -299,6 +301,7 @@ wasm: $(sqlite3.js)
# Bits for use with batch-runner.js...
dir.sql := sql
speedtest1 := ../../speedtest1
speedtest1.c := ../../test/speedtest1.c
speedtest1.sql := $(dir.sql)/speedtest1.sql
$(speedtest1):
$(MAKE) -C ../.. speedtest1
@ -315,6 +318,38 @@ clean-batch:
batch: batch-runner.list
all: batch
speedtest1.js := speedtest1.js
$(speedtest1.js): emcc.cflags+=
$(speedtest1.js): $(speedtest1.c) $(MAKEFILE)
$(emcc.bin) -g $(emcc_opt) \
-sINVOKE_RUN=0 \
--no-entry \
-sALLOW_TABLE_GROWTH \
-sABORTING_MALLOC \
-sINITIAL_MEMORY=128450560 \
-sSTRICT_JS \
-sENVIRONMENT=web \
-sMODULARIZE \
-sEXPORT_NAME=sqlite3Speedtest1InitModule \
-Wno-limited-postlink-optimizations \
-sEXPORTED_FUNCTIONS=_main,_malloc,_free \
-sDYNAMIC_EXECUTION=0 \
--minify 0 \
-I. -I$(dir.top) \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_TEMP_STORE=3 \
-DSQLITE_OMIT_UTF16 \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_SHARED_CACHE \
'-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \
-DSQLITE_SPEEDTEST1_WASM \
$(emcc_flags_wasmfs) \
-o $@ $(speedtest1.c) $(sqlite3.c) -lm
speedtest1: $(speedtest1.js)
all: $(speedtest1.js)
CLEAN_FILES += $(speedtest1.js) $(subst .js,.wasm,$(speedtest1.js))
########################################################################
# fiddle_remote is the remote destination for the fiddle app. It
# must be a [user@]HOST:/path for rsync.

View File

@ -212,9 +212,10 @@ self.WhWasmUtilInstaller = function(target){
that will certainly change.
*/
const ptrIR = target.pointerIR || 'i32';
const ptrSizeof = ('i32'===ptrIR ? 4
: ('i64'===ptrIR
? 8 : toss("Unhandled ptrSizeof:",ptrIR)));
const ptrSizeof = target.ptrSizeof =
('i32'===ptrIR ? 4
: ('i64'===ptrIR
? 8 : toss("Unhandled ptrSizeof:",ptrIR)));
/** Stores various cached state. */
const cache = Object.create(null);
/** Previously-recorded size of cache.memory.buffer, noted so that
@ -1021,6 +1022,29 @@ self.WhWasmUtilInstaller = function(target){
(jstr, returnWithLength=false)=>__allocCStr(jstr, returnWithLength,
target.scopedAlloc, 'scopedAllocCString()');
/**
Creates an array, using scopedAlloc(), suitable for passing to a
C-level main() routine. The input is a collection with a length
property and a forEach() method. A block of memory list.length
entries long is allocated and each pointer-sized block of that
memory is populated with a scopedAllocCString() conversion of the
(''+value) of each element. Returns a pointer to the start of the
list, suitable for passing as the 2nd argument to a C-style
main() function.
Throws if list.length is falsy or scopedAllocPush() is not active.
*/
target.scopedAllocMainArgv = function(list){
if(!list.length) toss("Cannot allocate empty array.");
const pList = target.scopedAlloc(list.length * target.ptrSizeof);
let i = 0;
list.forEach((e)=>{
target.setPtrValue(pList + (target.ptrSizeof * i++),
target.scopedAllocCString(""+e));
});
return pList;
};
/**
Wraps function call func() in a scopedAllocPush() and
scopedAllocPop() block, such that all calls to scopedAlloc() and

92
ext/wasm/speedtest1.html Normal file
View File

@ -0,0 +1,92 @@
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<link rel="stylesheet" href="common/emscripten.css"/>
<link rel="stylesheet" href="common/testing.css"/>
<title>speedtest1.wasm</title>
</head>
<body>
<header id='titlebar'><span>speedtest1.wasm</span></header>
<!-- emscripten bits -->
<figure id="module-spinner">
<div class="spinner"></div>
<div class='center'><strong>Initializing app...</strong></div>
<div class='center'>
On a slow internet connection this may take a moment. If this
message displays for "a long time", intialization may have
failed and the JavaScript console may contain clues as to why.
</div>
</figure>
<div class="emscripten" id="module-status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="module-progress" hidden='1'></progress>
</div><!-- /emscripten bits -->
<div>Output is sent to the dev console because we cannot update the UI while the
speedtest is running unless/until we move the speedtest to a worker thread.</div>
<hr>
<div id='test-output'></div>
<script src="common/whwasmutil.js"></script>
<script src="common/SqliteTestUtil.js"></script>
<script src="speedtest1.js"></script>
<script>
(function(){
const eOut = document.querySelector('#test-output');
const logHtml2 = async function(cssClass,...args){
const ln = document.createElement('div');
if(cssClass) ln.classList.add(cssClass);
ln.append(document.createTextNode(args.join(' ')));
eOut.append(ln);
//this.e.output.lastElementChild.scrollIntoViewIfNeeded();
};
const doHtmlOutput = false
/* can't update DOM while speedtest is running unless we run
speedtest in a worker thread. */;
const logHtml = (...args)=>{
console.log(...args);
if(doHtmlOutput) logHtml2('', ...args);
};
const logErr = function(...args){
console.error(...args);
if(doHtmlOutput) this.logHtml2('error', ...args);
};
const runTests = function(EmscriptenModule){
console.log("Module inited.");
const wasm = {
exports: EmscriptenModule.asm,
alloc: (n)=>EmscriptenModule._malloc(n),
dealloc: (m)=>EmscriptenModule._free(m)
};
//console.debug('Emscripten Module =',EmscriptenModule);
//console.debug('wasm =',wasm);
self.WhWasmUtilInstaller(wasm);
const scope = wasm.scopedAllocPush();
try{
const maxArgc = 12;
const aArgs = [
// TODO: accept flags via URL arguments and/or a
// UI control. A multi-SELECT element should do
// nicely.
"speedtest1",
"--memdb",
"--stats"
];
wasm.xCall('__main_argc_argv', aArgs.length,
wasm.scopedAllocMainArgv(aArgs));
}finally{
wasm.scopedAllocPop(scope);
}
};
self.sqlite3TestModule.print = logHtml;
self.sqlite3TestModule.printErr = logErr;
sqlite3Speedtest1InitModule(self.sqlite3TestModule).then(function(M){
setTimeout(()=>runTests(M), 100);
});
})();
</script>
</body>
</html>

View File

@ -1,5 +1,5 @@
C Minor\sinternal\sdoc\sclarifications.
D 2022-09-06T16:35:54.448
C Initial\sbuild\sof\sspeedtest1.wasm\sand\sspeedtest1.html\swith\swhich\sto\srun\sit.
D 2022-09-06T16:47:43.072
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -474,7 +474,7 @@ F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb
F ext/wasm/EXPORTED_FUNCTIONS.fiddle db7a4602f043cf4a5e4135be3609a487f9f1c83f05778bfbdf93766be4541b96
F ext/wasm/EXPORTED_RUNTIME_METHODS.fiddle a004bd5eeeda6d3b28d16779b7f1a80305bfe009dfc7f0721b042967f0d39d02
F ext/wasm/GNUmakefile 49d76f7b4c45d6ff8cb573ba0d1dd7b4712e59582bdc1dfb2f96a4b89f47e34c
F ext/wasm/GNUmakefile 445b81c44804f029bcc938aa777ca3fe450a0061a586a21be411362575c7cf61
F ext/wasm/README.md e1ee1e7c321c6a250bf78a84ca6f5882890a237a450ba5a0649c7a8399194c52
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 77ef4bcf37e362b9ad61f9c175dfc0f1b3e571563fb311b96581cf422ee6a8ec
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
@ -494,7 +494,7 @@ F ext/wasm/batch-runner.js a727cbbffe63fd17fb5a590dc679f0b13bd51880e8f84b461d7df
F ext/wasm/common/SqliteTestUtil.js 7a543e238c2ebda922c85076abda017d0480944fdfee576692a0c3a580319ebd
F ext/wasm/common/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
F ext/wasm/common/testing.css 572cf1ffae0b6eb7ca63684d3392bf350217a07b90e7a896e4fa850700c989b0
F ext/wasm/common/whwasmutil.js 3d68a9cd87a2d8f7e6d5a78f3b829a927f2e28422685e029139f6e75d4ed42e4
F ext/wasm/common/whwasmutil.js ed10ab537b800e1f8fac9d5ecec00908f4d4b0e1a270de196e43782600ae59f7
F ext/wasm/demo-oo1.html 75646855b38405d82781246fd08c852a2b3bee05dd9f0fe10ab655a8cffb79aa
F ext/wasm/demo-oo1.js aad38cb90b6fa7fd4d1184e759b25056fb4ed45c4957c458896354281259515f
F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
@ -510,6 +510,7 @@ F ext/wasm/scratchpad-opfs-main.js 69e960e9161f6412fd0c30f355d4112f1894d6609eb43
F ext/wasm/scratchpad-opfs-worker.html 66c1d15d678f3bd306373d76b61c6c8aef988f61f4a8dd40185d452f9c6d2bf5
F ext/wasm/scratchpad-opfs-worker.js 3ec2868c669713145c76eb5877c64a1b20741f741817b87c907a154b676283a9
F ext/wasm/scratchpad-opfs-worker2.js 5f2237427ac537b8580b1c659ff14ad2621d1694043eaaf41ae18dbfef2e48c0
F ext/wasm/speedtest1.html e5b6ca8d09e15ab77fcec95ab30a330cc5376795f3d3b7cc05b9377b08824071
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
@ -2015,8 +2016,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 7f76eaec793720db87415a476ddf539bc4dea3e74c8e5406d6739206aebdacc2
R ddf4f26b01c2c564d2354931a4072700
P 09796cc2bfce7bc4ce11db9673d20737259e9928f0484660cba3a9751f7d01c5
R 98ebaeee264c8d9d604307fc8843d5b6
U stephan
Z d6b7c42fac31d9af4682922126e1ce62
Z 0a749029dbb2383547531131a6904c9b
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
09796cc2bfce7bc4ce11db9673d20737259e9928f0484660cba3a9751f7d01c5
4441535e3e54dc1881f700fa3878964eb8554a6790fd6aa32945f7cc104a8467