@@ -88,8 +88,15 @@ mergeInto(LibraryManager.library, {
88
88
#endif
89
89
90
90
// 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.
91
93
emscripten_get_heap_max__sig : 'p' ,
94
+ emscripten_get_heap_max__deps : [ '$getHeapMax' ] ,
92
95
emscripten_get_heap_max : function ( ) {
96
+ return getHeapMax ( ) ;
97
+ } ,
98
+
99
+ $getHeapMax : function ( ) {
93
100
#if ALLOW_MEMORY_GROWTH
94
101
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
95
102
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
@@ -147,8 +154,9 @@ mergeInto(LibraryManager.library, {
147
154
} ,
148
155
#endif // ~TEST_MEMORY_GROWTH_FAILS
149
156
157
+ emscripten_resize_heap__sig : 'ip' ,
150
158
emscripten_resize_heap__deps : [
151
- 'emscripten_get_heap_max ' ,
159
+ '$getHeapMax ' ,
152
160
#if ASSERTIONS == 2
153
161
'emscripten_get_now' ,
154
162
#endif
@@ -203,7 +211,7 @@ mergeInto(LibraryManager.library, {
203
211
204
212
// A limit is set for how much we can grow. We should not exceed that
205
213
// (the wasm binary specifies it, so if we tried, we'd fail anyhow).
206
- var maxHeapSize = _emscripten_get_heap_max ( ) ;
214
+ var maxHeapSize = getHeapMax ( ) ;
207
215
if ( requestedSize > maxHeapSize ) {
208
216
#if ASSERTIONS
209
217
err ( 'Cannot enlarge memory, asked to go up to ' + requestedSize + ' bytes, but the limit is ' + maxHeapSize + ' bytes!' ) ;
@@ -342,6 +350,7 @@ mergeInto(LibraryManager.library, {
342
350
// the initial values of the environment accessible by getenv.
343
351
$ENV : { } ,
344
352
353
+ getloadavg__sig : 'ipi ',
345
354
getloadavg : function ( loadavg , nelem ) {
346
355
// int getloadavg(double loadavg[], int nelem);
347
356
// http://linux.die.net/man/3/getloadavg
@@ -389,7 +398,7 @@ mergeInto(LibraryManager.library, {
389
398
// assert.h
390
399
// ==========================================================================
391
400
392
- __assert_fail__sig : 'viiii ' ,
401
+ __assert_fail__sig : 'vppip ' ,
393
402
__assert_fail : function ( condition , filename , line , func ) {
394
403
abort ( 'Assertion failed: ' + UTF8ToString ( condition ) + ', at: ' + [ filename ? UTF8ToString ( filename ) : 'unknown filename' , line , func ? UTF8ToString ( func ) : 'unknown function' ] ) ;
395
404
} ,
@@ -403,7 +412,7 @@ mergeInto(LibraryManager.library, {
403
412
return Date . now ( ) ;
404
413
} ,
405
414
406
- _mktime_js__sig : 'ii ',
415
+ _mktime_js__sig : 'ip ',
407
416
_mktime_js : function ( tmPtr ) {
408
417
var date = new Date ( { { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_year , 'i32' ) } } } + 1900 ,
409
418
{ { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_mon , 'i32' ) } } } ,
@@ -503,7 +512,7 @@ mergeInto(LibraryManager.library, {
503
512
} ,
504
513
505
514
// musl-internal function used to implement both `asctime` and `asctime_r`
506
- __asctime_r__sig : 'iii ',
515
+ __asctime_r__sig : 'ppp ',
507
516
__asctime_r : function ( tmPtr , buf ) {
508
517
var date = {
509
518
tm_sec : { { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_sec , 'i32' ) } } } ,
@@ -953,6 +962,7 @@ mergeInto(LibraryManager.library, {
953
962
, '$intArrayFromString'
954
963
#endif
955
964
] ,
965
+ strptime__sig : 'pppp' ,
956
966
strptime : function ( buf , format , tm ) {
957
967
// char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
958
968
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
@@ -1193,6 +1203,7 @@ mergeInto(LibraryManager.library, {
1193
1203
1194
1204
return 0 ;
1195
1205
} ,
1206
+ strptime_l__sig : 'pppp ',
1196
1207
strptime_l__deps : [ 'strptime' ] ,
1197
1208
strptime_l : function ( buf , format , tm ) {
1198
1209
return _strptime ( buf , format , tm ) ; // no locale support yet
@@ -2217,6 +2228,7 @@ mergeInto(LibraryManager.library, {
2217
2228
} ,
2218
2229
2219
2230
getentropy__deps : [ '$getRandomDevice' ] ,
2231
+ getentropy__sig : 'ipp' ,
2220
2232
getentropy : function ( buffer , size ) {
2221
2233
if ( ! _getentropy . randomDevice ) {
2222
2234
_getentropy . randomDevice = getRandomDevice ( ) ;
@@ -2248,12 +2260,12 @@ mergeInto(LibraryManager.library, {
2248
2260
// emscripten.h
2249
2261
// ==========================================================================
2250
2262
2251
- emscripten_run_script__sig : 'vi ' ,
2263
+ emscripten_run_script__sig : 'vp ' ,
2252
2264
emscripten_run_script : function ( ptr ) {
2253
2265
{ { { makeEval ( 'eval(UTF8ToString(ptr));' ) } } }
2254
2266
} ,
2255
2267
2256
- emscripten_run_script_int__sig : 'ii ' ,
2268
+ emscripten_run_script_int__sig : 'ip ' ,
2257
2269
emscripten_run_script_int__docs : '/** @suppress{checkTypes} */' ,
2258
2270
emscripten_run_script_int : function ( ptr ) {
2259
2271
{ { { makeEval ( 'return eval(UTF8ToString(ptr))|0;' ) } } }
@@ -2262,7 +2274,7 @@ mergeInto(LibraryManager.library, {
2262
2274
// We use builtin_malloc and builtin_free here because otherwise lsan will
2263
2275
// report the last returned string as a leak.
2264
2276
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 ' ,
2266
2278
emscripten_run_script_string : function ( ptr ) {
2267
2279
{ { { makeEval ( "var s = eval(UTF8ToString(ptr));" ) } } }
2268
2280
if ( s == null ) {
@@ -2524,6 +2536,10 @@ mergeInto(LibraryManager.library, {
2524
2536
2525
2537
emscripten_get_callstack__deps : [ 'emscripten_get_callstack_js' ] ,
2526
2538
emscripten_get_callstack : function ( flags , str , maxbytes ) {
2539
+ // Use explicit 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' ) } } } ;
2527
2543
var callstack = _emscripten_get_callstack_js ( flags ) ;
2528
2544
// User can query the required amount of bytes to hold the callstack.
2529
2545
if ( ! str || maxbytes <= 0 ) {
@@ -2562,6 +2578,7 @@ mergeInto(LibraryManager.library, {
2562
2578
}
2563
2579
} ,
2564
2580
2581
+ emscripten_log__sig : 'vipp ',
2565
2582
emscripten_log__deps : [ '$formatString' , 'emscripten_log_js' ] ,
2566
2583
emscripten_log : function ( flags , format , varargs ) {
2567
2584
var result = formatString ( format , varargs ) ;
@@ -2600,6 +2617,7 @@ mergeInto(LibraryManager.library, {
2600
2617
debugger ;
2601
2618
} ,
2602
2619
2620
+ emscripten_print_double__sig : 'iipi' ,
2603
2621
emscripten_print_double : function ( x , to , max ) {
2604
2622
var str = x + '' ;
2605
2623
if ( to ) return stringToUTF8 ( str , to , max ) ;
@@ -2642,14 +2660,22 @@ mergeInto(LibraryManager.library, {
2642
2660
// Returns a representation of a call site of the caller of this function, in a manner
2643
2661
// similar to __builtin_return_address. If level is 0, we return the call site of the
2644
2662
// caller of this function.
2663
+ emscripten_return_address__sig : 'pi' ,
2645
2664
emscripten_return_address__deps : [ '$convertFrameToPC' , '$jsStackTrace' ] ,
2646
2665
emscripten_return_address : function ( level ) {
2647
2666
var callstack = jsStackTrace ( ) . split ( '\n' ) ;
2648
2667
if ( callstack [ 0 ] == 'Error' ) {
2649
2668
callstack . shift ( ) ;
2650
2669
}
2651
2670
// 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 BigInt convertions.
2674
+ var caller = callstack [ level + 4 ] ;
2675
+ #else
2676
+ var caller = callstack [ level + 3 ] ;
2677
+ #endif
2678
+ return convertFrameToPC ( caller ) ;
2653
2679
} ,
2654
2680
2655
2681
$UNWIND_CACHE : { } ,
@@ -2692,6 +2718,7 @@ mergeInto(LibraryManager.library, {
2692
2718
// must be able to unwind from a PC value that may no longer be on the
2693
2719
// execution stack, and so we are forced to cache the entire call stack.
2694
2720
emscripten_stack_snapshot__deps : [ '$convertFrameToPC' , '$UNWIND_CACHE' , '$saveInUnwindCache' , '$jsStackTrace' ] ,
2721
+ emscripten_stack_snapshot__sig : 'p' ,
2695
2722
emscripten_stack_snapshot : function ( ) {
2696
2723
var callstack = jsStackTrace ( ) . split ( '\n' ) ;
2697
2724
if ( callstack [ 0 ] == 'Error' ) {
@@ -2722,6 +2749,7 @@ mergeInto(LibraryManager.library, {
2722
2749
// emscripten_stack_snapshot, or this function will instead use the current
2723
2750
// call stack.
2724
2751
emscripten_stack_unwind_buffer__deps : [ '$UNWIND_CACHE' , '$saveInUnwindCache' , '$convertFrameToPC' , '$jsStackTrace' ] ,
2752
+ emscripten_stack_unwind_buffer__sig : 'ippi' ,
2725
2753
emscripten_stack_unwind_buffer : function ( addr , buffer , count ) {
2726
2754
var stack ;
2727
2755
if ( UNWIND_CACHE . last_addr == addr ) {
@@ -2756,6 +2784,7 @@ mergeInto(LibraryManager.library, {
2756
2784
] ,
2757
2785
// Don't treat allocation of _emscripten_pc_get_function.ret as a leak
2758
2786
emscripten_pc_get_function__noleakcheck : true ,
2787
+ emscripten_pc_get_function__sig : 'pp' ,
2759
2788
#endif
2760
2789
emscripten_pc_get_function : function ( pc ) {
2761
2790
#if ! USE_OFFSET_CONVERTER
@@ -2820,6 +2849,7 @@ mergeInto(LibraryManager.library, {
2820
2849
] ,
2821
2850
// Don't treat allocation of _emscripten_pc_get_file.ret as a leak
2822
2851
emscripten_pc_get_file__noleakcheck : true ,
2852
+ emscripten_pc_get_file__sig : 'pp' ,
2823
2853
emscripten_pc_get_file : function ( pc ) {
2824
2854
var result = convertPCtoSourceLocation ( pc ) ;
2825
2855
if ( ! result ) return 0 ;
@@ -2831,13 +2861,15 @@ mergeInto(LibraryManager.library, {
2831
2861
2832
2862
// Look up the line number from our stack frame cache with our PC representation.
2833
2863
emscripten_pc_get_line__deps : [ '$convertPCtoSourceLocation' ] ,
2864
+ emscripten_pc_get_line__sig : 'pp' ,
2834
2865
emscripten_pc_get_line : function ( pc ) {
2835
2866
var result = convertPCtoSourceLocation ( pc ) ;
2836
2867
return result ? result . line : 0 ;
2837
2868
} ,
2838
2869
2839
2870
// Look up the column number from our stack frame cache with our PC representation.
2840
2871
emscripten_pc_get_column__deps : [ '$convertPCtoSourceLocation' ] ,
2872
+ emscripten_pc_get_column__sig : 'pp' ,
2841
2873
emscripten_pc_get_column : function ( pc ) {
2842
2874
var result = convertPCtoSourceLocation ( pc ) ;
2843
2875
return result ? result . column || 0 : 0 ;
@@ -2882,7 +2914,6 @@ mergeInto(LibraryManager.library, {
2882
2914
#endif
2883
2915
] ,
2884
2916
$readAsmConstArgs : function ( sigPtr , buf ) {
2885
- { { { from64 ( [ 'sigPtr' , 'buf' ] ) } } } ;
2886
2917
#if ASSERTIONS
2887
2918
// Nobody should have mutated _readAsmConstArgsArray underneath us to be something else than an array.
2888
2919
assert ( Array . isArray ( readAsmConstArgsArray ) ) ;
@@ -2960,6 +2991,7 @@ mergeInto(LibraryManager.library, {
2960
2991
#endif
2961
2992
2962
2993
$mainThreadEM_ASM__deps : [ '$readAsmConstArgs' ] ,
2994
+ $mainThreadEM_ASM__sig : 'iippi' ,
2963
2995
$mainThreadEM_ASM : function ( code , sigPtr , argbuf , sync ) {
2964
2996
#if RELOCATABLE
2965
2997
code -= { { { GLOBAL_BASE } } } ;
@@ -3095,6 +3127,7 @@ mergeInto(LibraryManager.library, {
3095
3127
3096
3128
#if STACK_OVERFLOW_CHECK
3097
3129
// Used by wasm-emscripten-finalize to implement STACK_OVERFLOW_CHECK
3130
+ __handle_stack_overflow__sig : 'vp' ,
3098
3131
__handle_stack_overflow__deps : [ 'emscripten_stack_get_base' ] ,
3099
3132
__handle_stack_overflow : function ( requested ) {
3100
3133
requested = requested >>> 0 ;
0 commit comments