@@ -1966,41 +1966,38 @@ addToLibrary({
19661966 $setWasmTableEntry__internal : true ,
19671967 $setWasmTableEntry__deps : [ '$wasmTableMirror' , '$wasmTable' ] ,
19681968 $setWasmTableEntry : ( idx , func ) => {
1969- wasmTable . set ( idx , func ) ;
1969+ wasmTable . set ( { { { toIndexType ( ' idx' ) } } } , func ) ;
19701970 // With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overridden to return wrapped
19711971 // functions so we need to call it here to retrieve the potential wrapper correctly
19721972 // instead of just storing 'func' directly into wasmTableMirror
1973- wasmTableMirror [ idx ] = wasmTable . get ( idx ) ;
1973+ wasmTableMirror [ idx ] = wasmTable . get ( { { { toIndexType ( ' idx' ) } } } ) ;
19741974 } ,
19751975
19761976 $getWasmTableEntry__internal : true ,
19771977 $getWasmTableEntry__deps : [ '$wasmTableMirror' , '$wasmTable' ] ,
19781978 $getWasmTableEntry : ( funcPtr ) => {
1979- #if MEMORY64
1980- // Function pointers are 64-bit, but wasmTable.get() requires a Number.
1981- // https://github.com/emscripten-core/emscripten/issues/18200
1982- funcPtr = Number ( funcPtr ) ;
1983- #endif
1979+ // Pointers are expected to be JS numbers, even under wasm64
1980+ assert ( typeof funcPtr == 'number' ) ;
19841981 var func = wasmTableMirror [ funcPtr ] ;
19851982 if ( ! func ) {
19861983 if ( funcPtr >= wasmTableMirror . length ) wasmTableMirror . length = funcPtr + 1 ;
1987- wasmTableMirror [ funcPtr ] = func = wasmTable . get ( funcPtr ) ;
1984+ wasmTableMirror [ funcPtr ] = func = wasmTable . get ( { { { toIndexType ( ' funcPtr' ) } } } ) ;
19881985#if ASYNCIFY == 2
19891986 if ( Asyncify . isAsyncExport ( func ) ) {
19901987 wasmTableMirror [ funcPtr ] = func = Asyncify . makeAsyncFunction ( func ) ;
19911988 }
19921989#endif
19931990 }
19941991#if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper.
1995- assert ( wasmTable . get ( funcPtr ) == func , 'JavaScript-side Wasm function table mirror is out of date!' ) ;
1992+ assert ( wasmTable . get ( { { { toIndexType ( ' funcPtr' ) } } } ) == func , 'JavaScript-side Wasm function table mirror is out of date!' ) ;
19961993#endif
19971994 return func ;
19981995 } ,
19991996
20001997#else
20011998
20021999 $setWasmTableEntry__deps : [ '$wasmTable' ] ,
2003- $setWasmTableEntry : ( idx , func ) => wasmTable . set ( idx , func ) ,
2000+ $setWasmTableEntry : ( idx , func ) = > wasmTable . set ( { { { toIndexType ( ' idx' ) } } } , func ) ,
20042001
20052002 $getWasmTableEntry__deps : [ '$wasmTable' ] ,
20062003 $getWasmTableEntry : ( funcPtr ) => {
@@ -2391,9 +2388,9 @@ addToLibrary({
23912388#if RELOCATABLE
23922389 // In RELOCATABLE mode we create the table in JS.
23932390 $wasmTable : `=new WebAssembly.Table({
2394- 'initial': {{{ INITIAL_TABLE }}},
2391+ 'initial': {{{ toIndexType( INITIAL_TABLE) }}},
23952392#if !ALLOW_TABLE_GROWTH
2396- 'maximum': {{{ INITIAL_TABLE }}},
2393+ 'maximum': {{{ toIndexType( INITIAL_TABLE) }}},
23972394#endif
23982395#if MEMORY64 == 1
23992396 'index': 'i64',
0 commit comments