From 1ddef047f8c88bb5f4241c82ff715ec1f0cc65bd Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 7 Dec 2024 11:28:14 -0800 Subject: [PATCH] Simplify asyncLoad. NFC (#23100) Turns out non of the callers were relying the adding of the run dependencies here. There are 4 call sites total: - emscripten_async_wget_data: Explicitly sets noRunDep - emscripten_wget_data: Explicitly sets noRunDep - loadDynamicLibrary: The outer loadDylibs already has an explicit calls to addRunDependency/removeRunDependency. - FS_createPreloadedFile: Already has an explicit calls to addRunDependency/removeRunDependency. --- src/library.js | 6 +----- src/library_async.js | 2 +- src/library_wget.js | 2 +- test/other/codesize/test_codesize_hello_dylink.gzsize | 2 +- test/other/codesize/test_codesize_hello_dylink.jssize | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/library.js b/src/library.js index de40788604bf9..132de3c2910b0 100644 --- a/src/library.js +++ b/src/library.js @@ -2181,18 +2181,14 @@ addToLibrary({ return x.startsWith('dynCall_') ? x : '_' + x; }, - $asyncLoad__docs: '/** @param {boolean=} noRunDep */', - $asyncLoad: (url, noRunDep) => { + $asyncLoad: (url) => { return new Promise((resolve, reject) => { - var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : ''; - if (dep) addRunDependency(dep); readAsync(url).then( (arrayBuffer) => { #if ASSERTIONS assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`); #endif resolve(new Uint8Array(arrayBuffer)); - if (dep) removeRunDependency(dep); }, reject); }); }, diff --git a/src/library_async.js b/src/library_async.js index a3fbc151cb76f..9327bc3b495ff 100644 --- a/src/library_async.js +++ b/src/library_async.js @@ -471,7 +471,7 @@ addToLibrary({ emscripten_wget_data: (url, pbuffer, pnum, perror) => { return Asyncify.handleSleep((wakeUp) => { /* no need for run dependency, this is async but will not do any prepare etc. step */ - asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => { + asyncLoad(UTF8ToString(url)).then((byteArray) => { // can only allocate the buffer after the wakeUp, not during an asyncing var buffer = _malloc(byteArray.length); // must be freed by caller! HEAPU8.set(byteArray, buffer); diff --git a/src/library_wget.js b/src/library_wget.js index fe6416a7391f0..279913d0e19b4 100644 --- a/src/library_wget.js +++ b/src/library_wget.js @@ -65,7 +65,7 @@ var LibraryWget = { emscripten_async_wget_data: (url, userdata, onload, onerror) => { {{{ runtimeKeepalivePush() }}} /* no need for run dependency, this is async but will not do any prepare etc. step */ - asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => { + asyncLoad(UTF8ToString(url)).then((byteArray) => { {{{ runtimeKeepalivePop() }}} callUserCallback(() => { var buffer = _malloc(byteArray.length); diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index dcea0b8b886f4..473dc4cba135f 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6294 +6276 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 180ee9baf7ffc..153b68e34d9a0 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13863 +13831