@@ -948,7 +948,15 @@ var LibraryPThread = {
948948 _exit(returnCode);
949949 },
950950
951- $proxyToMainThread__deps: ['$withStackSave', '_emscripten_run_on_main_thread_js'],
951+ #if MEMORY64
952+ // Calls proxyToMainThread but returns a bigint rather than a number
953+ $proxyToMainThreadPtr__deps: ['$proxyToMainThread'],
954+ $proxyToMainThreadPtr: function() {
955+ return BigInt(proxyToMainThread.apply(null, arguments));
956+ },
957+ #endif
958+
959+ $proxyToMainThread__deps: ['$withStackSave', '_emscripten_run_on_main_thread_js'].concat(i53ConversionDeps),
952960 $proxyToMainThread__docs: '/** @type{function(number, (number|boolean), ...(number|boolean))} */',
953961 $proxyToMainThread: function(index, sync) {
954962 // Additional arguments are passed after those two, which are the actual
@@ -1032,6 +1040,19 @@ var LibraryPThread = {
10321040 PThread.currentProxiedOperationCallerThread = callingThread;
10331041 var rtn = func.apply(null, proxiedJSCallArgs);
10341042 PThread.currentProxiedOperationCallerThread = 0;
1043+ #if MEMORY64
1044+ // In memory64 mode some proxied functions return bigint/pointer but
1045+ // our return type is i53/double.
1046+ if (typeof rtn == "bigint") {
1047+ rtn = bigintToI53Checked(rtn);
1048+ }
1049+ #endif
1050+ #if ASSERTIONS
1051+ // Proxied functions can return any type except bigint. All other types
1052+ // cooerce to f64/double (the return type of this function in C) but not
1053+ // bigint.
1054+ assert(typeof rtn != "bigint");
1055+ #endif
10351056 return rtn;
10361057 },
10371058
0 commit comments