@@ -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.
@@ -471,7 +472,7 @@ function abort(what) {
471472#if WASM_EXCEPTIONS == 1
472473 // See above, in the meantime, we resort to wasm code for trapping.
473474 //
474- // In case abort() is called before the module is initialized, Module['asm']
475+ // In case abort() is called before the module is initialized, wasmExports
475476 // and its exported '__trap' function is not available, in which case we throw
476477 // a RuntimeError.
477478 //
@@ -527,7 +528,7 @@ function createExportWrapper(name) {
527528#if EXIT_RUNTIME
528529 assert ( ! runtimeExited , `native function \`${ name } \` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)` ) ;
529530#endif
530- var f = Module [ 'asm' ] [ name ] ;
531+ var f = wasmExports [ name ] ;
531532 assert ( f , `exported native function \`${ name } \` not found` ) ;
532533 return f . apply ( null , arguments ) ;
533534 } ;
@@ -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,20 @@ function createWasm() {
979980 exports = applySignatureConversions ( exports ) ;
980981#endif
981982
982- Module [ 'asm' ] = exports ;
983+ wasmExports = exports ;
984+ { { { receivedSymbol ( 'wasmExports' ) } } }
983985
984986#if PTHREADS
985987#if MAIN_MODULE
986- registerTLSInit ( Module [ 'asm' ] [ '_emscripten_tls_init' ] , instance . exports , metadata ) ;
988+ registerTLSInit ( wasmExports [ '_emscripten_tls_init' ] , instance . exports , metadata ) ;
987989#else
988- registerTLSInit ( Module [ 'asm' ] [ '_emscripten_tls_init' ] ) ;
990+ registerTLSInit ( wasmExports [ '_emscripten_tls_init' ] ) ;
989991#endif
990992#endif
991993
992994#if ! IMPORTED_MEMORY
993- wasmMemory = Module [ 'asm' ] [ 'memory' ] ;
995+ wasmMemory = wasmExports [ 'memory' ] ;
996+ { { { receivedSymbol ( 'wasmMemory' ) } } }
994997#if ASSERTIONS
995998 assert ( wasmMemory , "memory not found in wasm exports" ) ;
996999 // This assertion doesn't hold when emscripten is run in --post-link
@@ -1005,7 +1008,8 @@ function createWasm() {
10051008#endif
10061009
10071010#if ! RELOCATABLE
1008- wasmTable = Module [ 'asm' ] [ '__indirect_function_table' ] ;
1011+ wasmTable = wasmExports [ '__indirect_function_table' ] ;
1012+ { { { receivedSymbol ( 'wasmTable' ) } } }
10091013#if ASSERTIONS && ! PURE_WASI
10101014 assert ( wasmTable , "table not found in wasm exports" ) ;
10111015#endif
@@ -1019,11 +1023,11 @@ function createWasm() {
10191023#endif
10201024
10211025#if hasExportedSymbol ( '__wasm_call_ctors' )
1022- addOnInit ( Module [ 'asm' ] [ '__wasm_call_ctors' ] ) ;
1026+ addOnInit ( wasmExports [ '__wasm_call_ctors' ] ) ;
10231027#endif
10241028
10251029#if hasExportedSymbol ( '__wasm_apply_data_relocs' )
1026- __RELOC_FUNCS__ . push ( Module [ 'asm' ] [ '__wasm_apply_data_relocs' ] ) ;
1030+ __RELOC_FUNCS__ . push ( wasmExports [ '__wasm_apply_data_relocs' ] ) ;
10271031#endif
10281032
10291033#if ABORT_ON_WASM_EXCEPTIONS
0 commit comments