diff options
author | stephan <stephan@noemail.net> | 2022-09-26 13:55:10 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-26 13:55:10 +0000 |
commit | 278d3faf1ffa6bbd14253865edba3e81631d0cb5 (patch) | |
tree | fe54c334cfee9001d5f3d1d7a05cb2d0d31f8735 /ext/wasm/common/whwasmutil.js | |
parent | 1f095d482d1803deb9fcb60449e9ca1223018d73 (diff) | |
download | sqlite-278d3faf1ffa6bbd14253865edba3e81631d0cb5.tar.gz sqlite-278d3faf1ffa6bbd14253865edba3e81631d0cb5.zip |
Fiddle: replace db export routine with a C-side one which works for both Emscripten FS-hosted and OPFS-hosted db files. Minor code-adjacent cleanups.
FossilOrigin-Name: 3579a8d6f1f6cd3cd8aad9949536870c5fe7bae8c1778f700dd85d763e266b94
Diffstat (limited to 'ext/wasm/common/whwasmutil.js')
-rw-r--r-- | ext/wasm/common/whwasmutil.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js index fa39ad4b9..662978b20 100644 --- a/ext/wasm/common/whwasmutil.js +++ b/ext/wasm/common/whwasmutil.js @@ -63,7 +63,7 @@ - WASM-exported "indirect function table" access and manipulation. e.g. creating new WASM-side functions using JS functions, analog to Emscripten's addFunction() and - removeFunction() but slightly different. + uninstallFunction() but slightly different. - Get/set specific heap memory values, analog to Emscripten's getValue() and setValue(). @@ -483,9 +483,12 @@ self.WhWasmUtilInstaller = function(target){ available slot of this.functionTable(), and returns the function's index in that table (which acts as a pointer to that function). The returned pointer can be passed to - removeFunction() to uninstall it and free up the table slot for + uninstallFunction() to uninstall it and free up the table slot for reuse. + If passed (string,function) arguments then it treats the first + argument as the signature and second as the function. + As a special case, if the passed-in function is a WASM-exported function then the signature argument is ignored and func is installed as-is, without requiring re-compilation/re-wrapping. @@ -499,12 +502,20 @@ self.WhWasmUtilInstaller = function(target){ Sidebar: this function differs from Emscripten's addFunction() _primarily_ in that it does not share that function's undocumented behavior of reusing a function if it's passed to - addFunction() more than once, which leads to removeFunction() + addFunction() more than once, which leads to uninstallFunction() breaking clients which do not take care to avoid that case: https://github.com/emscripten-core/emscripten/issues/17323 */ target.installFunction = function f(func, sig){ + if(2!==arguments.length){ + toss("installFunction() requires exactly 2 arguments"); + } + if('string'===typeof func && sig instanceof Function){ + const x = sig; + sig = func; + func = x; + } const ft = target.functionTable(); const oldLen = ft.length; let ptr; |