Skip to content
Snippets Groups Projects
Commit f92ba74f 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 6888c9c4
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ export async function postLink(mod) { ...@@ -62,7 +62,7 @@ export async function postLink(mod) {
// Keep this in sync with dyld.mjs! // Keep this in sync with dyld.mjs!
src = `${src}\nexport default (__exports) => {`; src = `${src}\nexport default (__exports) => {`;
src = `${src}\nconst __ghc_wasm_jsffi_jsval_manager = new JSValManager();`; 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}\nreturn {`;
src = `${src}\nnewJSVal: (v) => __ghc_wasm_jsffi_jsval_manager.newJSVal(v),`; src = `${src}\nnewJSVal: (v) => __ghc_wasm_jsffi_jsval_manager.newJSVal(v),`;
src = `${src}\ngetJSVal: (k) => __ghc_wasm_jsffi_jsval_manager.getJSVal(k),`; 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