@@ -117,6 +117,21 @@ def randomize_feature_opts():
117
117
print ('randomized feature opts:' , ' ' .join (FEATURE_OPTS ))
118
118
119
119
120
+ ALL_FEATURE_OPTS = ['--all-features' , '-all' , '--mvp-features' , '-mvp' ]
121
+
122
+
123
+ def update_feature_opts (wasm ):
124
+ global FEATURE_OPTS
125
+ # we will re-compute the features; leave all other things as they are
126
+ EXTRA = [x for x in FEATURE_OPTS if not x .startswith ('--enable' ) and
127
+ not x .startswith ('--disable' ) and x not in ALL_FEATURE_OPTS ]
128
+ FEATURE_OPTS = run ([in_bin ('wasm-opt' ), wasm ] + FEATURE_OPTS + ['--print-features' ]).strip ().split ('\n ' )
129
+ # filter out '', which can happen if no features are enabled
130
+ FEATURE_OPTS = [x for x in FEATURE_OPTS if x ]
131
+ print (FEATURE_OPTS , EXTRA )
132
+ FEATURE_OPTS += EXTRA
133
+
134
+
120
135
def randomize_fuzz_settings ():
121
136
# a list of the optimizations to run on the wasm
122
137
global FUZZ_OPTS
@@ -448,6 +463,10 @@ def run_d8_wasm(wasm, liftoff=True):
448
463
return run_d8_js (in_binaryen ('scripts' , 'fuzz_shell.js' ), [wasm ], liftoff = liftoff )
449
464
450
465
466
+ def all_disallowed (features ):
467
+ return not any (('--enable-' + x ) in FEATURE_OPTS for x in features )
468
+
469
+
451
470
class TestCaseHandler :
452
471
# how frequent this handler will be run. 1 means always run it, 0.5 means half the
453
472
# time
@@ -563,7 +582,7 @@ def can_run(self, wasm):
563
582
if random .random () < 0.5 :
564
583
return False
565
584
# wasm2c doesn't support most features
566
- 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- gc' ] ])
585
+ return all_disallowed ([ ' exception-handling' , 'simd' , 'threads' , 'bulk-memory' , 'nontrapping-float-to-int' , 'tail-call' , 'sign-ext' , 'reference-types' , 'multivalue' , 'gc' ])
567
586
568
587
def run (self , wasm ):
569
588
run ([in_bin ('wasm-opt' ), wasm , '--emit-wasm2c-wrapper=main.c' ] + FEATURE_OPTS )
@@ -667,7 +686,7 @@ def compare_before_and_after(self, before, after):
667
686
compare (before [vm ], after [vm ], 'CompareVMs between before and after: ' + vm .name )
668
687
669
688
def can_run_on_feature_opts (self , feature_opts ):
670
- return all ([ x in feature_opts for x in [ '--disable- simd' , '--disable- exception-handling' , '--disable- multivalue' ] ])
689
+ return all_disallowed ([ ' simd' , 'exception-handling' , 'multivalue' ])
671
690
672
691
673
692
# Check for determinism - the same command must have the same output.
@@ -805,7 +824,7 @@ def can_run_on_feature_opts(self, feature_opts):
805
824
# specifically for growth here
806
825
if INITIAL_CONTENTS :
807
826
return False
808
- 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- gc' ] ])
827
+ return all_disallowed ([ ' exception-handling' , 'simd' , 'threads' , 'bulk-memory' , 'nontrapping-float-to-int' , 'tail-call' , 'sign-ext' , 'reference-types' , 'multivalue' , 'gc' ])
809
828
810
829
811
830
class Asyncify (TestCaseHandler ):
@@ -859,7 +878,7 @@ def do_asyncify(wasm):
859
878
compare (before , after_asyncify , 'Asyncify (before/after_asyncify)' )
860
879
861
880
def can_run_on_feature_opts (self , feature_opts ):
862
- return all ([ x in feature_opts for x in [ '--disable- exception-handling' , '--disable- simd' , '--disable- tail-call' , '--disable- reference-types' , '--disable- multivalue' , '--disable- gc' ] ])
881
+ return all_disallowed ([ ' exception-handling' , 'simd' , 'tail-call' , 'reference-types' , 'multivalue' , 'gc' ])
863
882
864
883
865
884
# Check that the text format round-trips without error.
@@ -925,6 +944,7 @@ def test_one(random_input, given_wasm):
925
944
wasm_size = os .stat ('a.wasm' ).st_size
926
945
bytes = wasm_size
927
946
print ('pre wasm size:' , wasm_size )
947
+ update_feature_opts ('a.wasm' )
928
948
929
949
# create a second wasm for handlers that want to look at pairs.
930
950
generate_command = [in_bin ('wasm-opt' ), 'a.wasm' , '-o' , 'b.wasm' ] + opts + FUZZ_OPTS + FEATURE_OPTS
@@ -1043,10 +1063,10 @@ def randomize_opt_flags():
1043
1063
if has_flatten :
1044
1064
print ('avoiding multiple --flatten in a single command, due to exponential overhead' )
1045
1065
continue
1046
- if '--disable -exception-handling' not in FEATURE_OPTS :
1066
+ if '--enable -exception-handling' in FEATURE_OPTS :
1047
1067
print ('avoiding --flatten due to exception catching which does not support it yet' )
1048
1068
continue
1049
- if '--disable -multivalue' not in FEATURE_OPTS and '--disable -reference-types' not in FEATURE_OPTS :
1069
+ if '--enable -multivalue' in FEATURE_OPTS and '--enable -reference-types' in FEATURE_OPTS :
1050
1070
print ('avoiding --flatten due to multivalue + reference types not supporting it (spilling of non-nullable tuples)' )
1051
1071
continue
1052
1072
if '--gc' not in FEATURE_OPTS :
0 commit comments