diff --git a/src/library.js b/src/library.js index cc9d3f69fcde3..135c734fc0aa6 100644 --- a/src/library.js +++ b/src/library.js @@ -2911,7 +2911,7 @@ addToLibrary({ // code paths as similar as possible on both sides.) // -1 - code is the encoding of a proxied EM_ASM, as a negative number // (positive numbers are non-EM_ASM calls). - return proxyToMainThread.apply(null, [-1 - code, sync].concat(args)); + return proxyToMainThread(-1 - code, sync, ...args); } #endif #if ASSERTIONS diff --git a/src/library_pthread.js b/src/library_pthread.js index a204c2b5b3b90..bc65dd9249f4b 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -957,21 +957,17 @@ var LibraryPThread = { #if MEMORY64 // Calls proxyToMainThread but returns a bigint rather than a number $proxyToMainThreadPtr__deps: ['$proxyToMainThread'], - $proxyToMainThreadPtr: function() { - return BigInt(proxyToMainThread.apply(null, arguments)); - }, + $proxyToMainThreadPtr: (...args) => BigInt(proxyToMainThread(...args)), #endif $proxyToMainThread__deps: ['$withStackSave', '_emscripten_run_on_main_thread_js'].concat(i53ConversionDeps), - $proxyToMainThread__docs: '/** @type{function(number, (number|boolean), ...(number|boolean))} */', - $proxyToMainThread: function(index, sync) { + $proxyToMainThread__docs: '/** @type{function(number, (number|boolean), ...number)} */', + $proxyToMainThread: (index, sync, ...callArgs) => { // Additional arguments are passed after those two, which are the actual // function arguments. // The serialization buffer contains the number of call params, and then // all the args here. // We also pass 'sync' to C separately, since C needs to look at it. - var numCallArgs = arguments.length - 2; - var outerArgs = arguments; // Allocate a buffer, which will be copied by the C code. return withStackSave(() => { // First passed parameter specifies the number of arguments to the function. @@ -980,11 +976,11 @@ var LibraryPThread = { // type info here). To do that, add a "prefix" before each value that // indicates if it is a BigInt, which effectively doubles the number of // values we serialize for proxying. TODO: pack this? - var serializedNumCallArgs = numCallArgs {{{ WASM_BIGINT ? "* 2" : "" }}}; + var serializedNumCallArgs = callArgs.length {{{ WASM_BIGINT ? "* 2" : "" }}}; var args = stackAlloc(serializedNumCallArgs * 8); var b = {{{ getHeapOffset('args', 'i64') }}}; - for (var i = 0; i < numCallArgs; i++) { - var arg = outerArgs[2 + i]; + for (var i = 0; i < callArgs.length; i++) { + var arg = callArgs[i]; #if WASM_BIGINT if (typeof arg == 'bigint') { // The prefix is non-zero to indicate a bigint. diff --git a/test/other/metadce/test_metadce_minimal_pthreads.gzsize b/test/other/metadce/test_metadce_minimal_pthreads.gzsize index d05eeed63c5c3..b1feb95664247 100644 --- a/test/other/metadce/test_metadce_minimal_pthreads.gzsize +++ b/test/other/metadce/test_metadce_minimal_pthreads.gzsize @@ -1 +1 @@ -4923 +4920 diff --git a/test/other/metadce/test_metadce_minimal_pthreads.jssize b/test/other/metadce/test_metadce_minimal_pthreads.jssize index 67700c91ca4af..34e006b941803 100644 --- a/test/other/metadce/test_metadce_minimal_pthreads.jssize +++ b/test/other/metadce/test_metadce_minimal_pthreads.jssize @@ -1 +1 @@ -13664 +13635