@@ -194,7 +194,7 @@ mergeInto(LibraryManager.library, {
194194 emscripten_resize_heap : 'ip' ,
195195 emscripten_resize_heap : function ( requestedSize ) {
196196 var oldSize = HEAPU8 . length ;
197- requestedSize = requestedSize >>> 0 ;
197+ { { { convertPtrToIdx ( ' requestedSize' ) } } } ;
198198#if ALLOW_MEMORY_GROWTH == 0
199199#if ABORTING_MALLOC
200200 abortOnCannotGrowMemory ( requestedSize ) ;
@@ -2577,10 +2577,10 @@ mergeInto(LibraryManager.library, {
25772577
25782578 emscripten_get_callstack__deps : [ '$getCallstack' , '$lengthBytesUTF8' , '$stringToUTF8' ] ,
25792579 emscripten_get_callstack : function ( flags , str , maxbytes ) {
2580- // Use explicit calls to from64 rather then using the __sig
2580+ // Use explicit calls to convertPtrToIdx() rather than using the __sig
25812581 // magic here. This is because the __sig wrapper uses arrow function
25822582 // notation which causes the inner call to traverseStack to fail.
2583- { { { from64 ( 'str' ) } } } ;
2583+ { { { convertPtrToIdx ( 'str' ) } } } ;
25842584 var callstack = getCallstack ( flags ) ;
25852585 // User can query the required amount of bytes to hold the callstack.
25862586 if ( ! str || maxbytes <= 0 ) {
@@ -3128,7 +3128,7 @@ mergeInto(LibraryManager.library, {
31283128 // Used by wasm-emscripten-finalize to implement STACK_OVERFLOW_CHECK
31293129 __handle_stack_overflow__deps : [ 'emscripten_stack_get_base' , 'emscripten_stack_get_end' , '$ptrToString' ] ,
31303130 __handle_stack_overflow : function ( requested ) {
3131- requested = requested >>> 0 ;
3131+ { { { convertPtrToIdx ( ' requested' ) } } } ;
31323132 var base = _emscripten_stack_get_base ( ) ;
31333133 var end = _emscripten_stack_get_end ( ) ;
31343134 abort ( 'stack overflow (Attempt to set SP to ' + ptrToString ( requested ) +
@@ -3264,6 +3264,7 @@ mergeInto(LibraryManager.library, {
32643264 new_args . push ( arg ) ;
32653265 } ) ;
32663266 args = new_args ;
3267+ if ( sig [ i ] == 'p' ) args [ i ] = BigInt ( args [ i ] ) ;
32673268 }
32683269#endif
32693270 var rtn = getWasmTableEntry ( ptr ) . apply ( null , args ) ;
@@ -3303,11 +3304,9 @@ mergeInto(LibraryManager.library, {
33033304 $getWasmTableEntry__internal : true ,
33043305 $getWasmTableEntry__deps : [ '$wasmTableMirror' ] ,
33053306 $getWasmTableEntry : function ( funcPtr ) {
3306- #if MEMORY64
33073307 // Function pointers are 64-bit, but wasmTable.get() requires a Number.
33083308 // https://github.com/emscripten-core/emscripten/issues/18200
3309- funcPtr = Number ( funcPtr ) ;
3310- #endif
3309+ { { { convertPtrToIdx ( funcPtr ) ;
33113310 var func = wasmTableMirror [ funcPtr ] ;
33123311 if ( ! func ) {
33133312 if ( funcPtr >= wasmTableMirror . length ) wasmTableMirror . length = funcPtr + 1 ;
@@ -3326,11 +3325,9 @@ mergeInto(LibraryManager.library, {
33263325 } ,
33273326
33283327 $getWasmTableEntry : function ( funcPtr ) {
3329- #if MEMORY64
33303328 // Function pointers are 64-bit, but wasmTable.get() requires a Number.
33313329 // https://github.com/emscripten-core/emscripten/issues/18200
3332- funcPtr = Number ( funcPtr ) ;
3333- #endif
3330+ { { { convertPtrToIdx ( funcPtr ) ;
33343331 // In -Os and -Oz builds, do not implement a JS side wasm table mirror for small
33353332 // code size, but directly access wasmTable, which is a bit slower as uncached.
33363333 return wasmTable . get ( funcPtr ) ;
@@ -3605,11 +3602,11 @@ mergeInto(LibraryManager.library, {
36053602#if RELOCATABLE
36063603 // Globals that are normally exported from the wasm module but in relocatable
36073604 // mode are created here and imported by the module.
3608- __stack_pointer: "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}, {{{ to64 (STACK_HIGH) }}})" ,
3605+ __stack_pointer: "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}, {{{ idxToPtr (STACK_HIGH) }}})" ,
36093606 // tell the memory segments where to place themselves
3610- __memory_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ to64 (GLOBAL_BASE) }}})" ,
3607+ __memory_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ idxToPtr (GLOBAL_BASE) }}})" ,
36113608 // the wasm backend reserves slot 0 for the NULL function pointer
3612- __table_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ to64 (1) }}})" ,
3609+ __table_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ idxToPtr (1) }}})" ,
36133610#if MEMORY64 == 2
36143611 __memory_base32: "new WebAssembly.Global({'value': 'i32', 'mutable': false}, {{{ GLOBAL_BASE }}})" ,
36153612#endif
0 commit comments