Skip to content

Commit

Permalink
[EH] Rename Wasm EH tests (emscripten-core#23427)
Browse files Browse the repository at this point in the history
This renames Wasm EH test modes:
- `wasm` -> `wasm_legacy`
- `wasm_exnref` -> `wasm`

So `_wasm` suffix means the standardized Wasm EH, and `_wasm_legacy`
means the legacy EH. This also removes some comments mentioning things
like "new Wasm EH with exnref", given that this should be (eventually)
the default mode and not the new thing.
  • Loading branch information
aheejin authored Jan 17, 2025
1 parent 186cae3 commit bb16735
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ jobs:
core2.test_i64_invoke_bigint
core2.test_sse2
core2.test_source_map
core2.test_exceptions_wasm
core2.test_exceptions_wasm_legacy
core2.test_pthread_unhandledrejection"
- upload-test-results
test-other:
Expand Down
24 changes: 12 additions & 12 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,19 +625,19 @@ def metafunc(self, standalone):
return decorated


# Tests exception handling / setjmp/longjmp handling in Emscripten EH/SjLj mode
# and new wasm EH/SjLj modes. This tests three combinations:
# Tests exception handling and setjmp/longjmp handling. This tests three
# combinations:
# - Emscripten EH + Emscripten SjLj
# - Wasm EH + Wasm SjLj (Phase 3, to be deprecated)
# - Wasm EH + Wasm SjLj (New proposal witn exnref, experimental)
# - Wasm EH + Wasm SjLj
# - Wasm EH + Wasm SjLj (Legacy)
def with_all_eh_sjlj(f):
assert callable(f)

@wraps(f)
def metafunc(self, mode, *args, **kwargs):
if DEBUG:
print('parameterize:eh_mode=%s' % mode)
if mode in {'wasm', 'wasm_exnref'}:
if mode in {'wasm', 'wasm_legacy'}:
# Wasm EH is currently supported only in wasm backend and V8
if self.is_wasm2js():
self.skipTest('wasm2js does not support wasm EH/SjLj')
Expand All @@ -647,9 +647,9 @@ def metafunc(self, mode, *args, **kwargs):
self.emcc_args.append('-fwasm-exceptions')
self.set_setting('SUPPORT_LONGJMP', 'wasm')
if mode == 'wasm':
self.require_wasm_legacy_eh()
if mode == 'wasm_exnref':
self.require_wasm_eh()
if mode == 'wasm_legacy':
self.require_wasm_legacy_eh()
f(self, *args, **kwargs)
else:
self.set_setting('DISABLE_EXCEPTION_CATCHING', 0)
Expand All @@ -663,7 +663,7 @@ def metafunc(self, mode, *args, **kwargs):

parameterize(metafunc, {'emscripten': ('emscripten',),
'wasm': ('wasm',),
'wasm_exnref': ('wasm_exnref',)})
'wasm_legacy': ('wasm_legacy',)})
return metafunc


Expand All @@ -674,25 +674,25 @@ def with_all_sjlj(f):

@wraps(f)
def metafunc(self, mode, *args, **kwargs):
if mode in {'wasm', 'wasm_exnref'}:
if mode in {'wasm', 'wasm_legacy'}:
if self.is_wasm2js():
self.skipTest('wasm2js does not support wasm SjLj')
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
if '-fsanitize=address' in self.emcc_args:
self.skipTest('Wasm EH does not work with asan yet')
self.set_setting('SUPPORT_LONGJMP', 'wasm')
if mode == 'wasm':
self.require_wasm_legacy_eh()
if mode == 'wasm_exnref':
self.require_wasm_eh()
if mode == 'wasm_legacy':
self.require_wasm_legacy_eh()
f(self, *args, **kwargs)
else:
self.set_setting('SUPPORT_LONGJMP', 'emscripten')
f(self, *args, **kwargs)

parameterize(metafunc, {'emscripten': ('emscripten',),
'wasm': ('wasm',),
'wasm_exnref': ('wasm_exnref',)})
'wasm_legacy': ('wasm_legacy',)})
return metafunc


Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
142162
144708

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
142162
23 changes: 9 additions & 14 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,10 @@ def test_longjmp_with_and_without_exceptions(self):
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
if '-fsanitize=address' in self.emcc_args:
self.skipTest('Wasm EH does not work with asan yet')
self.emcc_args.append('-fwasm-exceptions')
for arg in ('-fwasm-exceptions', '-fno-exceptions'):
self.do_core_test('test_longjmp.c', emcc_args=[arg])
# Wasm SjLj with and with the standardized EH (exnref) support
self.set_setting('WASM_LEGACY_EXCEPTIONS', 0)
self.do_core_test('test_longjmp.c', emcc_args=['-fwasm-exceptions'])
for legacy in [0, 1]:
self.set_setting('WASM_LEGACY_EXCEPTIONS', legacy)
for arg in ('-fwasm-exceptions', '-fno-exceptions'):
self.do_core_test('test_longjmp.c', emcc_args=[arg])

@with_all_sjlj
def test_longjmp2(self):
Expand Down Expand Up @@ -1011,14 +1009,11 @@ def test_exceptions_with_and_without_longjmp(self):
if '-fsanitize=address' in self.emcc_args:
self.skipTest('Wasm EH does not work with asan yet')
self.emcc_args.append('-fwasm-exceptions')
for support_longjmp in (0, 'wasm'):
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
# Wasm standardized EH (exnref) with and without Wasm SjLj support
self.set_setting('WASM_LEGACY_EXCEPTIONS', 0)
for support_longjmp in (0, 'wasm'):
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
for legacy in [0, 1]:
self.set_setting('WASM_LEGACY_EXCEPTIONS', legacy)
for support_longjmp in (0, 'wasm'):
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')

def test_exceptions_off(self):
self.set_setting('DISABLE_EXCEPTION_CATCHING')
Expand Down
30 changes: 14 additions & 16 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3536,10 +3536,10 @@ def test_embind_tsgen_jspi(self):

@parameterized({
'': [0],
'wasm_exnref': [1]
'legacy': [1]
})
def test_embind_tsgen_exceptions(self, wasm_exnref):
self.set_setting('WASM_LEGACY_EXCEPTIONS', wasm_exnref == 1)
def test_embind_tsgen_exceptions(self, legacy):
self.set_setting('WASM_LEGACY_EXCEPTIONS', legacy)
# Check that when Wasm exceptions and assertions are enabled bindings still generate.
self.run_process([EMXX, test_file('other/embind_tsgen.cpp'),
'-lembind', '-fwasm-exceptions', '-sASSERTIONS',
Expand Down Expand Up @@ -8950,8 +8950,8 @@ def test_codesize_minimal_pthreads(self):
'mangle': (['-O2', '-fexceptions',
'-sDEMANGLE_SUPPORT', '-Wno-deprecated'], [], ['waka']), # noqa
# Wasm EH's code size increase is smaller than that of Emscripten EH
'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'], [], ['waka']),
'except_wasm_exnref': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'], [], ['waka']),
'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'], [], ['waka']),
'except_wasm_legacy': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'], [], ['waka']),
# eval_ctors 1 can partially optimize, but runs into getenv() for locale
# code. mode 2 ignores those and fully optimizes out the ctors
'ctors1': (['-O2', '-sEVAL_CTORS'], [], ['waka']),
Expand Down Expand Up @@ -9251,9 +9251,9 @@ def test_lto(self, args):

@parameterized({
'noexcept': [],
'except': ['-sDISABLE_EXCEPTION_CATCHING=0'],
'except_wasm': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],
'except_wasm_exnref': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0']
'except_emscripten': ['-sDISABLE_EXCEPTION_CATCHING=0'],
'except_wasm': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'],
'except_wasm_legacy': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS']
})
def test_lto_libcxx(self, *args):
self.run_process([EMXX, test_file('hello_libcxx.cpp'), '-flto'] + list(args))
Expand All @@ -9275,12 +9275,11 @@ def test_lto_flags(self):
@requires_wasm_eh
def test_lto_wasm_exceptions(self):
self.set_setting('EXCEPTION_DEBUG')
self.set_setting('WASM_LEGACY_EXCEPTIONS')
self.emcc_args += ['-fwasm-exceptions', '-flto']
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
# New Wasm EH with exnref
self.set_setting('WASM_LEGACY_EXCEPTIONS', 0)
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
self.set_setting('WASM_LEGACY_EXCEPTIONS')
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')

@parameterized({
'': ([],),
Expand Down Expand Up @@ -12794,11 +12793,10 @@ def test_standalone_wasm_exceptions(self):
self.set_setting('WASM_BIGINT')
self.wasm_engines = []
self.emcc_args += ['-fwasm-exceptions']
self.set_setting('WASM_LEGACY_EXCEPTIONS')
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
# New Wasm EH with exnref
self.set_setting('WASM_LEGACY_EXCEPTIONS', 0)
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
self.set_setting('WASM_LEGACY_EXCEPTIONS')
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')

def test_missing_malloc_export(self):
# we used to include malloc by default. show a clear error in builds with
Expand Down Expand Up @@ -15328,8 +15326,8 @@ def test_SUPPORT_BIG_ENDIAN(self):
'noexcept': ['-fno-exceptions'],
'default': [],
'except': ['-sDISABLE_EXCEPTION_CATCHING=0'],
'except_wasm': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],
'except_wasm_exnref': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0']
'except_wasm': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'],
'except_wasm_legacy': ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS']
})
def test_std_promise_link(self, *args):
# Regression test for a bug where std::promise's destructor caused a link
Expand Down
2 changes: 1 addition & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def check_human_readable_list(items):
extras = settings.BINARYEN_EXTRA_PASSES.split(',')
passes += [('--' + p) if p[0] != '-' else p for p in extras if p]

# Run the translator to the new standardized EH instructions with exnref
# Run the translator to the standardized EH instructions.
if not settings.WASM_LEGACY_EXCEPTIONS:
passes += ['--emit-exnref']

Expand Down

0 comments on commit bb16735

Please sign in to comment.