From 8a1d39e2dd5cc1623ec58b84cb6c4e29386917d8 Mon Sep 17 00:00:00 2001 From: Benjamin Ling Date: Tue, 30 Sep 2025 23:15:08 +0800 Subject: [PATCH 1/5] Fix wasm table access We can use the `toIndexType` utility function to access the wasm table --- src/preamble.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index fb8954566aa82..b853a47623b02 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -503,9 +503,9 @@ var splitModuleProxyHandler = { // When the table is dynamically laid out, the placeholder functions names // are offsets from the table base. In the main module, the table base is // always 1. - return wasmTable.get(1 + parseInt(prop))(...args); + return wasmTable.get(toIndexType(1 + parseInt(prop)))(...args); #else - return wasmTable.get(prop)(...args); + return wasmTable.get(toIndexType(prop))(...args); #endif #endif } From 5269096489a09428ada8ee7bdbab49bb0cb6baff Mon Sep 17 00:00:00 2001 From: Benjamin Ling Date: Tue, 30 Sep 2025 23:46:52 +0800 Subject: [PATCH 2/5] Combine logic to have a single return statement Changes from comments --- src/preamble.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index b853a47623b02..9b62b72c77645 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -503,10 +503,9 @@ var splitModuleProxyHandler = { // When the table is dynamically laid out, the placeholder functions names // are offsets from the table base. In the main module, the table base is // always 1. - return wasmTable.get(toIndexType(1 + parseInt(prop)))(...args); -#else - return wasmTable.get(toIndexType(prop))(...args); + prop = 1 + parseInt(prop) #endif + return wasmTable.get({{{ toIndexType('prop') }}})(...args); #endif } } From a01c9311f9546452837b5b788bf2ee5a100b5c8e Mon Sep 17 00:00:00 2001 From: Benjamin Ling Date: Tue, 30 Sep 2025 23:59:48 +0800 Subject: [PATCH 3/5] Add missing semi colon --- src/preamble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preamble.js b/src/preamble.js index 9b62b72c77645..eb885e27c21a8 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -503,7 +503,7 @@ var splitModuleProxyHandler = { // When the table is dynamically laid out, the placeholder functions names // are offsets from the table base. In the main module, the table base is // always 1. - prop = 1 + parseInt(prop) + prop = 1 + parseInt(prop); #endif return wasmTable.get({{{ toIndexType('prop') }}})(...args); #endif From b2166dace62c10ec0771f27cfd67a642ac9700c4 Mon Sep 17 00:00:00 2001 From: Benjamin Ling Date: Wed, 8 Oct 2025 17:04:17 +0800 Subject: [PATCH 4/5] update test_split_module to run wasm64 --- test/test_other.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_other.py b/test/test_other.py index 884b610d0a0a8..c74f02593aa25 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12816,6 +12816,7 @@ def test_syslog(self): def test_syscall_stubs(self): self.do_other_test('test_syscall_stubs.c') + @also_with_wasm64 @parameterized({ '': (False, False, False), 'custom': (True, False, False), From 813007e8dbac7c96c2194e06ea0267c5c5d437d9 Mon Sep 17 00:00:00 2001 From: Ben Ling Date: Wed, 8 Oct 2025 23:22:19 +0800 Subject: [PATCH 5/5] Add in memory64 flag during splitting in tests --- test/test_other.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_other.py b/test/test_other.py index f324b4407ee21..a4105d8185cad 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12849,6 +12849,8 @@ def test_split_module(self, customLoader, jspi, opt): '--export-prefix=%', 'test_split_module.wasm.orig', '-o1', 'primary.wasm', '-o2', 'secondary.wasm', '--profile=profile.data'] if jspi: wasm_split_run += ['--jspi', '--enable-reference-types'] + if self.get_setting('MEMORY64'): + wasm_split_run += ['--enable-memory64'] self.run_process(wasm_split_run) os.remove('test_split_module.wasm')