Skip to content

Commit 9eaa392

Browse files
committed
[WIP] Enable WASM_BIGINT by default
Enables by default by temporarily reducing required Safari version. Also includes bugfixes for WASM_BIGINT compatibility.
1 parent b3edd4c commit 9eaa392

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

src/library_wasmfs_jsimpl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ addToLibrary({
5353
return wasmFS$backends[backend].getSize(file);
5454
},
5555

56+
_wasmfs_jsimpl_set_size__i53abi: true,
5657
_wasmfs_jsimpl_set_size: (backend, file, size) => {
5758
#if ASSERTIONS
5859
assert(wasmFS$backends[backend]);

src/shell.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {
4949
#include "polyfill/objassign.js"
5050
#endif
5151

52-
#if WASM_BIGINT && MIN_SAFARI_VERSION < 150000
52+
#if WASM_BIGINT && MIN_SAFARI_VERSION < 140100
53+
// TODO: Fix this back to 150000
5354
// See https://caniuse.com/mdn-javascript_builtins_bigint64array
5455
#include "polyfill/bigint64array.js"
5556
#endif

test/test_core.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,10 +1954,8 @@ def test_em_js(self, args, force_c):
19541954

19551955
@no_wasm2js('WASM_BIGINT is not compatible with wasm2js')
19561956
def test_em_js_i64(self):
1957-
err = self.expect_fail([EMCC, '-Werror', test_file('core/test_em_js_i64.c')])
1957+
err = self.expect_fail([EMCC, '-Werror', '-sWASM_BIGINT=0', test_file('core/test_em_js_i64.c')])
19581958
self.assertContained('emcc: error: using 64-bit arguments in EM_JS function without WASM_BIGINT is not yet fully supported: `foo`', err)
1959-
1960-
self.set_setting('WASM_BIGINT')
19611959
self.node_args += shared.node_bigint_flags(self.get_nodejs())
19621960
self.do_core_test('test_em_js_i64.c')
19631961

@@ -6995,11 +6993,10 @@ def test_EXPORTED_RUNTIME_METHODS(self):
69956993
def test_dyncall_specific(self, *args):
69966994
if self.get_setting('MEMORY64'):
69976995
self.skipTest('not compatible with MEMORY64')
6998-
if self.get_setting('WASM_BIGINT'):
6999-
# define DYNCALLS because this test does test calling them directly, and
7000-
# in WASM_BIGINT mode we do not enable them by default (since we can do
7001-
# more without them - we don't need to legalize)
7002-
args = list(args) + ['-sDYNCALLS', '-DWASM_BIGINT']
6996+
# define DYNCALLS because this test does test calling them directly, and
6997+
# in WASM_BIGINT mode we do not enable them by default (since we can do
6998+
# more without them - we don't need to legalize)
6999+
args = list(args) + ['-sDYNCALLS', '-DWASM_BIGINT']
70037000
cases = [
70047001
('DIRECT', []),
70057002
('DYNAMIC_SIG', ['-sDYNCALLS']),
@@ -8417,6 +8414,7 @@ def test_wasm2js(self):
84178414
if self.is_wasm2js():
84188415
self.skipTest('redundant to test wasm2js in wasm2js* mode')
84198416
self.set_setting('WASM', 0)
8417+
self.set_setting('WASM_BIGINT', 0)
84208418
self.do_core_test('test_hello_world.c')
84218419
self.assertNotExists('test_hello_world.js.mem')
84228420

@@ -8448,7 +8446,7 @@ def test_wasm2js_fallback(self, args):
84488446
if self.is_wasm2js():
84498447
self.skipTest('redundant to test wasm2js in wasm2js* mode')
84508448

8451-
cmd = [EMCC, test_file('small_hello_world.c'), '-sWASM=2'] + args
8449+
cmd = [EMCC, test_file('small_hello_world.c'), '-sWASM=2', '-sWASM_BIGINT=0'] + args
84528450
self.run_process(cmd)
84538451

84548452
# First run with WebAssembly support enabled

test/test_other.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8197,15 +8197,15 @@ def test_memory_growth_noasm(self):
81978197
assert 'use asm' not in src
81988198

81998199
def test_EM_ASM_i64(self):
8200+
self.do_other_test('test_em_asm_i64.cpp')
8201+
self.do_other_test('test_em_asm_i64.cpp', force_c=True)
8202+
8203+
self.set_setting('WASM_BIGINT', 0)
82008204
expected = 'Invalid character 106("j") in readEmAsmArgs!'
82018205
self.do_runf('other/test_em_asm_i64.cpp',
82028206
expected_output=expected,
82038207
assert_returncode=NON_ZERO)
82048208

8205-
self.set_setting('WASM_BIGINT')
8206-
self.do_other_test('test_em_asm_i64.cpp')
8207-
self.do_other_test('test_em_asm_i64.cpp', force_c=True)
8208-
82098209
def test_eval_ctor_ordering(self):
82108210
# ensure order of execution remains correct, even with a bad ctor
82118211
def test(p1, p2, p3, last, expected):
@@ -12373,6 +12373,7 @@ def fail(args, details):
1237312373
# plain -O0
1237412374
legalization_message = 'to disable int64 legalization (which requires changes after link) use -sWASM_BIGINT'
1237512375
fail([], legalization_message)
12376+
fail(['-sMIN_SAFARI_VERSION=140100'], legalization_message)
1237612377
# optimized builds even without legalization
1237712378
optimization_message = '-O2+ optimizations always require changes, build with -O0 or -O1 instead'
1237812379
fail(required_flags + ['-O2'], optimization_message)

tools/feature_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Feature(IntEnum):
6666
Feature.JS_BIGINT_INTEGRATION: {
6767
'chrome': 67,
6868
'firefox': 68,
69-
'safari': 150000,
69+
'safari': 140100,
7070
},
7171
Feature.THREADS: {
7272
'chrome': 74,

tools/link.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,10 @@ def phase_linker_setup(options, state, newargs):
786786
# to js.
787787
settings.WASM = 1
788788
settings.WASM2JS = 1
789+
# Wasm bigint doesn't make sense with wasm2js, since it controls how the
790+
# wasm and JS interact.
791+
settings.WASM_BIGINT = 0
792+
feature_matrix.disable_feature(feature_matrix.Feature.JS_BIGINT_INTEGRATION)
789793
if settings.WASM == 2:
790794
# Requesting both Wasm and Wasm2JS support
791795
settings.WASM2JS = 1
@@ -1386,6 +1390,8 @@ def phase_linker_setup(options, state, newargs):
13861390
settings.SUPPORTS_PROMISE_ANY = feature_matrix.caniuse(feature_matrix.Feature.PROMISE_ANY)
13871391
if not settings.BULK_MEMORY:
13881392
settings.BULK_MEMORY = feature_matrix.caniuse(feature_matrix.Feature.BULK_MEMORY)
1393+
if 'WASM_BIGINT' not in user_settings:
1394+
settings.WASM_BIGINT = feature_matrix.caniuse(feature_matrix.Feature.JS_BIGINT_INTEGRATION)
13891395

13901396
if settings.AUDIO_WORKLET:
13911397
if settings.AUDIO_WORKLET == 1:

0 commit comments

Comments
 (0)