Skip to content

Commit bd769ac

Browse files
authored
Use automatic dependency detection for runtimeKeepalivePush/Pop. NFC (#17395)
These are good candidates for this new automatic depenency system because: 1. They are fairly common. 2. They are also generated by a {{{ }}} macro 3. They are conditional which makes their inclusion in regular dependencies messy.
1 parent aa0ed29 commit bd769ac

10 files changed

+24
-115
lines changed

src/jsifier.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,16 @@ function ${name}(${args}) {
177177
}
178178

179179
function addImplicitDeps(snippet, deps) {
180-
// There are some very common dependencies that we inject automatically
181-
// by conservatively scanning the input functions for their usage.
180+
// There are some common dependencies that we inject automatically by
181+
// conservatively scanning the input functions for their usage.
182182
// Specifically, these are dependencies that are automatically generated by
183-
// the {{{ makeDynCall }}} macro which is very common.
184-
const autoDeps = ['getDynCaller', 'getWasmTableEntry'];
183+
// the {{{ makeDynCall }}}, and {{{ runtimeKeepalivePush/Pop }}} macros.
184+
const autoDeps = [
185+
'getDynCaller',
186+
'getWasmTableEntry',
187+
'runtimeKeepalivePush',
188+
'runtimeKeepalivePop',
189+
];
185190
for (const dep of autoDeps) {
186191
if (snippet.includes(dep + '(')) {
187192
deps.push('$' + dep);

src/library.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3319,9 +3319,6 @@ mergeInto(LibraryManager.library, {
33193319

33203320
// Callable in pthread without __proxy needed.
33213321
emscripten_exit_with_live_runtime__sig: 'v',
3322-
#if !MINIMAL_RUNTIME
3323-
emscripten_exit_with_live_runtime__deps: ['$runtimeKeepalivePush'],
3324-
#endif
33253322
emscripten_exit_with_live_runtime: function() {
33263323
{{{ runtimeKeepalivePush() }}}
33273324
throw 'unwind';
@@ -3535,12 +3532,7 @@ mergeInto(LibraryManager.library, {
35353532
},
35363533
#endif
35373534

3538-
$safeSetTimeout__deps: ['$callUserCallback',
3539-
#if !MINIMAL_RUNTIME
3540-
'$runtimeKeepalivePush',
3541-
'$runtimeKeepalivePop',
3542-
#endif
3543-
],
3535+
$safeSetTimeout__deps: ['$callUserCallback'],
35443536
$safeSetTimeout__docs: '/** @param {number=} timeout */',
35453537
$safeSetTimeout: function(func, timeout) {
35463538
{{{ runtimeKeepalivePush() }}}

src/library_browser.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ var LibraryBrowser = {
1111
'$callUserCallback',
1212
'$safeSetTimeout',
1313
'emscripten_set_main_loop_timing',
14-
#if !MINIMAL_RUNTIME
15-
'$runtimeKeepalivePush',
16-
'$runtimeKeepalivePop'
17-
#endif
1814
],
1915
$Browser__postset: 'Module["requestFullscreen"] = function Module_requestFullscreen(lockPointer, resizeCanvas) { Browser.requestFullscreen(lockPointer, resizeCanvas) };\n' + // exports
2016
#if ASSERTIONS
@@ -779,11 +775,7 @@ var LibraryBrowser = {
779775
},
780776
},
781777

782-
emscripten_run_preload_plugins__deps: ['$PATH',
783-
#if !MINIMAL_RUNTIME
784-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
785-
#endif
786-
],
778+
emscripten_run_preload_plugins__deps: ['$PATH'],
787779
emscripten_run_preload_plugins__proxy: 'sync',
788780
emscripten_run_preload_plugins__sig: 'iiii',
789781
emscripten_run_preload_plugins: function(file, onload, onerror) {
@@ -809,9 +801,6 @@ var LibraryBrowser = {
809801
return 0;
810802
},
811803

812-
#if !MINIMAL_RUNTIME
813-
emscripten_run_preload_plugins_data__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'],
814-
#endif
815804
emscripten_run_preload_plugins_data__proxy: 'sync',
816805
emscripten_run_preload_plugins_data__sig: 'viiiiii',
817806
emscripten_run_preload_plugins_data: function(data, size, suffix, arg, onload, onerror) {
@@ -962,7 +951,6 @@ var LibraryBrowser = {
962951
'emscripten_webgl_commit_frame',
963952
#endif
964953
#if !MINIMAL_RUNTIME
965-
'$runtimeKeepalivePush',
966954
'$maybeExit',
967955
#endif
968956
],
@@ -1292,9 +1280,6 @@ var LibraryBrowser = {
12921280

12931281
emscripten_call_worker__proxy: 'sync',
12941282
emscripten_call_worker__sig: 'viiiiii',
1295-
#if !MINIMAL_RUNTIME
1296-
emscripten_call_worker__deps: ['$runtimeKeepalivePush'],
1297-
#endif
12981283
emscripten_call_worker: function(id, funcName, data, size, callback, arg) {
12991284
funcName = UTF8ToString(funcName);
13001285
var info = Browser.workers[id];

src/library_dylink.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,7 @@ var LibraryDylink = {
961961
},
962962

963963
// Async version of dlopen.
964-
_emscripten_dlopen_js__deps: ['$dlopenInternal', '$callUserCallback', '$dlSetError',
965-
#if !MINIMAL_RUNTIME
966-
'$runtimeKeepalivePush',
967-
'$runtimeKeepalivePop',
968-
#endif
969-
],
964+
_emscripten_dlopen_js__deps: ['$dlopenInternal', '$callUserCallback', '$dlSetError'],
970965
_emscripten_dlopen_js__sig: 'viiiii',
971966
_emscripten_dlopen_js: function(handle, onsuccess, onerror) {
972967
/** @param {Object=} e */

src/library_eventloop.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ LibraryJSEventLoop = {
6868
// emscripten_set_immediate_loop() if application links to both of them.
6969
},
7070

71-
emscripten_set_immediate__deps: ['$polyfillSetImmediate', '$callUserCallback',
72-
#if !MINIMAL_RUNTIME
73-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
74-
#endif
75-
],
71+
emscripten_set_immediate__deps: ['$polyfillSetImmediate', '$callUserCallback'],
7672
emscripten_set_immediate: function(cb, userData) {
7773
polyfillSetImmediate();
7874
{{{ runtimeKeepalivePush(); }}}
@@ -84,21 +80,13 @@ LibraryJSEventLoop = {
8480
});
8581
},
8682

87-
emscripten_clear_immediate__deps: ['$polyfillSetImmediate',
88-
#if !MINIMAL_RUNTIME
89-
'$runtimeKeepalivePop',
90-
#endif
91-
],
83+
emscripten_clear_immediate__deps: ['$polyfillSetImmediate'],
9284
emscripten_clear_immediate: function(id) {
9385
{{{ runtimeKeepalivePop(); }}}
9486
emClearImmediate(id);
9587
},
9688

97-
emscripten_set_immediate_loop__deps: ['$polyfillSetImmediate', '$callUserCallback',
98-
#if !MINIMAL_RUNTIME
99-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
100-
#endif
101-
],
89+
emscripten_set_immediate_loop__deps: ['$polyfillSetImmediate', '$callUserCallback'],
10290
emscripten_set_immediate_loop: function(cb, userData) {
10391
polyfillSetImmediate();
10492
function tick() {
@@ -114,11 +102,7 @@ LibraryJSEventLoop = {
114102
return emSetImmediate(tick);
115103
},
116104

117-
emscripten_set_timeout__deps: ['$callUserCallback',
118-
#if !MINIMAL_RUNTIME
119-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
120-
#endif
121-
],
105+
emscripten_set_timeout__deps: ['$callUserCallback'],
122106
emscripten_set_timeout: function(cb, msecs, userData) {
123107
{{{ runtimeKeepalivePush() }}}
124108
return setTimeout(function() {
@@ -133,11 +117,7 @@ LibraryJSEventLoop = {
133117
clearTimeout(id);
134118
},
135119

136-
emscripten_set_timeout_loop__deps: ['$callUserCallback',
137-
#if !MINIMAL_RUNTIME
138-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
139-
#endif
140-
],
120+
emscripten_set_timeout_loop__deps: ['$callUserCallback'],
141121
emscripten_set_timeout_loop: function(cb, msecs, userData) {
142122
function tick() {
143123
var t = performance.now();
@@ -157,11 +137,7 @@ LibraryJSEventLoop = {
157137
return setTimeout(tick, 0);
158138
},
159139

160-
emscripten_set_interval__deps: ['$callUserCallback',
161-
#if !MINIMAL_RUNTIME
162-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
163-
#endif
164-
],
140+
emscripten_set_interval__deps: ['$callUserCallback'],
165141
emscripten_set_interval: function(cb, msecs, userData) {
166142
{{{ runtimeKeepalivePush() }}}
167143
return setInterval(function() {
@@ -171,9 +147,6 @@ LibraryJSEventLoop = {
171147
}, msecs);
172148
},
173149

174-
#if !MINIMAL_RUNTIME
175-
emscripten_clear_interval__deps: ['$runtimeKeepalivePop'],
176-
#endif
177150
emscripten_clear_interval: function(id) {
178151
{{{ runtimeKeepalivePop() }}}
179152
clearInterval(id);

src/library_fetch.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ var LibraryFetch = {
2929
'$Fetch',
3030
'$fetchXHR',
3131
'$callUserCallback',
32-
#if !MINIMAL_RUNTIME
33-
'$runtimeKeepalivePush',
34-
'$runtimeKeepalivePop',
35-
#endif
3632
#if FETCH_SUPPORT_INDEXEDDB
3733
'$fetchCacheData',
3834
'$fetchLoadCachedData',

src/library_sockfs.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,7 @@ mergeInto(LibraryManager.library, {
731731
* Passing a NULL callback function to a emscripten_set_socket_*_callback call
732732
* will deregister the callback registered for that Event.
733733
*/
734-
$_setNetworkCallback__deps: ['$withStackSave',
735-
#if !MINIMAL_RUNTIME
736-
'$runtimeKeepalivePush',
737-
#endif
738-
],
734+
$_setNetworkCallback__deps: ['$withStackSave'],
739735
$_setNetworkCallback: function(event, userData, callback) {
740736
function _callback(data) {
741737
try {

src/library_wasmfs_jsimpl.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ mergeInto(LibraryManager.library, {
5959
// (however, dyncalls might also just work, given in MEMORY64 we assume
6060
// WASM_BIGINT so the pointer is just a single argument, just like in
6161
// wasm32).
62-
_wasmfs_jsimpl_async_alloc_file__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'],
6362
_wasmfs_jsimpl_async_alloc_file: async function(ctx, backend, file) {
6463
#if ASSERTIONS
6564
assert(wasmFS$backends[backend]);
@@ -68,7 +67,6 @@ mergeInto(LibraryManager.library, {
6867
_emscripten_proxy_finish(ctx);
6968
},
7069

71-
_wasmfs_jsimpl_async_free_file__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'],
7270
_wasmfs_jsimpl_async_free_file: async function(ctx, backend, file) {
7371
#if ASSERTIONS
7472
assert(wasmFS$backends[backend]);
@@ -77,7 +75,6 @@ mergeInto(LibraryManager.library, {
7775
_emscripten_proxy_finish(ctx);
7876
},
7977

80-
_wasmfs_jsimpl_async_write__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'],
8178
_wasmfs_jsimpl_async_write: async function(ctx, backend, file, buffer, length, {{{ defineI64Param('offset') }}}, result_p) {
8279
{{{ receiveI64ParamAsDouble('offset') }}}
8380
#if ASSERTIONS
@@ -88,7 +85,6 @@ mergeInto(LibraryManager.library, {
8885
_emscripten_proxy_finish(ctx);
8986
},
9087

91-
_wasmfs_jsimpl_async_read__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'],
9288
_wasmfs_jsimpl_async_read: async function(ctx, backend, file, buffer, length, {{{ defineI64Param('offset') }}}, result_p) {
9389
{{{ receiveI64ParamAsDouble('offset') }}}
9490
#if ASSERTIONS
@@ -99,7 +95,6 @@ mergeInto(LibraryManager.library, {
9995
_emscripten_proxy_finish(ctx);
10096
},
10197

102-
_wasmfs_jsimpl_async_get_size__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'],
10398
_wasmfs_jsimpl_async_get_size: async function(ctx, backend, file, size_p) {
10499
#if ASSERTIONS
105100
assert(wasmFS$backends[backend]);

src/library_webgpu.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,6 @@ var LibraryWebGPU = {
757757
'$callUserCallback',
758758
#if MINIMAL_RUNTIME
759759
'$allocateUTF8',
760-
#else
761-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
762760
#endif
763761
],
764762
wgpuDevicePopErrorScope: function(deviceId, callback, userdata) {
@@ -1489,12 +1487,7 @@ var LibraryWebGPU = {
14891487
queue["submit"](cmds);
14901488
},
14911489

1492-
wgpuQueueOnSubmittedWorkDone__deps: [
1493-
'$callUserCallback',
1494-
#if !MINIMAL_RUNTIME
1495-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
1496-
#endif
1497-
],
1490+
wgpuQueueOnSubmittedWorkDone__deps: ['$callUserCallback'],
14981491
wgpuQueueOnSubmittedWorkDone: function(queueId, {{{ defineI64Param('signalValue') }}}, callback, userdata) {
14991492
var queue = WebGPU.mgrQueue.get(queueId);
15001493
#if ASSERTIONS
@@ -1911,12 +1904,7 @@ var LibraryWebGPU = {
19111904

19121905
// In webgpu.h offset and size are passed in as size_t.
19131906
// And library_webgpu assumes that size_t is always 32bit in emscripten.
1914-
wgpuBufferMapAsync__deps: [
1915-
'$callUserCallback',
1916-
#if !MINIMAL_RUNTIME
1917-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
1918-
#endif
1919-
],
1907+
wgpuBufferMapAsync__deps: ['$callUserCallback'],
19201908
wgpuBufferMapAsync: function(bufferId, mode, offset, size, callback, userdata) {
19211909
var bufferWrapper = WebGPU.mgrBuffer.objects[bufferId];
19221910
{{{ gpu.makeCheckDefined('bufferWrapper') }}}
@@ -2380,8 +2368,6 @@ var LibraryWebGPU = {
23802368
'$callUserCallback',
23812369
#if MINIMAL_RUNTIME
23822370
'$allocateUTF8',
2383-
#else
2384-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
23852371
#endif
23862372
],
23872373
wgpuInstanceRequestAdapter: function(instanceId, options, callback, userdata) {
@@ -2466,8 +2452,6 @@ var LibraryWebGPU = {
24662452
'$callUserCallback',
24672453
#if MINIMAL_RUNTIME
24682454
'$allocateUTF8',
2469-
#else
2470-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
24712455
#endif
24722456
],
24732457
wgpuAdapterRequestDevice: function(adapterId, descriptor, callback, userdata) {

src/library_wget.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ var LibraryWget = {
1616
},
1717
},
1818

19-
emscripten_async_wget__deps: ['$PATH_FS', '$wget', '$callUserCallback', '$Browser', '$withStackSave',
20-
#if !MINIMAL_RUNTIME
21-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
22-
#endif
23-
],
19+
emscripten_async_wget__deps: ['$PATH_FS', '$wget', '$callUserCallback', '$Browser', '$withStackSave'],
2420
emscripten_async_wget__proxy: 'sync',
2521
emscripten_async_wget__sig: 'viiii',
2622
emscripten_async_wget: function(url, file, onload, onerror) {
@@ -63,11 +59,7 @@ var LibraryWget = {
6359
);
6460
},
6561

66-
emscripten_async_wget_data__deps: ['$asyncLoad', 'malloc', 'free', '$callUserCallback',
67-
#if !MINIMAL_RUNTIME
68-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
69-
#endif
70-
],
62+
emscripten_async_wget_data__deps: ['$asyncLoad', 'malloc', 'free', '$callUserCallback'],
7163
emscripten_async_wget_data__proxy: 'sync',
7264
emscripten_async_wget_data__sig: 'viiii',
7365
emscripten_async_wget_data: function(url, arg, onload, onerror) {
@@ -90,11 +82,7 @@ var LibraryWget = {
9082
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
9183
},
9284

93-
emscripten_async_wget2__deps: ['$PATH_FS', '$wget', '$withStackSave',
94-
#if !MINIMAL_RUNTIME
95-
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
96-
#endif
97-
],
85+
emscripten_async_wget2__deps: ['$PATH_FS', '$wget', '$withStackSave'],
9886
emscripten_async_wget2__proxy: 'sync',
9987
emscripten_async_wget2__sig: 'iiiiiiiii',
10088
emscripten_async_wget2: function(url, file, request, param, arg, onload, onerror, onprogress) {

0 commit comments

Comments
 (0)