Skip to content

Commit 1df360c

Browse files
authored
[jspi] Fix dlopen with MEMORY64 and JSPI. (#23588)
Adds the various `async` and `awaits` before the conversion to BigInt.
1 parent 753f1ef commit 1df360c

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/jsifier.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,23 @@ export async function runJSify(outputFile, symbolsOnly) {
248248
}
249249

250250
if ((sig[0] == 'j' && i53abi) || (sig[0] == 'p' && MEMORY64)) {
251+
const await_ = async_ ? 'await ' : '';
251252
// For functions that where we need to mutate the return value, we
252253
// also need to wrap the body in an inner function.
253254
if (oneliner) {
254255
if (argConversions) {
255256
return `${async_}(${args}) => {
256257
${argConversions}
257-
return ${makeReturn64(body)};
258+
return ${makeReturn64(await_ + body)};
258259
}`;
259260
}
260-
return `${async_}(${args}) => ${makeReturn64(body)};`;
261+
return `${async_}(${args}) => ${makeReturn64(await_ + body)};`;
261262
}
262263
return `\
263264
${async_}function(${args}) {
264265
${argConversions}
265266
var ret = (() => { ${body} })();
266-
return ${makeReturn64('ret')};
267+
return ${makeReturn64(await_ + 'ret')};
267268
}`;
268269
}
269270

src/lib/libdylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ var LibraryDylink = {
11591159
#if ASYNCIFY
11601160
_dlopen_js__async: true,
11611161
#endif
1162-
_dlopen_js: (handle) => {
1162+
_dlopen_js: {{{ asyncIf(ASYNCIFY == 2) }}} (handle) => {
11631163
#if ASYNCIFY
11641164
return Asyncify.handleSleep((wakeUp) => {
11651165
dlopenInternal(handle, { loadAsync: true })

test/test_core.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,8 +3729,6 @@ def test_dlfcn_feature_in_lib(self):
37293729
@needs_dylink
37303730
@with_asyncify_and_jspi
37313731
def test_dlfcn_asyncify(self):
3732-
if self.is_wasm64() and self.get_setting('ASYNCIFY') == 2:
3733-
self.skipTest('https://github.com/emscripten-core/emscripten/issues/23585')
37343732
create_file('liblib.c', r'''
37353733
#include <stdio.h>
37363734
#include <emscripten/emscripten.h>

0 commit comments

Comments
 (0)