Skip to content

Commit

Permalink
Cleanup emSetImmediate/emClearImmediate. NFC (emscripten-core#22890)
Browse files Browse the repository at this point in the history
This change avoids the extra dummy library entry `polyfillSetImmediate`.
  • Loading branch information
sbc100 authored Jan 4, 2025
1 parent d7f8277 commit 1436e74
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
20 changes: 8 additions & 12 deletions src/library_eventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ LibraryJSEventLoop = {
setImmediateWrapped.mapping[id] = undefined;
},

$polyfillSetImmediate__deps: ['$setImmediateWrapped', '$clearImmediateWrapped'],
$polyfillSetImmediate__postset: `
var emSetImmediate;
var emClearImmediate;
$emSetImmediate__deps: ['$setImmediateWrapped', '$clearImmediateWrapped', '$emClearImmediate'],
$emSetImmediate__postset: `
if (typeof setImmediate != "undefined") {
emSetImmediate = setImmediateWrapped;
emClearImmediate = clearImmediateWrapped;
Expand All @@ -82,14 +80,12 @@ LibraryJSEventLoop = {
if (index >= 0 && index < __setImmediate_queue.length) __setImmediate_queue[index] = () => {};
})
}`,
$emSetImmediate: undefined,

$polyfillSetImmediate: () => {
// nop, used for its postset to ensure setImmediate() polyfill is
// not duplicated between emscripten_set_immediate() and
// emscripten_set_immediate_loop() if application links to both of them.
},
$emClearImmediate_deps: ['$emSetImmediate'],
$emClearImmediate: undefined,

emscripten_set_immediate__deps: ['$polyfillSetImmediate', '$callUserCallback'],
emscripten_set_immediate__deps: ['$emSetImmediate', '$callUserCallback'],
emscripten_set_immediate: (cb, userData) => {
{{{ runtimeKeepalivePush(); }}}
return emSetImmediate(() => {
Expand All @@ -98,13 +94,13 @@ LibraryJSEventLoop = {
});
},

emscripten_clear_immediate__deps: ['$polyfillSetImmediate'],
emscripten_clear_immediate__deps: ['$emClearImmediate'],
emscripten_clear_immediate: (id) => {
{{{ runtimeKeepalivePop(); }}}
emClearImmediate(id);
},

emscripten_set_immediate_loop__deps: ['$polyfillSetImmediate', '$callUserCallback'],
emscripten_set_immediate_loop__deps: ['$emSetImmediate', '$callUserCallback'],
emscripten_set_immediate_loop: (cb, userData) => {
function tick() {
callUserCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7905
7913
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21012
21045
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6443
6449
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17061
17094
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52855
52898
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
51638
51681

0 comments on commit 1436e74

Please sign in to comment.