Skip to content

Commit 18fa2a3

Browse files
authored
Fix wasm table access when accessing functions in splitted module (#25432)
When accessing functions from the splitted module, there's an error because the wasmtable is using table64. So we would have to access it with a BigInt. This has been updated in other part of the codebase, but we missed this file.
1 parent 37cfd8c commit 18fa2a3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/preamble.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,9 @@ var splitModuleProxyHandler = {
503503
// When the table is dynamically laid out, the placeholder functions names
504504
// are offsets from the table base. In the main module, the table base is
505505
// always 1.
506-
return wasmTable.get(1 + parseInt(prop))(...args);
507-
#else
508-
return wasmTable.get(prop)(...args);
506+
prop = 1 + parseInt(prop);
509507
#endif
508+
return wasmTable.get({{{ toIndexType('prop') }}})(...args);
510509
#endif
511510
}
512511
}

test/test_other.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12816,6 +12816,7 @@ def test_syslog(self):
1281612816
def test_syscall_stubs(self):
1281712817
self.do_other_test('test_syscall_stubs.c')
1281812818

12819+
@also_with_wasm64
1281912820
@parameterized({
1282012821
'': (False, False, False),
1282112822
'custom': (True, False, False),
@@ -12848,6 +12849,8 @@ def test_split_module(self, customLoader, jspi, opt):
1284812849
'--export-prefix=%', 'test_split_module.wasm.orig', '-o1', 'primary.wasm', '-o2', 'secondary.wasm', '--profile=profile.data']
1284912850
if jspi:
1285012851
wasm_split_run += ['--jspi', '--enable-reference-types']
12852+
if self.get_setting('MEMORY64'):
12853+
wasm_split_run += ['--enable-memory64']
1285112854
self.run_process(wasm_split_run)
1285212855

1285312856
os.remove('test_split_module.wasm')

0 commit comments

Comments
 (0)