Skip to content

Commit 2e86518

Browse files
authored
PreserveImportsExportsJS fuzzer: Handle NaNs properly (#8620)
1. De-NaN when that setting is on. 2. Check if we can compare, which depends on NaNs.
1 parent 40acafe commit 2e86518

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/fuzz_opt.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,13 +2157,19 @@ def do_handle_pair(self, input, before_wasm, after_wasm, opts):
21572157

21582158
# Modify the initial wat to get the pre-optimizations wasm.
21592159
pre_wasm = abspath('pre.wasm')
2160-
run([in_bin('wasm-opt'), input] + FEATURE_OPTS + [
2160+
gen_args = [
2161+
input,
21612162
'-ttf',
21622163
'--fuzz-preserve-imports-exports',
21632164
'--initial-fuzz=' + wat_file,
21642165
'-o', pre_wasm,
21652166
'-g',
2166-
])
2167+
]
2168+
# We do not copy all of GEN_ARGS, as we don't need e.g. legalization.
2169+
if not NANS:
2170+
# TODO: do we also need this in each reduction step?
2171+
gen_args += ['--denan']
2172+
run([in_bin('wasm-opt')] + gen_args + FEATURE_OPTS)
21672173

21682174
# We successfully generated pre_wasm; stash it for possible reduction
21692175
# purposes later.
@@ -2206,8 +2212,9 @@ def do_handle_pair(self, input, before_wasm, after_wasm, opts):
22062212
post_vm = random.choice(vms)
22072213
post = self.do_run(post_vm, js_file, post_wasm)
22082214

2209-
# Compare
2210-
compare(pre, post, 'PreserveImportsExportsJS')
2215+
# Compare, if we can.
2216+
if pre_vm.can_compare_to_other(post_vm):
2217+
compare(pre, post, 'PreserveImportsExportsJS')
22112218

22122219
def do_run(self, vm, js, wasm):
22132220
out = vm.run_js(js, wasm, checked=False)

0 commit comments

Comments
 (0)