Skip to content

Commit b9b9aba

Browse files
authored
Convert loadDylibs to async. NFC (#24978)
1 parent 2cac602 commit b9b9aba

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

src/lib/libdylink.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,8 +1174,8 @@ var LibraryDylink = {
11741174
},
11751175

11761176
$loadDylibs__internal: true,
1177-
$loadDylibs__deps: ['$loadDynamicLibrary', '$reportUndefinedSymbols'],
1178-
$loadDylibs: () => {
1177+
$loadDylibs__deps: ['$loadDynamicLibrary', '$reportUndefinedSymbols', '$addRunDependency', '$removeRunDependency'],
1178+
$loadDylibs: async () => {
11791179
if (!dynamicLibraries.length) {
11801180
#if DYLINK_DEBUG
11811181
dbg('loadDylibs: no libraries to preload');
@@ -1187,21 +1187,19 @@ var LibraryDylink = {
11871187
#if DYLINK_DEBUG
11881188
dbg('loadDylibs:', dynamicLibraries);
11891189
#endif
1190+
addRunDependency('loadDylibs');
11901191

11911192
// Load binaries asynchronously
1192-
addRunDependency('loadDylibs');
1193-
dynamicLibraries
1194-
.reduce((chain, lib) => chain.then(() =>
1195-
loadDynamicLibrary(lib, {loadAsync: true, global: true, nodelete: true, allowUndefined: true})
1196-
), Promise.resolve())
1197-
.then(() => {
1198-
// we got them all, wonderful
1199-
reportUndefinedSymbols();
1200-
removeRunDependency('loadDylibs');
1201-
#if DYLINK_DEBUG
1202-
dbg('loadDylibs done!');
1203-
#endif
1204-
});
1193+
for (var lib of dynamicLibraries) {
1194+
await loadDynamicLibrary(lib, {loadAsync: true, global: true, nodelete: true, allowUndefined: true})
1195+
}
1196+
// we got them all, wonderful
1197+
reportUndefinedSymbols();
1198+
1199+
#if DYLINK_DEBUG
1200+
dbg('loadDylibs done!');
1201+
#endif
1202+
removeRunDependency('loadDylibs');
12051203
},
12061204

12071205
// void* dlopen(const char* filename, int flags);

test/code_size/test_codesize_hello_dylink.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 27002,
3-
"a.out.js.gz": 11463,
2+
"a.out.js": 26976,
3+
"a.out.js.gz": 11462,
44
"a.out.nodebug.wasm": 18561,
55
"a.out.nodebug.wasm.gz": 9167,
6-
"total": 45563,
7-
"total_gz": 20630,
6+
"total": 45537,
7+
"total_gz": 20629,
88
"sent": [
99
"__heap_base",
1010
"__indirect_function_table",

test/code_size/test_codesize_hello_dylink_all.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"a.out.js": 246665,
2+
"a.out.js": 246639,
33
"a.out.nodebug.wasm": 597720,
4-
"total": 844385,
4+
"total": 844359,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",

0 commit comments

Comments
 (0)