Skip to content
Snippets Groups Projects
Commit 6437e8f3 authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

wasm: fix FinalizationRegistry logic for Cloudflare Workers

This patch fixes FinalizationRegistry related logic for Cloudflare
Workers in wasm backend js post linker. Cloudflare Workers doesn't
support FinalizationRegistry, in this case we use a dummy
implementation that doesn't do anything.

(cherry picked from commit bea8ea4c)
(cherry picked from commit 0346e7b7)
parent 57735bda
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,7 @@ export async function postLink(mod) {
// Keep this in sync with dyld.mjs!
src = `${src}\nexport default (__exports) => {`;
src = `${src}\nconst __ghc_wasm_jsffi_jsval_manager = new JSValManager();`;
src = `${src}\nconst __ghc_wasm_jsffi_finalization_registry = new FinalizationRegistry(sp => __exports.rts_freeStablePtr(sp));`;
src = `${src}\nconst __ghc_wasm_jsffi_finalization_registry = globalThis.FinalizationRegistry ? new FinalizationRegistry(sp => __exports.rts_freeStablePtr(sp)) : { register: () => {}, unregister: () => true };`;
src = `${src}\nreturn {`;
src = `${src}\nnewJSVal: (v) => __ghc_wasm_jsffi_jsval_manager.newJSVal(v),`;
src = `${src}\ngetJSVal: (k) => __ghc_wasm_jsffi_jsval_manager.getJSVal(k),`;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment