Skip to content

Commit 91641db

Browse files
authored
[Wasm64] Fix argv handling for >4GB memories (#20070)
The old code was using a shift operator to convert pointers to typed array indexes which does not work for values over 2**32. Instead we can use the `makeSetValue` helper macros which either use shifting or division.
1 parent 91be1cf commit 91641db

File tree

7 files changed

+10
-7
lines changed

7 files changed

+10
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ jobs:
618618
wasm64
619619
wasm64_4gb.test_hello_world
620620
wasm64_4gb.test_em_asm
621+
wasm64_4gb.test_async_main
621622
core_2gb.test_em_asm
622623
wasm64l.test_bigswitch
623624
other.test_memory64_proxies

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@ def phase_linker_setup(options, state, newargs):
24212421
settings.EXPORT_IF_DEFINED.append('__wasm_apply_data_relocs')
24222422

24232423
if settings.SIDE_MODULE and 'GLOBAL_BASE' in user_settings:
2424-
exit_with_error('GLOBAL_BASE is not compatible with SIDE_MODULE')
2424+
diagnostics.warning('unused-command-line-argument', 'GLOBAL_BASE is not compatible with SIDE_MODULE')
24252425

24262426
if settings.PROXY_TO_WORKER or options.use_preload_plugins:
24272427
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$Browser']

src/postamble.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ function callMain() {
7474

7575
var argc = args.length;
7676
var argv = stackAlloc((argc + 1) * {{{ POINTER_SIZE }}});
77-
var argv_ptr = argv >> {{{ POINTER_SHIFT }}};
77+
var argv_ptr = argv;
7878
args.forEach((arg) => {
79-
{{{ POINTER_HEAP }}}[argv_ptr++] = {{{ to64('stringToUTF8OnStack(arg)') }}};
79+
{{{ makeSetValue('argv_ptr', 0, 'stringToUTF8OnStack(arg)', '*') }}};
80+
argv_ptr += {{{ POINTER_SIZE }}};
8081
});
81-
{{{ POINTER_HEAP }}}[argv_ptr] = {{{ to64('0') }}};
82+
{{{ makeSetValue('argv_ptr', 0, 0, '*') }}};
8283
#else
8384
var argc = 0;
8485
var argv = 0;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14822
1+
14820
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5774
1+
5780
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6094
1+
6100

test/runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
'ubsan',
7070
'wasm64',
7171
'wasm64_v8',
72+
'wasm64_4gb',
7273
]
7374

7475
# The default core test mode, used when none is specified

0 commit comments

Comments
 (0)