@@ -88,8 +88,15 @@ mergeInto(LibraryManager.library, {
8888#endif
8989
9090 // Returns a pointer ('p'), which means an i32 on wasm32 and an i64 wasm64
91+ // We have a separate JS version `getHeapMax()` which can be called directly
92+ // avoiding any wrapper added for wasm64.
9193 emscripten_get_heap_max__sig : 'p' ,
94+ emscripten_get_heap_max__deps : [ '$getHeapMax' ] ,
9295 emscripten_get_heap_max : function ( ) {
96+ return getHeapMax ( ) ;
97+ } ,
98+
99+ $getHeapMax : function ( ) {
93100#if ALLOW_MEMORY_GROWTH
94101 // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
95102 // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
@@ -147,8 +154,9 @@ mergeInto(LibraryManager.library, {
147154 } ,
148155#endif // ~TEST_MEMORY_GROWTH_FAILS
149156
157+ emscripten_resize_heap__sig : 'ip' ,
150158 emscripten_resize_heap__deps : [
151- 'emscripten_get_heap_max ' ,
159+ '$getHeapMax ' ,
152160#if ASSERTIONS == 2
153161 'emscripten_get_now' ,
154162#endif
@@ -203,7 +211,7 @@ mergeInto(LibraryManager.library, {
203211
204212 // A limit is set for how much we can grow. We should not exceed that
205213 // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
206- var maxHeapSize = _emscripten_get_heap_max ( ) ;
214+ var maxHeapSize = getHeapMax ( ) ;
207215 if ( requestedSize > maxHeapSize ) {
208216#if ASSERTIONS
209217 err ( 'Cannot enlarge memory, asked to go up to ' + requestedSize + ' bytes, but the limit is ' + maxHeapSize + ' bytes!' ) ;
@@ -342,6 +350,7 @@ mergeInto(LibraryManager.library, {
342350 // the initial values of the environment accessible by getenv.
343351 $ENV : { } ,
344352
353+ getloadavg__sig : 'ipi ',
345354 getloadavg : function ( loadavg , nelem ) {
346355 // int getloadavg(double loadavg[], int nelem);
347356 // http://linux.die.net/man/3/getloadavg
@@ -389,7 +398,7 @@ mergeInto(LibraryManager.library, {
389398 // assert.h
390399 // ==========================================================================
391400
392- __assert_fail__sig : 'viiii ' ,
401+ __assert_fail__sig : 'vppip ' ,
393402 __assert_fail : function ( condition , filename , line , func ) {
394403 abort ( 'Assertion failed: ' + UTF8ToString ( condition ) + ', at: ' + [ filename ? UTF8ToString ( filename ) : 'unknown filename' , line , func ? UTF8ToString ( func ) : 'unknown function' ] ) ;
395404 } ,
@@ -403,7 +412,7 @@ mergeInto(LibraryManager.library, {
403412 return Date . now ( ) ;
404413 } ,
405414
406- _mktime_js__sig : 'ii ',
415+ _mktime_js__sig : 'ip ',
407416 _mktime_js : function ( tmPtr ) {
408417 var date = new Date ( { { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_year , 'i32' ) } } } + 1900 ,
409418 { { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_mon , 'i32' ) } } } ,
@@ -503,7 +512,7 @@ mergeInto(LibraryManager.library, {
503512 } ,
504513
505514 // musl-internal function used to implement both `asctime` and `asctime_r`
506- __asctime_r__sig : 'iii ',
515+ __asctime_r__sig : 'ppp ',
507516 __asctime_r : function ( tmPtr , buf ) {
508517 var date = {
509518 tm_sec : { { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_sec , 'i32' ) } } } ,
@@ -953,6 +962,7 @@ mergeInto(LibraryManager.library, {
953962 , '$intArrayFromString'
954963#endif
955964 ] ,
965+ strptime__sig : 'pppp' ,
956966 strptime : function ( buf , format , tm ) {
957967 // char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
958968 // http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
@@ -1193,6 +1203,7 @@ mergeInto(LibraryManager.library, {
11931203
11941204 return 0 ;
11951205 } ,
1206+ strptime_l__sig : 'pppp ',
11961207 strptime_l__deps : [ 'strptime' ] ,
11971208 strptime_l : function ( buf , format , tm ) {
11981209 return _strptime ( buf , format , tm ) ; // no locale support yet
@@ -2217,6 +2228,7 @@ mergeInto(LibraryManager.library, {
22172228 } ,
22182229
22192230 getentropy__deps : [ '$getRandomDevice' ] ,
2231+ getentropy__sig : 'ipp' ,
22202232 getentropy : function ( buffer , size ) {
22212233 if ( ! _getentropy . randomDevice ) {
22222234 _getentropy . randomDevice = getRandomDevice ( ) ;
@@ -2248,12 +2260,12 @@ mergeInto(LibraryManager.library, {
22482260 // emscripten.h
22492261 // ==========================================================================
22502262
2251- emscripten_run_script__sig : 'vi ' ,
2263+ emscripten_run_script__sig : 'vp ' ,
22522264 emscripten_run_script : function ( ptr ) {
22532265 { { { makeEval ( 'eval(UTF8ToString(ptr));' ) } } }
22542266 } ,
22552267
2256- emscripten_run_script_int__sig : 'ii ' ,
2268+ emscripten_run_script_int__sig : 'ip ' ,
22572269 emscripten_run_script_int__docs : '/** @suppress{checkTypes} */' ,
22582270 emscripten_run_script_int : function ( ptr ) {
22592271 { { { makeEval ( 'return eval(UTF8ToString(ptr))|0;' ) } } }
@@ -2262,7 +2274,7 @@ mergeInto(LibraryManager.library, {
22622274 // We use builtin_malloc and builtin_free here because otherwise lsan will
22632275 // report the last returned string as a leak.
22642276 emscripten_run_script_string__deps : [ 'emscripten_builtin_malloc' , 'emscripten_builtin_free' ] ,
2265- emscripten_run_script_string__sig : 'ii ' ,
2277+ emscripten_run_script_string__sig : 'pp ' ,
22662278 emscripten_run_script_string : function ( ptr ) {
22672279 { { { makeEval ( "var s = eval(UTF8ToString(ptr));" ) } } }
22682280 if ( s == null ) {
@@ -2524,6 +2536,10 @@ mergeInto(LibraryManager.library, {
25242536
25252537 emscripten_get_callstack__deps : [ 'emscripten_get_callstack_js' ] ,
25262538 emscripten_get_callstack : function ( flags , str , maxbytes ) {
2539+ // Use explict calls to from64 rather then using the __sig
2540+ // magic here. This is because the __sig wrapper uses arrow function
2541+ // notation which causes the inner call to traverseStack to fail.
2542+ { { { from64 ( 'str' ) } } } ;
25272543 var callstack = _emscripten_get_callstack_js ( flags ) ;
25282544 // User can query the required amount of bytes to hold the callstack.
25292545 if ( ! str || maxbytes <= 0 ) {
@@ -2562,6 +2578,7 @@ mergeInto(LibraryManager.library, {
25622578 }
25632579 } ,
25642580
2581+ emscripten_log__sig : 'vipp ',
25652582 emscripten_log__deps : [ '$formatString' , 'emscripten_log_js' ] ,
25662583 emscripten_log : function ( flags , format , varargs ) {
25672584 var result = formatString ( format , varargs ) ;
@@ -2600,6 +2617,7 @@ mergeInto(LibraryManager.library, {
26002617 debugger ;
26012618 } ,
26022619
2620+ emscripten_print_double__sig : 'iipi' ,
26032621 emscripten_print_double : function ( x , to , max ) {
26042622 var str = x + '' ;
26052623 if ( to ) return stringToUTF8 ( str , to , max ) ;
@@ -2642,14 +2660,22 @@ mergeInto(LibraryManager.library, {
26422660 // Returns a representation of a call site of the caller of this function, in a manner
26432661 // similar to __builtin_return_address. If level is 0, we return the call site of the
26442662 // caller of this function.
2663+ emscripten_return_address__sig : 'pi' ,
26452664 emscripten_return_address__deps : [ '$convertFrameToPC' , '$jsStackTrace' ] ,
26462665 emscripten_return_address : function ( level ) {
26472666 var callstack = jsStackTrace ( ) . split ( '\n' ) ;
26482667 if ( callstack [ 0 ] == 'Error' ) {
26492668 callstack . shift ( ) ;
26502669 }
26512670 // skip this function and the caller to get caller's return address
2652- return convertFrameToPC ( callstack [ level + 3 ] ) ;
2671+ #if MEMORY64
2672+ // MEMORY64 injects and extra wrapper within emscripten_return_address
2673+ // to handle BitInt convertions.
2674+ var caller = callstack [ level + 4 ] ;
2675+ #else
2676+ var caller = callstack [ level + 3 ] ;
2677+ #endif
2678+ return convertFrameToPC ( caller ) ;
26532679 } ,
26542680
26552681 $UNWIND_CACHE : { } ,
@@ -2692,6 +2718,7 @@ mergeInto(LibraryManager.library, {
26922718 // must be able to unwind from a PC value that may no longer be on the
26932719 // execution stack, and so we are forced to cache the entire call stack.
26942720 emscripten_stack_snapshot__deps : [ '$convertFrameToPC' , '$UNWIND_CACHE' , '$saveInUnwindCache' , '$jsStackTrace' ] ,
2721+ emscripten_stack_snapshot__sig : 'p' ,
26952722 emscripten_stack_snapshot : function ( ) {
26962723 var callstack = jsStackTrace ( ) . split ( '\n' ) ;
26972724 if ( callstack [ 0 ] == 'Error' ) {
@@ -2722,6 +2749,7 @@ mergeInto(LibraryManager.library, {
27222749 // emscripten_stack_snapshot, or this function will instead use the current
27232750 // call stack.
27242751 emscripten_stack_unwind_buffer__deps : [ '$UNWIND_CACHE' , '$saveInUnwindCache' , '$convertFrameToPC' , '$jsStackTrace' ] ,
2752+ emscripten_stack_unwind_buffer__sig : 'ippi' ,
27252753 emscripten_stack_unwind_buffer : function ( addr , buffer , count ) {
27262754 var stack ;
27272755 if ( UNWIND_CACHE . last_addr == addr ) {
@@ -2756,6 +2784,7 @@ mergeInto(LibraryManager.library, {
27562784 ] ,
27572785 // Don't treat allocation of _emscripten_pc_get_function.ret as a leak
27582786 emscripten_pc_get_function__noleakcheck : true ,
2787+ emscripten_pc_get_function__sig : 'pp' ,
27592788#endif
27602789 emscripten_pc_get_function : function ( pc ) {
27612790#if ! USE_OFFSET_CONVERTER
@@ -2820,6 +2849,7 @@ mergeInto(LibraryManager.library, {
28202849 ] ,
28212850 // Don't treat allocation of _emscripten_pc_get_file.ret as a leak
28222851 emscripten_pc_get_file__noleakcheck : true ,
2852+ emscripten_pc_get_file__sig : 'pp' ,
28232853 emscripten_pc_get_file : function ( pc ) {
28242854 var result = convertPCtoSourceLocation ( pc ) ;
28252855 if ( ! result ) return 0 ;
@@ -2831,13 +2861,15 @@ mergeInto(LibraryManager.library, {
28312861
28322862 // Look up the line number from our stack frame cache with our PC representation.
28332863 emscripten_pc_get_line__deps : [ '$convertPCtoSourceLocation' ] ,
2864+ emscripten_pc_get_line__sig : 'pp' ,
28342865 emscripten_pc_get_line : function ( pc ) {
28352866 var result = convertPCtoSourceLocation ( pc ) ;
28362867 return result ? result . line : 0 ;
28372868 } ,
28382869
28392870 // Look up the column number from our stack frame cache with our PC representation.
28402871 emscripten_pc_get_column__deps : [ '$convertPCtoSourceLocation' ] ,
2872+ emscripten_pc_get_column__sig : 'pp' ,
28412873 emscripten_pc_get_column : function ( pc ) {
28422874 var result = convertPCtoSourceLocation ( pc ) ;
28432875 return result ? result . column || 0 : 0 ;
@@ -3095,6 +3127,7 @@ mergeInto(LibraryManager.library, {
30953127
30963128#if STACK_OVERFLOW_CHECK
30973129 // Used by wasm-emscripten-finalize to implement STACK_OVERFLOW_CHECK
3130+ __handle_stack_overflow__sig : 'vp' ,
30983131 __handle_stack_overflow__deps : [ 'emscripten_stack_get_base' ] ,
30993132 __handle_stack_overflow : function ( requested ) {
31003133 requested = requested >>> 0 ;
0 commit comments