diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-11 03:04:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 18:04:17 -0700 |
commit | 192757772adce7568fc1f3f3e733a4263b6392c6 (patch) | |
tree | 922fec8709cf9008d239a1fcbce7280e6ab46deb /scripts/fuzz_opt.py | |
parent | cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595 (diff) | |
download | binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.gz binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.bz2 binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.zip |
Add anyref feature and type (#3109)
Adds `anyref` type, which is enabled by a new feature `--enable-anyref`. This type is primarily used for testing that passes correctly handle subtype relationships so that the codebase will continue to be prepared for future subtyping. Since `--enable-anyref` is meaningless without also using `--enable-reference-types`, this PR also makes it a validation error to pass only the former (and similarly makes it a validation error to enable exception handling without enabling reference types).
Diffstat (limited to 'scripts/fuzz_opt.py')
-rwxr-xr-x | scripts/fuzz_opt.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index bf1f7f409..4df552b99 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -111,6 +111,8 @@ def randomize_feature_opts(): for possible in POSSIBLE_FEATURE_OPTS: if random.random() < 0.5: FEATURE_OPTS.append(possible) + if possible in IMPLIED_FEATURE_OPTS: + FEATURE_OPTS.extend(IMPLIED_FEATURE_OPTS[possible]) print('randomized feature opts:', ' '.join(FEATURE_OPTS)) @@ -402,7 +404,7 @@ class CompareVMs(TestCaseHandler): if random.random() < 0.5: return False # wasm2c doesn't support most features - return all([x in FEATURE_OPTS for x in ['--disable-exception-handling', '--disable-simd', '--disable-threads', '--disable-bulk-memory', '--disable-nontrapping-float-to-int', '--disable-tail-call', '--disable-sign-ext', '--disable-reference-types', '--disable-multivalue']]) + return all([x in FEATURE_OPTS for x in ['--disable-exception-handling', '--disable-simd', '--disable-threads', '--disable-bulk-memory', '--disable-nontrapping-float-to-int', '--disable-tail-call', '--disable-sign-ext', '--disable-reference-types', '--disable-multivalue', '--disable-anyref']]) def run(self, wasm): run([in_bin('wasm-opt'), wasm, '--emit-wasm2c-wrapper=main.c'] + FEATURE_OPTS) @@ -502,7 +504,7 @@ class CompareVMs(TestCaseHandler): compare(before[vm], after[vm], 'CompareVMs between before and after: ' + vm.name) def can_run_on_feature_opts(self, feature_opts): - return all([x in feature_opts for x in ['--disable-simd', '--disable-reference-types', '--disable-exception-handling', '--disable-multivalue']]) + return all([x in feature_opts for x in ['--disable-simd', '--disable-reference-types', '--disable-exception-handling', '--disable-multivalue', '--disable-anyref']]) # Check for determinism - the same command must have the same output. @@ -633,7 +635,7 @@ class Wasm2JS(TestCaseHandler): return run_vm([shared.NODEJS, js_file, 'a.wasm']) def can_run_on_feature_opts(self, feature_opts): - return all([x in feature_opts for x in ['--disable-exception-handling', '--disable-simd', '--disable-threads', '--disable-bulk-memory', '--disable-nontrapping-float-to-int', '--disable-tail-call', '--disable-sign-ext', '--disable-reference-types', '--disable-multivalue']]) + return all([x in feature_opts for x in ['--disable-exception-handling', '--disable-simd', '--disable-threads', '--disable-bulk-memory', '--disable-nontrapping-float-to-int', '--disable-tail-call', '--disable-sign-ext', '--disable-reference-types', '--disable-multivalue', '--disable-anyref']]) class Asyncify(TestCaseHandler): @@ -687,7 +689,7 @@ class Asyncify(TestCaseHandler): compare(before, after_asyncify, 'Asyncify (before/after_asyncify)') def can_run_on_feature_opts(self, feature_opts): - return all([x in feature_opts for x in ['--disable-exception-handling', '--disable-simd', '--disable-tail-call', '--disable-reference-types', '--disable-multivalue']]) + return all([x in feature_opts for x in ['--disable-exception-handling', '--disable-simd', '--disable-tail-call', '--disable-reference-types', '--disable-multivalue', '--disable-anyref']]) # The global list of all test case handlers @@ -870,6 +872,12 @@ def randomize_opt_flags(): POSSIBLE_FEATURE_OPTS = run([in_bin('wasm-opt'), '--print-features', in_binaryen('test', 'hello_world.wat')] + CONSTANT_FEATURE_OPTS).replace('--enable', '--disable').strip().split('\n') print('POSSIBLE_FEATURE_OPTS:', POSSIBLE_FEATURE_OPTS) +# some features depend on other features, so if a required feature is +# disabled, its dependent features need to be disabled as well. +IMPLIED_FEATURE_OPTS = { + '--disable-reference-types': ['--disable-exception-handling', '--disable-anyref'] +} + if __name__ == '__main__': # if we are given a seed, run exactly that one testcase. otherwise, # run new ones until we fail |