Skip to content

Commit

Permalink
fixed wasm syscall/js.finalizeRef use <tinygo-org/tinygo#1140>
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Aug 19, 2023
1 parent 3e6d0fd commit d0da919
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmds/mcla_wasm/wasm_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,17 @@
},

// func finalizeRef(v ref)
"syscall/js.finalizeRef": (sp) => {
// Note: TinyGo does not support finalizers so this should never be
// called.
console.error('syscall/js.finalizeRef not implemented');
"syscall/js.finalizeRef": (v_addr) => {
// Note: TinyGo does not support finalizers so this is only called
// for one specific case, by js.go:jsString.
const id = mem().getUint32(v_addr, true);
this._goRefCounts[id]--;
if (this._goRefCounts[id] === 0) {
const v = this._values[id];
this._values[id] = null;
this._ids.delete(v);
this._idPool.push(id);
}
},

// func stringVal(value string) ref
Expand Down

0 comments on commit d0da919

Please sign in to comment.