@@ -957,21 +957,17 @@ var LibraryPThread = {
957957#if MEMORY64
958958 // Calls proxyToMainThread but returns a bigint rather than a number
959959 $proxyToMainThreadPtr__deps: ['$proxyToMainThread'],
960- $proxyToMainThreadPtr: function() {
961- return BigInt(proxyToMainThread.apply(null, arguments));
962- },
960+ $proxyToMainThreadPtr: (...args) => BigInt(proxyToMainThread(...args)),
963961#endif
964962
965963 $proxyToMainThread__deps: ['$withStackSave', '_emscripten_run_on_main_thread_js'].concat(i53ConversionDeps),
966- $proxyToMainThread__docs: '/** @type{function(number, (number|boolean), ...( number|boolean) )} */',
967- $proxyToMainThread: function (index, sync) {
964+ $proxyToMainThread__docs: '/** @type{function(number, (number|boolean), ...number)} */',
965+ $proxyToMainThread: (index, sync, ...callArgs) => {
968966 // Additional arguments are passed after those two, which are the actual
969967 // function arguments.
970968 // The serialization buffer contains the number of call params, and then
971969 // all the args here.
972970 // We also pass 'sync' to C separately, since C needs to look at it.
973- var numCallArgs = arguments.length - 2;
974- var outerArgs = arguments;
975971 // Allocate a buffer, which will be copied by the C code.
976972 return withStackSave(() => {
977973 // First passed parameter specifies the number of arguments to the function.
@@ -980,11 +976,11 @@ var LibraryPThread = {
980976 // type info here). To do that, add a "prefix" before each value that
981977 // indicates if it is a BigInt, which effectively doubles the number of
982978 // values we serialize for proxying. TODO: pack this?
983- var serializedNumCallArgs = numCallArgs {{{ WASM_BIGINT ? "* 2" : "" }}};
979+ var serializedNumCallArgs = callArgs.length {{{ WASM_BIGINT ? "* 2" : "" }}};
984980 var args = stackAlloc(serializedNumCallArgs * 8);
985981 var b = {{{ getHeapOffset('args', 'i64') }}};
986- for (var i = 0; i < numCallArgs ; i++) {
987- var arg = outerArgs[2 + i];
982+ for (var i = 0; i < callArgs.length ; i++) {
983+ var arg = callArgs[ i];
988984#if WASM_BIGINT
989985 if (typeof arg == 'bigint') {
990986 // The prefix is non-zero to indicate a bigint.
0 commit comments