Skip to content

Commit f64d865

Browse files
authored
Explicitly test JSPI version of dlopen. NFC (#19566)
1 parent 3113ff0 commit f64d865

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/library_dylink.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,12 @@ var LibraryDylink = {
10991099
_dlopen_js: function(handle) {
11001100
#if ASYNCIFY
11011101
return Asyncify.handleSleep((wakeUp) => {
1102-
var jsflags = { loadAsync: true }
1103-
var promise = dlopenInternal(handle, jsflags);
1104-
promise.then(wakeUp).catch(() => wakeUp(0));
1102+
dlopenInternal(handle, { loadAsync: true })
1103+
.then(wakeUp)
1104+
.catch(() => wakeUp(0));
11051105
});
11061106
#else
1107-
var jsflags = { loadAsync: false }
1108-
return dlopenInternal(handle, jsflags);
1107+
return dlopenInternal(handle, { loadAsync: false });
11091108
#endif
11101109
},
11111110

@@ -1125,8 +1124,7 @@ var LibraryDylink = {
11251124
}
11261125

11271126
{{{ runtimeKeepalivePush() }}}
1128-
var jsflags = { loadAsync: true }
1129-
var promise = dlopenInternal(handle, jsflags);
1127+
var promise = dlopenInternal(handle, { loadAsync: true });
11301128
if (promise) {
11311129
promise.then(successCallback, errorCallback);
11321130
} else {

test/test_other.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6644,16 +6644,25 @@ def test_dlopen_promise(self):
66446644
self.set_setting('EXIT_RUNTIME')
66456645
self.do_other_test('test_dlopen_promise.c')
66466646

6647-
def test_dlopen_blocking(self):
6647+
@parameterized({
6648+
# Under node this should work even without ASYNCIFY because we can do
6649+
# synchronous loading via readBinary
6650+
'': (0,),
6651+
'asyncify': (1,),
6652+
'jspi': (2,),
6653+
})
6654+
def test_dlopen_blocking(self, asyncify):
66486655
self.run_process([EMCC, test_file('other/test_dlopen_blocking_side.c'), '-o', 'libside.so', '-sSIDE_MODULE'])
66496656
self.set_setting('MAIN_MODULE', 2)
66506657
self.set_setting('EXIT_RUNTIME')
66516658
self.set_setting('NO_AUTOLOAD_DYLIBS')
6659+
if asyncify:
6660+
self.set_setting('ASYNCIFY', asyncify)
6661+
if asyncify == 2:
6662+
self.emcc_args.append('-Wno-experimental')
6663+
self.require_v8()
6664+
self.v8_args.append('--experimental-wasm-stack-switching')
66526665
self.emcc_args.append('libside.so')
6653-
# Under node this should work both with and without ASYNCIFY
6654-
# because we can do synchronous readBinary
6655-
self.do_other_test('test_dlopen_blocking.c')
6656-
self.set_setting('ASYNCIFY')
66576666
self.do_other_test('test_dlopen_blocking.c')
66586667

66596668
def test_dlsym_rtld_default(self):

0 commit comments

Comments
 (0)