Skip to content

Enable WASM_BIGINT by default #19156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ee34a80
yolo
kripken Apr 10, 2023
5b5e426
make it work
kripken Apr 10, 2023
520301b
fix
kripken Apr 10, 2023
85793ac
fix closure
kripken Apr 11, 2023
22393a4
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Apr 11, 2023
9fe22ab
fix wasm2js
kripken Apr 11, 2023
e255dad
fix test
kripken Apr 11, 2023
e1108d6
fix
kripken Apr 11, 2023
314cf8a
fix
kripken Apr 11, 2023
a52372d
cleanup
kripken Apr 11, 2023
c64adf2
more
kripken Apr 11, 2023
e7259ed
fix
kripken Apr 11, 2023
09ea912
fixflake8
kripken Apr 11, 2023
6699531
work
kripken Apr 11, 2023
d907b0e
fix
kripken Apr 12, 2023
af838e7
fix
kripken Apr 12, 2023
9aac743
fix
kripken Apr 12, 2023
5142300
work
kripken Apr 12, 2023
71ca03a
feedback
kripken Apr 12, 2023
d23687e
update test
kripken Apr 13, 2023
83165d1
fix
kripken Apr 13, 2023
0fb2458
try to fix test_dyncall_specific
kripken Apr 13, 2023
08c7170
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Apr 13, 2023
d1e4aec
fix old node version handling in common.py (maybe)
kripken Apr 13, 2023
2ae89c5
fix
kripken Apr 13, 2023
3f3c561
fix
kripken Apr 13, 2023
bf566aa
fix
kripken Apr 14, 2023
9459701
fix
kripken Apr 14, 2023
8dbb1ae
more test workarounds
kripken Apr 14, 2023
b107f47
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Apr 14, 2023
6b71f83
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Apr 17, 2023
6973fea
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Apr 17, 2023
560120a
fix
kripken Apr 17, 2023
84836b2
fix
kripken Apr 17, 2023
356a840
Explain safari-bigint issue and set version to 15
kripken Apr 17, 2023
00aab91
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Jun 21, 2023
0ca6930
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Jun 21, 2023
5985cdd
fix
kripken Jun 21, 2023
8566684
fix
kripken Jun 21, 2023
c35d241
Merge remote-tracking branch 'origin/main' into safari.bigint
kripken Jun 22, 2023
b537cc7
fix
kripken Jun 22, 2023
339b323
fix
kripken Jun 22, 2023
400f01e
fix
kripken Jun 22, 2023
62366ca
clean
kripken Jun 22, 2023
2f8f82c
waka
kripken Jun 22, 2023
8eab1f5
fix
kripken Jun 22, 2023
c93f72f
comment
kripken Jun 22, 2023
568ee40
fix
kripken Jun 22, 2023
fe12dc0
flip
kripken Jun 22, 2023
a42cb9e
remove =1s
kripken Jun 22, 2023
4998ef6
merge [ci skip]
kripken Jun 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ jobs:
other.test_min_node_version
other.test_node_emscripten_num_logical_cores
core2.test_pthread_create
core2.test_i64_invoke_bigint
core2.test_i64_invoke
core2.test_sse2
core2.test_source_map
core2.test_exceptions_wasm
Expand Down
5 changes: 5 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,11 @@ def phase_linker_setup(options, state, newargs):
if settings.LZ4:
settings.EXPORTED_RUNTIME_METHODS += ['LZ4']

# WASM_BIGINT defaults to 1 when VMs support it, and when not using wasm2js
default_setting('WASM_BIGINT',
feature_matrix.caniuse(feature_matrix.Feature.JS_BIGINT_INTEGRATION) and \
not settings.WASM2JS)

if settings.PURE_WASI:
settings.STANDALONE_WASM = 1
settings.WASM_BIGINT = 1
Expand Down
6 changes: 6 additions & 0 deletions src/polyfill/bigint64array.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ if (typeof globalThis.BigInt64Array === "undefined") {
}

function createBigIntArrayShim(partsToBigInt) {
/**
* Closure thinks .set is not defined on Proxy objects for some reason. The
* error is on the line with proxy.set but we can only apply the
* suppression at the function level here.
* @suppress {missingProperties}
*/
function createBigInt64Array(array) {
if (typeof array === "number") {
array = new Uint32Array(2 * array);
Expand Down
6 changes: 3 additions & 3 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ var DYNCALLS = false;
// i64 is used. If WASM_BIGINT is present, the default minimum supported browser
// versions will be increased to the min version that supports BigInt.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last sentence should probably just be removed I think

// [link]
var WASM_BIGINT = false;
var WASM_BIGINT = true;

// WebAssembly defines a "producers section" which compilers and tools can
// annotate themselves in, and LLVM emits this by default.
Expand Down Expand Up @@ -1745,10 +1745,10 @@ var AUTO_NATIVE_LIBRARIES = true;
// versions >= MIN_FIREFOX_VERSION
// are desired to work. Pass -sMIN_FIREFOX_VERSION=majorVersion to drop support
// for Firefox versions older than < majorVersion.
// Firefox ESR 60.5 (Firefox 65) was released on 2019-01-29.
// Firefox ESR 68 was released on July 9, 2019.
// MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
// [link]
var MIN_FIREFOX_VERSION = 65;
var MIN_FIREFOX_VERSION = 68;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this to the ChangeLog, along with a note about bigint itself being enabled by default.


// Specifies the oldest version of desktop Safari to target. Version is encoded
// in MMmmVV, e.g. 70101 denotes Safari 7.1.1.
Expand Down
7 changes: 3 additions & 4 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,13 @@ def metafunc(self, with_bigint):
self.skipTest('wasm2js does not support WASM_BIGINT')
if self.get_setting('WASM_BIGINT') is not None:
self.skipTest('redundant in bigint test config')
self.set_setting('WASM_BIGINT')
self.node_args += shared.node_bigint_flags()
f(self)
else:
self.set_setting('WASM_BIGINT', '0')
f(self)

metafunc._parameterize = {'': (False,),
'bigint': (True,)}
metafunc._parameterize = {'no_bigint': (False,),
'': (True,)}
return metafunc


Expand Down
4 changes: 1 addition & 3 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2327,11 +2327,9 @@ def test_em_js(self, args, force_c):

@no_wasm2js('WASM_BIGINT is not compatible with wasm2js')
def test_em_js_i64(self):
err = self.expect_fail([EMCC, '-Werror', test_file('core/test_em_js_i64.c')])
err = self.expect_fail([EMCC, '-sWASM=0', '-Werror', test_file('core/test_em_js_i64.c')])
self.assertContained('emcc: error: using 64-bit arguments in EM_JS function without WASM_BIGINT is not yet fully supported: `foo`', err)

self.set_setting('WASM_BIGINT')
self.node_args += shared.node_bigint_flags()
self.do_core_test('test_em_js_i64.c')

def test_em_js_address_taken(self):
Expand Down
22 changes: 9 additions & 13 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -11091,19 +11091,18 @@ def ok(args, filename='hello_world.cpp', expected='hello, world!'):
args += ['-sERROR_ON_WASM_CHANGES_AFTER_LINK']
self.do_runf(test_file(filename), expected, emcc_args=args)

# -O0 with BigInt support (to avoid the need for legalization)
required_flags = ['-sWASM_BIGINT']
ok(required_flags)
# -O0 just works
ok([])
# Same with DWARF
ok(required_flags + ['-g'])
ok(['-g'])
# Function pointer calls from JS work too
ok(required_flags, filename='hello_world_main_loop.cpp')
ok([], filename='hello_world_main_loop.cpp')
# -O1 is ok as we don't run wasm-opt there (but no higher, see below)
ok(required_flags + ['-O1'])
ok(['-O1'])
# Exception support shouldn't require changes after linking
ok(required_flags + ['-fexceptions'])
ok(['-fexceptions'])
# Standalone mode should not do anything special to the wasm.
ok(required_flags + ['-sSTANDALONE_WASM'])
ok(['-sSTANDALONE_WASM'])

# other builds fail with a standard message + extra details
def fail(args, details):
Expand All @@ -11113,13 +11112,10 @@ def fail(args, details):
self.assertContained('changes to the wasm are required after link, but disallowed by ERROR_ON_WASM_CHANGES_AFTER_LINK', err)
self.assertContained(details, err)

# plain -O0
legalization_message = 'to disable int64 legalization (which requires changes after link) use -sWASM_BIGINT'
fail([], legalization_message)
# optimized builds even without legalization
optimization_message = '-O2+ optimizations always require changes, build with -O0 or -O1 instead'
fail(required_flags + ['-O2'], optimization_message)
fail(required_flags + ['-O3'], optimization_message)
fail(['-O2'], optimization_message)
fail(['-O3'], optimization_message)

@crossplatform
def test_output_to_nowhere(self):
Expand Down
3 changes: 2 additions & 1 deletion tools/feature_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class Feature(IntEnum):
Feature.JS_BIGINT_INTEGRATION: {
'chrome': 67,
'firefox': 68,
'safari': 150000,
# Note: Safari 14.1 shipped only in iOS 14.5, which can be confusing.
'safari': 140100,
},
Feature.THREADS: {
'chrome': 74,
Expand Down