[browser][MT] conditional revert of wasm imports optimization (#81275)
authorPavel Savara <pavel.savara@gmail.com>
Fri, 27 Jan 2023 21:32:00 +0000 (22:32 +0100)
committerGitHub <noreply@github.com>
Fri, 27 Jan 2023 21:32:00 +0000 (15:32 -0600)
* conditional revert of https://github.com/dotnet/runtime/pull/79466

* feedback

src/mono/wasm/runtime/es6/dotnet.es6.lib.js

index fb184f0..19f877f 100644 (file)
@@ -121,7 +121,12 @@ const linked_functions = [
 // -- this javascript file is evaluated by emcc during compilation! --
 // we generate simple proxy for each exported function so that emcc will include them in the final output
 for (let linked_function of linked_functions) {
-    DotnetSupportLib[linked_function] = new Function("");
+    #if USE_PTHREADS
+    const fn_template = `return __dotnet_runtime.__linker_exports.${linked_function}.apply(__dotnet_runtime, arguments)`;
+    DotnetSupportLib[linked_function] = new Function(fn_template);
+    #else
+    DotnetSupportLib[linked_function] = new Function('throw new Error("unreachable");');
+    #endif
 }
 
 autoAddDeps(DotnetSupportLib, "$DOTNET");