Skip to content

Commit a30a119

Browse files
authored
Remove unnecessary dependencies. NFC (#27077)
Followup to #27075
1 parent bdd20af commit a30a119

13 files changed

Lines changed: 60 additions & 140 deletions

src/lib/libbrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ var LibraryBrowser = {
614614
},
615615

616616
// TODO: currently not callable from a pthread, but immediately calls onerror() if not on main thread.
617-
emscripten_async_load_script__deps: ['$UTF8ToString'],
617+
emscripten_async_load_script__deps: ['$UTF8ToString', '$runDependencies', '$dependenciesFulfilled'],
618618
emscripten_async_load_script: async (url, onload, onerror) => {
619619
url = UTF8ToString(url);
620620
#if PTHREADS

src/lib/libfetch.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
var LibraryFetch = {
1010
$Fetch__postset: 'Fetch.init();',
11-
$Fetch__deps: ['$HandleAllocator'],
11+
$Fetch__deps: [
12+
'$HandleAllocator',
13+
#if FETCH_SUPPORT_INDEXEDDB
14+
'$addRunDependency',
15+
'$removeRunDependency',
16+
#endif
17+
],
1218
$Fetch: Fetch,
1319
_emscripten_fetch_get_response_headers_length__deps: ['$lengthBytesUTF8'],
1420
_emscripten_fetch_get_response_headers_length: fetchGetResponseHeadersLength,

test/codesize/test_codesize_file_preload.expected.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -517,25 +517,6 @@ var onPreRuns = [];
517517

518518
var addOnPreRun = cb => onPreRuns.push(cb);
519519

520-
var runDependencies = 0;
521-
522-
var dependenciesFulfilled = null;
523-
524-
var removeRunDependency = id => {
525-
runDependencies--;
526-
if (runDependencies == 0) {
527-
if (dependenciesFulfilled) {
528-
var callback = dependenciesFulfilled;
529-
dependenciesFulfilled = null;
530-
callback();
531-
}
532-
}
533-
};
534-
535-
var addRunDependency = id => {
536-
runDependencies++;
537-
};
538-
539520
/** @param {number=} offset */ var doWritev = (stream, iov, iovcnt, offset) => {
540521
var ret = 0;
541522
for (var i = 0; i < iovcnt; i++) {
@@ -1323,6 +1304,25 @@ var FS_createDataFile = (...args) => FS.createDataFile(...args);
13231304

13241305
var getUniqueRunDependency = id => id;
13251306

1307+
var runDependencies = 0;
1308+
1309+
var dependenciesFulfilled = null;
1310+
1311+
var removeRunDependency = id => {
1312+
runDependencies--;
1313+
if (runDependencies == 0) {
1314+
if (dependenciesFulfilled) {
1315+
var callback = dependenciesFulfilled;
1316+
dependenciesFulfilled = null;
1317+
callback();
1318+
}
1319+
}
1320+
};
1321+
1322+
var addRunDependency = id => {
1323+
runDependencies++;
1324+
};
1325+
13261326
var preloadPlugins = [];
13271327

13281328
var FS_handledByPreloadPlugin = async (byteArray, fullname) => {

test/codesize/test_codesize_file_preload.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 22109,
3-
"a.out.js.gz": 9180,
2+
"a.out.js": 22108,
3+
"a.out.js.gz": 9183,
44
"a.out.nodebug.wasm": 1666,
55
"a.out.nodebug.wasm.gz": 945,
6-
"total": 23775,
7-
"total_gz": 10125,
6+
"total": 23774,
7+
"total_gz": 10128,
88
"sent": [
99
"a (fd_write)"
1010
],

test/codesize/test_codesize_hello_O0.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 23358,
3-
"a.out.js.gz": 8434,
2+
"a.out.js": 23248,
3+
"a.out.js.gz": 8396,
44
"a.out.nodebug.wasm": 15115,
55
"a.out.nodebug.wasm.gz": 7464,
6-
"total": 38473,
7-
"total_gz": 15898,
6+
"total": 38363,
7+
"total_gz": 15860,
88
"sent": [
99
"fd_write"
1010
],

test/codesize/test_codesize_hello_dylink.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"a.out.js": 26398,
2+
"a.out.js": 26397,
33
"a.out.js.gz": 11245,
44
"a.out.nodebug.wasm": 17861,
55
"a.out.nodebug.wasm.gz": 9019,
6-
"total": 44259,
6+
"total": 44258,
77
"total_gz": 20264,
88
"sent": [
99
"__syscall_stat64",

test/codesize/test_codesize_minimal_O0.expected.js

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -736,67 +736,6 @@ async function createWasm() {
736736
/** @type {!Uint8Array} */
737737
var HEAPU8;
738738

739-
var runDependencies = 0;
740-
741-
742-
var dependenciesFulfilled = null;
743-
744-
var runDependencyTracking = {
745-
};
746-
747-
var runDependencyWatcher = null;
748-
var removeRunDependency = (id) => {
749-
runDependencies--;
750-
751-
assert(id, 'removeRunDependency requires an ID');
752-
assert(runDependencyTracking[id]);
753-
delete runDependencyTracking[id];
754-
if (runDependencies == 0) {
755-
if (runDependencyWatcher !== null) {
756-
clearInterval(runDependencyWatcher);
757-
runDependencyWatcher = null;
758-
}
759-
if (dependenciesFulfilled) {
760-
var callback = dependenciesFulfilled;
761-
dependenciesFulfilled = null;
762-
callback(); // can add another dependenciesFulfilled
763-
}
764-
}
765-
};
766-
767-
768-
var addRunDependency = (id) => {
769-
runDependencies++;
770-
771-
assert(id, 'addRunDependency requires an ID')
772-
assert(!runDependencyTracking[id]);
773-
runDependencyTracking[id] = 1;
774-
if (runDependencyWatcher === null && globalThis.setInterval) {
775-
// Check for missing dependencies every few seconds
776-
runDependencyWatcher = setInterval(() => {
777-
if (ABORT) {
778-
clearInterval(runDependencyWatcher);
779-
runDependencyWatcher = null;
780-
return;
781-
}
782-
var shown = false;
783-
for (var dep in runDependencyTracking) {
784-
if (!shown) {
785-
shown = true;
786-
err('still waiting on run dependencies:');
787-
}
788-
err(`dependency: ${dep}`);
789-
}
790-
if (shown) {
791-
err('(end of list)');
792-
}
793-
}, 10000);
794-
// Prevent this timer from keeping the runtime alive if nothing
795-
// else is.
796-
runDependencyWatcher.unref?.()
797-
}
798-
};
799-
800739
var callRuntimeCallbacks = (callbacks) => {
801740
while (callbacks.length > 0) {
802741
// Pass the module as the first argument.
@@ -831,7 +770,6 @@ async function createWasm() {
831770
return '0x' + ptr.toString(16).padStart(8, '0');
832771
}
833772

834-
835773

836774
/**
837775
* @param {number} ptr
@@ -953,6 +891,8 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
953891
'mmapAlloc',
954892
'HandleAllocator',
955893
'getUniqueRunDependency',
894+
'addRunDependency',
895+
'removeRunDependency',
956896
'addOnPreRun',
957897
'addOnInit',
958898
'addOnPostCtor',
@@ -1103,8 +1043,6 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
11031043
'wasmTable',
11041044
'wasmMemory',
11051045
'noExitRuntime',
1106-
'addRunDependency',
1107-
'removeRunDependency',
11081046
'freeTableIndexes',
11091047
'functionsInTableMap',
11101048
'setValue',
@@ -1380,21 +1318,10 @@ function stackCheckInit() {
13801318

13811319
function run() {
13821320

1383-
if (runDependencies > 0) {
1384-
dependenciesFulfilled = run;
1385-
return;
1386-
}
1387-
13881321
stackCheckInit();
13891322

13901323
preRun();
13911324

1392-
// a preRun added a dependency, run will be called later
1393-
if (runDependencies > 0) {
1394-
dependenciesFulfilled = run;
1395-
return;
1396-
}
1397-
13981325
function doRun() {
13991326
// run may have just been called through dependencies being fulfilled just in this very frame,
14001327
// or while the async setStatus time below was happening

test/codesize/test_codesize_minimal_O0.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.out.js": 18596,
3-
"a.out.js.gz": 6720,
3+
"a.out.js.gz": 6718,
44
"a.out.nodebug.wasm": 1015,
55
"a.out.nodebug.wasm.gz": 602,
66
"total": 19611,
7-
"total_gz": 7322,
7+
"total_gz": 7320,
88
"sent": [],
99
"imports": [],
1010
"exports": [

test/codesize/test_codesize_minimal_pthreads.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 6975,
3-
"a.out.js.gz": 3442,
2+
"a.out.js": 6949,
3+
"a.out.js.gz": 3427,
44
"a.out.nodebug.wasm": 19063,
55
"a.out.nodebug.wasm.gz": 8803,
6-
"total": 26038,
7-
"total_gz": 12245,
6+
"total": 26012,
7+
"total_gz": 12230,
88
"sent": [
99
"a (memory)",
1010
"b (exit)",

test/codesize/test_codesize_minimal_pthreads_memgrowth.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 7383,
3-
"a.out.js.gz": 3643,
2+
"a.out.js": 7357,
3+
"a.out.js.gz": 3627,
44
"a.out.nodebug.wasm": 19064,
55
"a.out.nodebug.wasm.gz": 8804,
6-
"total": 26447,
7-
"total_gz": 12447,
6+
"total": 26421,
7+
"total_gz": 12431,
88
"sent": [
99
"a (memory)",
1010
"b (exit)",

0 commit comments

Comments
 (0)