Skip to content

Commit

Permalink
Replace Module.asm with Module.wasmExports
Browse files Browse the repository at this point in the history
Module.asm was removed, use wasmExports instead.
Context: emscripten-core/emscripten#19816
  • Loading branch information
radekdoulik committed Mar 27, 2024
1 parent e52f7df commit a91ec44
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/mono/browser/browser.proj
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
</ItemGroup>
<!-- for the jiterpreter -->
<ItemGroup>
<EmccExportedRuntimeMethod Include="wasmExports" />

<EmccExportedFunction Include="_fmod" />
<EmccExportedFunction Include="_atan2" />
<EmccExportedFunction Include="_fma" />
Expand Down Expand Up @@ -286,7 +288,7 @@
<_EmccLinkFlags Include="--source-map-base http://example.com" />
<_EmccLinkFlags Include="-s WASM_BIGINT=1" />
<_EmccLinkFlags Include="-s EXPORT_NAME=&quot;'createDotnetRuntime'&quot;" />
<_EmccLinkFlags Include="-s MODULARIZE=1"/>
<_EmccLinkFlags Include="-s MODULARIZE=1" />

<_EmccLinkFlags Include="-s ENVIRONMENT=&quot;web,webview,worker,node,shell&quot;" />
<!-- remove -Wno-limited-postlink-optimizations once below issue is fixed
Expand Down
6 changes: 3 additions & 3 deletions src/mono/browser/runtime/cwraps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ function cwrap(name: string, returnType: string | null, argTypes: string[] | und
// Only attempt to do fast calls if all the args and the return type are either number or void
(fastCwrapTypes.indexOf(returnType) >= 0) &&
(!argTypes || argTypes.every(atype => fastCwrapTypes.indexOf(atype) >= 0)) &&
// Module["asm"] may not be defined yet if we are early enough in the startup process
// Module["wasmExports"] may not be defined yet if we are early enough in the startup process
// in that case, we need to rely on emscripten's lazy wrappers
Module["asm"]
? <Function>((<any>Module["asm"])[name])
Module["wasmExports"]
? <Function>((<any>Module["wasmExports"])[name])
: undefined;

// If the argument count for the wasm function doesn't match the signature, fall back to cwrap
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/jiterpreter-jit-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function mono_interp_invoke_wasm_jit_call_trampoline(
thunk(ret_sp, sp, ftndesc, thrown);
} catch (exc: any) {
receiveWorkerHeapViews();
const exceptionTag = (<any>Module)["asm"]["__cpp_exception"];
const exceptionTag = (<any>Module)["wasmExports"]["__cpp_exception"];
const haveTag = exceptionTag instanceof (<any>WebAssembly).Tag;
if (
!haveTag || (
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/jiterpreter-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class WasmBuilder {
}

getExceptionTag(): any {
const exceptionTag = (<any>Module)["asm"]["__cpp_exception"];
const exceptionTag = (<any>Module)["wasmExports"]["__cpp_exception"];
if (typeof (exceptionTag) !== "undefined")
mono_assert(exceptionTag instanceof (<any>WebAssembly).Tag, () => `expected __cpp_exception export from dotnet.wasm to be WebAssembly.Tag but was ${exceptionTag}`);
return exceptionTag;
Expand Down Expand Up @@ -1833,7 +1833,7 @@ export function getMemberOffset(member: JiterpMember) {
}

export function getRawCwrap(name: string): Function {
const result = (<any>Module)["asm"][name];
const result = (<any>Module)["wasmExports"][name];
if (typeof (result) !== "function")
throw new Error(`raw cwrap ${name} not found`);
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export declare interface EmscriptenModuleInternal {
FS: any;
wasmModule: WebAssembly.Instance | null;
ready: Promise<unknown>;
asm: any;
wasmExports: any;
getWasmTableEntry(index: number): any;
removeRunDependency(id: string): void;
addRunDependency(id: string): void;
Expand Down

0 comments on commit a91ec44

Please sign in to comment.