Skip to content

Mark async imports in library files instead hardcoded list. #19134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@
}

DEFAULT_ASYNCIFY_IMPORTS = [
'emscripten_wget', 'emscripten_wget_data', 'emscripten_idb_load',
'emscripten_idb_store', 'emscripten_idb_delete', 'emscripten_idb_exists',
'emscripten_idb_load_blob', 'emscripten_idb_store_blob', 'SDL_Delay',
'emscripten_scan_registers', 'emscripten_lazy_load_code',
'emscripten_fiber_swap', '__load_secondary_module',
'wasi_snapshot_preview1.fd_sync', '__wasi_fd_sync', '_emval_await',
'_dlopen_js', '__asyncjs__*'
'wasi_snapshot_preview1.fd_sync', '__wasi_fd_sync', '__asyncjs__*'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see __load_secondary_module modified - is that handled differently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already an async function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks.

]

DEFAULT_ASYNCIFY_EXPORTS = [
Expand Down
1 change: 1 addition & 0 deletions src/embind/emval.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ var LibraryEmVal = {

#if ASYNCIFY
_emval_await__deps: ['$Emval', '$Asyncify'],
_emval_await__async: true,
_emval_await: function(promise) {
return Asyncify.handleAsync(() => {
promise = Emval.toValue(promise);
Expand Down
5 changes: 5 additions & 0 deletions src/library_async.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ mergeInto(LibraryManager.library, {
},

emscripten_wget__deps: ['$Browser', '$PATH_FS', '$FS'],
emscripten_wget__async: true,
emscripten_wget: function(url, file) {
return Asyncify.handleSleep((wakeUp) => {
var _url = UTF8ToString(url);
Expand Down Expand Up @@ -489,6 +490,7 @@ mergeInto(LibraryManager.library, {
},

emscripten_wget_data__deps: ['$asyncLoad', 'malloc'],
emscripten_wget_data__async: true,
emscripten_wget_data: function(url, pbuffer, pnum, perror) {
return Asyncify.handleSleep((wakeUp) => {
asyncLoad(UTF8ToString(url), (byteArray) => {
Expand All @@ -507,6 +509,7 @@ mergeInto(LibraryManager.library, {
},

emscripten_scan_registers__deps: ['$safeSetTimeout'],
emscripten_scan_registers__async: true,
emscripten_scan_registers: function(func) {
return Asyncify.handleSleep((wakeUp) => {
// We must first unwind, so things are spilled to the stack. Then while
Expand All @@ -523,6 +526,7 @@ mergeInto(LibraryManager.library, {
},

emscripten_lazy_load_code__sig: 'v',
emscripten_lazy_load_code__async: true,
emscripten_lazy_load_code: function() {
return Asyncify.handleSleep((wakeUp) => {
// Update the expected wasm binary file to be the lazy one.
Expand Down Expand Up @@ -607,6 +611,7 @@ mergeInto(LibraryManager.library, {
},

emscripten_fiber_swap__deps: ["$Asyncify", "$Fibers"],
emscripten_fiber_swap__async: true,
emscripten_fiber_swap: function(oldFiber, newFiber) {
if (ABORT) return;
#if ASYNCIFY_DEBUG
Expand Down
3 changes: 3 additions & 0 deletions src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@ var LibraryDylink = {
},

_dlopen_js__deps: ['$dlopenInternal'],
#if ASYNCIFY
_dlopen_js__async: true,
#endif
_dlopen_js: function(handle) {
#if ASYNCIFY
return Asyncify.handleSleep(function(wakeUp) {
Expand Down
6 changes: 6 additions & 0 deletions src/library_idbstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var LibraryIDBStore = {
},

#if ASYNCIFY
emscripten_idb_load__async: true,
emscripten_idb_load: function(db, id, pbuffer, pnum, perror) {
Asyncify.handleSleep(function(wakeUp) {
IDBStore.getFile(UTF8ToString(db), UTF8ToString(id), function(error, byteArray) {
Expand All @@ -72,6 +73,7 @@ var LibraryIDBStore = {
});
});
},
emscripten_idb_store__async: true,
emscripten_idb_store: function(db, id, ptr, num, perror) {
Asyncify.handleSleep(function(wakeUp) {
IDBStore.setFile(UTF8ToString(db), UTF8ToString(id), new Uint8Array(HEAPU8.subarray(ptr, ptr+num)), function(error) {
Expand All @@ -80,6 +82,7 @@ var LibraryIDBStore = {
});
});
},
emscripten_idb_delete__async: true,
emscripten_idb_delete: function(db, id, perror) {
Asyncify.handleSleep(function(wakeUp) {
IDBStore.deleteFile(UTF8ToString(db), UTF8ToString(id), function(error) {
Expand All @@ -88,6 +91,7 @@ var LibraryIDBStore = {
});
});
},
emscripten_idb_exists__async: true,
emscripten_idb_exists: function(db, id, pexists, perror) {
Asyncify.handleSleep(function(wakeUp) {
IDBStore.existsFile(UTF8ToString(db), UTF8ToString(id), function(error, exists) {
Expand All @@ -98,6 +102,7 @@ var LibraryIDBStore = {
});
},
// extra worker methods - proxied
emscripten_idb_load_blob__async: true,
emscripten_idb_load_blob: function(db, id, pblob, perror) {
Asyncify.handleSleep(function(wakeUp) {
assert(!IDBStore.pending);
Expand All @@ -123,6 +128,7 @@ var LibraryIDBStore = {
});
});
},
emscripten_idb_store_blob__async: true,
emscripten_idb_store_blob: function(db, id, ptr, num, perror) {
Asyncify.handleSleep(function(wakeUp) {
assert(!IDBStore.pending);
Expand Down
1 change: 1 addition & 0 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,7 @@ var LibrarySDL = {
},
#else
SDL_Delay__deps: ['emscripten_sleep'],
SDL_Delay__async: true,
SDL_Delay: function(delay) {
_emscripten_sleep(delay);
},
Expand Down