From fac7b4a23e534a36d8ce94807089302459f00d09 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 27 Sep 2023 01:02:14 -0400 Subject: [PATCH 1/3] [wasm] Define getWasmIndirectFunctionTable before intializing the .. runtime also, so it is available at that time. --- src/mono/wasm/runtime/es6/dotnet.es6.pre.js | 4 +++- src/mono/wasm/runtime/types/internal.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/runtime/es6/dotnet.es6.pre.js b/src/mono/wasm/runtime/es6/dotnet.es6.pre.js index 490935d5ca028..2a5165fbe56bd 100644 --- a/src/mono/wasm/runtime/es6/dotnet.es6.pre.js +++ b/src/mono/wasm/runtime/es6/dotnet.es6.pre.js @@ -1,5 +1,7 @@ if (_nativeModuleLoaded) throw new Error("Native module already loaded"); _nativeModuleLoaded = true; -createDotnetRuntime = Module = createDotnetRuntime(Module); +Module["getMemory"] = function () { return wasmMemory; } Module["getWasmIndirectFunctionTable"] = function () { return wasmTable; } +createDotnetRuntime = Module = createDotnetRuntime(Module); Module["getMemory"] = function () { return wasmMemory; } +Module["getWasmIndirectFunctionTable"] = function () { return wasmTable; } diff --git a/src/mono/wasm/runtime/types/internal.ts b/src/mono/wasm/runtime/types/internal.ts index a91b21973c8d5..7a6b861a4a18f 100644 --- a/src/mono/wasm/runtime/types/internal.ts +++ b/src/mono/wasm/runtime/types/internal.ts @@ -454,7 +454,7 @@ export declare interface EmscriptenModuleInternal { ready: Promise; asm: { memory?: WebAssembly.Memory }; wasmMemory?: WebAssembly.Memory; - getWasmIndirectFunctionTable: any; + getWasmIndirectFunctionTable(): any; getMemory: WebAssembly.Memory; getWasmTableEntry(index: number): any; removeRunDependency(id: string): void; @@ -508,4 +508,4 @@ export type RuntimeModuleExportsInternal = { export type NativeModuleExportsInternal = { default: (unificator: Function) => EmscriptenModuleInternal -} \ No newline at end of file +} From 4975dc35664e4f3b11a91a689d65b3b3564b915d Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 27 Sep 2023 16:40:15 -0400 Subject: [PATCH 2/3] address review feedback --- src/mono/wasm/runtime/es6/dotnet.es6.pre.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/wasm/runtime/es6/dotnet.es6.pre.js b/src/mono/wasm/runtime/es6/dotnet.es6.pre.js index 2a5165fbe56bd..5cb5091dc16b1 100644 --- a/src/mono/wasm/runtime/es6/dotnet.es6.pre.js +++ b/src/mono/wasm/runtime/es6/dotnet.es6.pre.js @@ -4,4 +4,3 @@ Module["getMemory"] = function () { return wasmMemory; } Module["getWasmIndirectFunctionTable"] = function () { return wasmTable; } createDotnetRuntime = Module = createDotnetRuntime(Module); Module["getMemory"] = function () { return wasmMemory; } -Module["getWasmIndirectFunctionTable"] = function () { return wasmTable; } From 249d8b6f66ab44e6892d3bac0e43d3a0084c1929 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 27 Sep 2023 18:13:35 -0400 Subject: [PATCH 3/3] Revert "address review feedback" This reverts commit 4975dc35664e4f3b11a91a689d65b3b3564b915d. This caused library aot tests to fail with: ``` info: MONO_WASM: mono_wasm_load_runtime () failed TypeError: t.getWasmIndirectFunctionTable is not a function info: MONO_WASM: TypeError: t.getWasmIndirectFunctionTable is not a function info: at Ma (/root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.runtime.js:3:80285) info: at Ul (/root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.runtime.js:3:174663) info: at do_jit_call (do_jit_call (wasm://wasm/0dec238a:wasm-function[90022]:0x16bba99)) info: at mono_interp_exec_method (mono_interp_exec_method (wasm://wasm/0dec238a:wasm-function[90012]:0x16af791)) info: at interp_runtime_invoke (interp_runtime_invoke (wasm://wasm/0dec238a:wasm-function[90052]:0x16bc9da)) info: at mono_jit_runtime_invoke (mono_jit_runtime_invoke (wasm://wasm/0dec238a:wasm-function[95289]:0x17c5028)) info: at do_runtime_invoke (do_runtime_invoke (wasm://wasm/0dec238a:wasm-function[94085]:0x178e3d3)) info: at mono_runtime_invoke_checked (mono_runtime_invoke_checked (wasm://wasm/0dec238a:wasm-function[94084]:0x178e38f)) info: at mono_runtime_install_appctx_properties (mono_runtime_install_appctx_properties (wasm://wasm/0dec238a:wasm-function[91526]:0x17054e4)) info: at mono_runtime_init_checked (mono_runtime_init_checked (wasm://wasm/0dec238a:wasm-function[91521]:0x1704d4e)) info: at mini_init (mini_init (wasm://wasm/0dec238a:wasm-function[95272]:0x17c43ea)) info: at mono_jit_init_version (mono_jit_init_version (wasm://wasm/0dec238a:wasm-function[95408]:0x17ca553)) info: at mono_wasm_load_runtime (mono_wasm_load_runtime (wasm://wasm/0dec238a:wasm-function[103299]:0x1900987)) info: at Module._mono_wasm_load_runtime (/root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.native.js:6817:114) info: at ccall (/root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.native.js:5851:22) info: at Object.mono_wasm_load_runtime (/root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.native.js:5877:16) info: at Dl (/root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.runtime.js:3:215804) info: at /root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.runtime.js:3:205340 info: at /root/helix/work/workitem/e/wasm_build/AppBundle/_framework/dotnet.runtime.js:3:206020 ``` --- src/mono/wasm/runtime/es6/dotnet.es6.pre.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/wasm/runtime/es6/dotnet.es6.pre.js b/src/mono/wasm/runtime/es6/dotnet.es6.pre.js index 5cb5091dc16b1..2a5165fbe56bd 100644 --- a/src/mono/wasm/runtime/es6/dotnet.es6.pre.js +++ b/src/mono/wasm/runtime/es6/dotnet.es6.pre.js @@ -4,3 +4,4 @@ Module["getMemory"] = function () { return wasmMemory; } Module["getWasmIndirectFunctionTable"] = function () { return wasmTable; } createDotnetRuntime = Module = createDotnetRuntime(Module); Module["getMemory"] = function () { return wasmMemory; } +Module["getWasmIndirectFunctionTable"] = function () { return wasmTable; }