@@ -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 ) +
@@ -3303,11 +3303,9 @@ mergeInto(LibraryManager.library, {
33033303 $getWasmTableEntry__internal : true ,
33043304 $getWasmTableEntry__deps : [ '$wasmTableMirror' ] ,
33053305 $getWasmTableEntry : function ( funcPtr ) {
3306- #if MEMORY64
33073306 // Function pointers are 64-bit, but wasmTable.get() requires a Number.
33083307 // https://github.com/emscripten-core/emscripten/issues/18200
3309- funcPtr = Number ( funcPtr ) ;
3310- #endif
3308+ { { { convertPtrToIdx ( funcPtr ) ;
33113309 var func = wasmTableMirror [ funcPtr ] ;
33123310 if ( ! func ) {
33133311 if ( funcPtr >= wasmTableMirror . length ) wasmTableMirror . length = funcPtr + 1 ;
@@ -3326,11 +3324,9 @@ mergeInto(LibraryManager.library, {
33263324 } ,
33273325
33283326 $getWasmTableEntry : function ( funcPtr ) {
3329- #if MEMORY64
33303327 // Function pointers are 64-bit, but wasmTable.get() requires a Number.
33313328 // https://github.com/emscripten-core/emscripten/issues/18200
3332- funcPtr = Number ( funcPtr ) ;
3333- #endif
3329+ { { { convertPtrToIdx ( funcPtr ) ;
33343330 // In -Os and -Oz builds, do not implement a JS side wasm table mirror for small
33353331 // code size, but directly access wasmTable, which is a bit slower as uncached.
33363332 return wasmTable . get ( funcPtr ) ;
@@ -3605,11 +3601,11 @@ mergeInto(LibraryManager.library, {
36053601#if RELOCATABLE
36063602 // Globals that are normally exported from the wasm module but in relocatable
36073603 // mode are created here and imported by the module.
3608- __stack_pointer: "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}, {{{ to64 (STACK_HIGH) }}})" ,
3604+ __stack_pointer: "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}, {{{ idxToPtr (STACK_HIGH) }}})" ,
36093605 // tell the memory segments where to place themselves
3610- __memory_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ to64 (GLOBAL_BASE) }}})" ,
3606+ __memory_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ idxToPtr (GLOBAL_BASE) }}})" ,
36113607 // 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) }}})" ,
3608+ __table_base : "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': false}, {{{ idxToPtr (1) }}})" ,
36133609#if MEMORY64 == 2
36143610 __memory_base32: "new WebAssembly.Global({'value': 'i32', 'mutable': false}, {{{ GLOBAL_BASE }}})" ,
36153611#endif
0 commit comments