mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
fix: correctly handle id lookup for finalizeRef call
Modify the ID used for looking up the reference, based on suggestion made by @prochac Also use console.error in the caase that the reference is not found, since it is now actually known to be an error.
This commit is contained in:
@@ -305,8 +305,7 @@
|
|||||||
"syscall/js.finalizeRef": (v_ref) => {
|
"syscall/js.finalizeRef": (v_ref) => {
|
||||||
// Note: TinyGo does not support finalizers so this is only called
|
// Note: TinyGo does not support finalizers so this is only called
|
||||||
// for one specific case, by js.go:jsString. and can/might leak memory.
|
// for one specific case, by js.go:jsString. and can/might leak memory.
|
||||||
const id = mem().getUint32(unboxValue(v_ref), true);
|
const id = v_ref & 0xffffffffn;
|
||||||
// Note that this if is so far seemingly never true. Someone should investigate why.
|
|
||||||
if (this._goRefCounts?.[id] !== undefined) {
|
if (this._goRefCounts?.[id] !== undefined) {
|
||||||
this._goRefCounts[id]--;
|
this._goRefCounts[id]--;
|
||||||
if (this._goRefCounts[id] === 0) {
|
if (this._goRefCounts[id] === 0) {
|
||||||
@@ -316,8 +315,7 @@
|
|||||||
this._idPool.push(id);
|
this._idPool.push(id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Log as a hint and reminder that something is probably off.
|
console.error("syscall/js.finalizeRef: unknown id", id);
|
||||||
console.log("syscall/js.finalizeRef: unknown id", id);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user