aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/common/whwasmutil.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-08-04 08:41:55 +0000
committerstephan <stephan@noemail.net>2023-08-04 08:41:55 +0000
commit444424dab8c5fff24256ab32f0279e3e0b841961 (patch)
tree51dfffa679e6f8087a2b1481228f62f235de1d64 /ext/wasm/common/whwasmutil.js
parent1050f1d2a1b1e5fc55107e262af1ab0a748b26f1 (diff)
downloadsqlite-444424dab8c5fff24256ab32f0279e3e0b841961.tar.gz
sqlite-444424dab8c5fff24256ab32f0279e3e0b841961.zip
Part 2 of the fix from [a0f808363318c00fd1db78b].
FossilOrigin-Name: 5c3104228d75c8fafbe24e46623777f3a8647f1b50267af61d46f7fad0e0434e
Diffstat (limited to 'ext/wasm/common/whwasmutil.js')
-rw-r--r--ext/wasm/common/whwasmutil.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/wasm/common/whwasmutil.js b/ext/wasm/common/whwasmutil.js
index ee7ea20c3..4a6934f71 100644
--- a/ext/wasm/common/whwasmutil.js
+++ b/ext/wasm/common/whwasmutil.js
@@ -1180,7 +1180,7 @@ globalThis.WhWasmUtilInstaller = function(target){
cache.scopedAlloc.splice(n,1);
for(let p; (p = state.pop()); ){
if(target.functionEntry(p)){
- //console.warn("scopedAllocPop() uninstalling transient function",p);
+ //console.warn("scopedAllocPop() uninstalling function",p);
target.uninstallFunction(p);
}
else target.dealloc(p);
@@ -1637,6 +1637,7 @@ globalThis.WhWasmUtilInstaller = function(target){
'and is not intended to be invoked from',
'client-level code. Invoked with:',opt);
}
+ this.name = opt.name || "unnamed";
this.signature = opt.signature;
if(opt.contextKey instanceof Function){
this.contextKey = opt.contextKey;
@@ -1698,14 +1699,16 @@ globalThis.WhWasmUtilInstaller = function(target){
exactly the 2nd and 3rd arguments are.
*/
convertArg(v,argv,argIndex){
- //FuncPtrAdapter.debugOut("FuncPtrAdapter.convertArg()",this.signature,this.transient,v);
+ //FuncPtrAdapter.debugOut("FuncPtrAdapter.convertArg()",this.name,this.signature,this.transient,v);
let pair = this.singleton;
if(!pair && this.isContext){
pair = this.contextMap(this.contextKey(argv,argIndex));
+ //FuncPtrAdapter.debugOut(this.name, this.signature, "contextKey() =",this.contextKey(argv,argIndex), pair);
}
if(pair && pair[0]===v) return pair[1];
if(v instanceof Function){
/* Install a WASM binding and return its pointer. */
+ //FuncPtrAdapter.debugOut("FuncPtrAdapter.convertArg()",this.name,this.signature,this.transient,v,pair);
if(this.callProxy) v = this.callProxy(v);
const fp = __installFunction(v, this.signature, this.isTransient);
if(FuncPtrAdapter.debugFuncInstall){
@@ -1727,13 +1730,14 @@ globalThis.WhWasmUtilInstaller = function(target){
}
return fp;
}else if(target.isPtr(v) || null===v || undefined===v){
+ //FuncPtrAdapter.debugOut("FuncPtrAdapter.convertArg()",this.name,this.signature,this.transient,v,pair);
if(pair && pair[1] && pair[1]!==v){
/* uninstall stashed mapping and replace stashed mapping with v. */
if(FuncPtrAdapter.debugFuncInstall){
FuncPtrAdapter.debugOut("FuncPtrAdapter uninstalling", this,
this.contextKey(argv,argIndex), '@'+pair[1], v);
}
- try{target.uninstallFunction(pair[1])}
+ try{ cache.scopedAlloc[cache.scopedAlloc.length-1].push(pair[1]) }
catch(e){/*ignored*/}
pair[0] = pair[1] = (v | 0);
}