Skip to content

Commit dc14d80

Browse files
authored
Fix for wasm64 when DYNCALLS is enabled (#20394)
I noticed that test/browser/async.cpp was failing in wasm64 mode. This change fixes the failure, and also moves that test out of browser testing and into core testing.
1 parent a7877f0 commit dc14d80

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed
File renamed without changes.

test/core/test_asyncify_longjmp.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
first
2+
result: 1 1
3+
second
4+
result: 2 -1

test/test_browser.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,15 +3445,6 @@ def test_async_virtual_2(self):
34453445
print(opts)
34463446
self.btest_exit('async_virtual_2.cpp', args=['-O' + str(opts), '-sASSERTIONS', '-sSAFE_HEAP', '-profiling', '-sASYNCIFY'])
34473447

3448-
# Test async sleeps in the presence of invoke_* calls, which can happen with
3449-
# longjmp or exceptions.
3450-
@parameterized({
3451-
'O0': ([],), # noqa
3452-
'O3': (['-O3'],), # noqa
3453-
})
3454-
def test_async_longjmp(self, args):
3455-
self.btest_exit('async_longjmp.cpp', args=args + ['-sASYNCIFY'])
3456-
34573448
def test_async_mainloop(self):
34583449
for opts in [0, 3]:
34593450
print(opts)

test/test_core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8276,6 +8276,12 @@ def test_setlocale(self):
82768276
def test_vswprintf_utf8(self):
82778277
self.do_core_test('test_vswprintf_utf8.c')
82788278

8279+
# Test async sleeps in the presence of invoke_* calls, which can happen with
8280+
# longjmp or exceptions.
8281+
def test_asyncify_longjmp(self):
8282+
self.set_setting('ASYNCIFY')
8283+
self.do_core_test('test_asyncify_longjmp.c')
8284+
82798285
# Test that a main with arguments is automatically asyncified.
82808286
@with_asyncify_and_jspi
82818287
def test_async_main(self):

tools/js_manipulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def isidentifier(name):
108108

109109
def make_dynCall(sig, args):
110110
# wasm2c and asyncify are not yet compatible with direct wasm table calls
111+
if settings.MEMORY64:
112+
args = list(args)
113+
args[0] = f'Number({args[0]})'
111114
if settings.DYNCALLS or not is_legal_sig(sig):
112115
args = ','.join(args)
113116
if not settings.MAIN_MODULE and not settings.SIDE_MODULE:
@@ -117,11 +120,8 @@ def make_dynCall(sig, args):
117120
else:
118121
return 'Module["dynCall_%s"](%s)' % (sig, args)
119122
else:
120-
func_ptr = args[0]
121-
if settings.MEMORY64:
122-
func_ptr = f'Number({func_ptr})'
123123
call_args = ",".join(args[1:])
124-
return f'getWasmTableEntry({func_ptr})({call_args})'
124+
return f'getWasmTableEntry({args[0]})({call_args})'
125125

126126

127127
def make_invoke(sig):

0 commit comments

Comments
 (0)