@@ -53,6 +53,7 @@ if (typeof WebAssembly != 'object') {
5353// Wasm globals
5454
5555var wasmMemory ;
56+ var wasmExports ;
5657
5758#if SHARED_MEMORY
5859// For sending to workers.
@@ -468,7 +469,7 @@ function abort(what) {
468469#if WASM_EXCEPTIONS == 1
469470 // See above, in the meantime, we resort to wasm code for trapping.
470471 //
471- // In case abort() is called before the module is initialized, Module['asm']
472+ // In case abort() is called before the module is initialized, wasmExports
472473 // and its exported '__trap' function is not available, in which case we throw
473474 // a RuntimeError.
474475 //
@@ -524,7 +525,7 @@ function createExportWrapper(name, fixedasm) {
524525 var displayName = name ;
525526 var asm = fixedasm ;
526527 if ( ! fixedasm ) {
527- asm = Module [ 'asm' ] ;
528+ asm = wasmExports ;
528529 }
529530 assert ( runtimeInitialized , 'native function `' + displayName + '` called before runtime initialization' ) ;
530531#if EXIT_RUNTIME
@@ -714,7 +715,7 @@ var splitModuleProxyHandler = {
714715 throw new Error ( 'Placeholder function "' + prop + '" should not be called when using JSPI.' ) ;
715716#else
716717 err ( 'placeholder function called: ' + prop ) ;
717- var imports = { 'primary' : Module [ 'asm' ] } ;
718+ var imports = { 'primary' : wasmExports } ;
718719 // Replace '.wasm' suffix with '.deferred.wasm'.
719720 var deferred = wasmBinaryFile . slice ( 0 , - 5 ) + '.deferred.wasm'
720721 loadSplitModule ( deferred , imports , prop ) ;
@@ -979,18 +980,18 @@ function createWasm() {
979980 exports = applySignatureConversions ( exports ) ;
980981#endif
981982
982- Module [ 'asm' ] = exports ;
983+ wasmExports = exports ;
983984
984985#if PTHREADS
985986#if MAIN_MODULE
986- registerTLSInit ( Module [ 'asm' ] [ '_emscripten_tls_init' ] , instance . exports , metadata ) ;
987+ registerTLSInit ( wasmExports [ '_emscripten_tls_init' ] , instance . exports , metadata ) ;
987988#else
988- registerTLSInit ( Module [ 'asm' ] [ '_emscripten_tls_init' ] ) ;
989+ registerTLSInit ( wasmExports [ '_emscripten_tls_init' ] ) ;
989990#endif
990991#endif
991992
992993#if ! IMPORTED_MEMORY
993- wasmMemory = Module [ 'asm' ] [ 'memory' ] ;
994+ wasmMemory = wasmExports [ 'memory' ] ;
994995#if ASSERTIONS
995996 assert ( wasmMemory , "memory not found in wasm exports" ) ;
996997 // This assertion doesn't hold when emscripten is run in --post-link
@@ -1005,7 +1006,7 @@ function createWasm() {
10051006#endif
10061007
10071008#if ! RELOCATABLE
1008- wasmTable = Module [ 'asm' ] [ '__indirect_function_table' ] ;
1009+ wasmTable = wasmExports [ '__indirect_function_table' ] ;
10091010#if ASSERTIONS && ! PURE_WASI
10101011 assert ( wasmTable , "table not found in wasm exports" ) ;
10111012#endif
@@ -1019,11 +1020,11 @@ function createWasm() {
10191020#endif
10201021
10211022#if hasExportedSymbol ( '__wasm_call_ctors' )
1022- addOnInit ( Module [ 'asm' ] [ '__wasm_call_ctors' ] ) ;
1023+ addOnInit ( wasmExports [ '__wasm_call_ctors' ] ) ;
10231024#endif
10241025
10251026#if hasExportedSymbol ( '__wasm_apply_data_relocs' )
1026- __RELOC_FUNCS__ . push ( Module [ 'asm' ] [ '__wasm_apply_data_relocs' ] ) ;
1027+ __RELOC_FUNCS__ . push ( wasmExports [ '__wasm_apply_data_relocs' ] ) ;
10271028#endif
10281029
10291030#if ABORT_ON_WASM_EXCEPTIONS
0 commit comments