@@ -1048,24 +1048,6 @@ def handle_pair(self, input, before_wasm, after_wasm, opts):
10481048 # with NaNs we can't compare the output, as a reinterpret through
10491049 # memory might end up different in JS than wasm
10501050 return
1051- # we also cannot compare if the wasm hits a trap, as wasm2js does not
1052- # trap on many things wasm would, and in those cases it can do weird
1053- # undefined things. in such a case, at least compare up until before
1054- # the trap, which lets us compare at least some results in some cases.
1055- # (this is why wasm2js is not in CompareVMs, which does full
1056- # comparisons - we need to limit the comparison in a special way here)
1057- interpreter = run_bynterp (before_wasm_temp , ['--fuzz-exec-before' ])
1058- if TRAP_PREFIX in interpreter :
1059- trap_index = interpreter .index (TRAP_PREFIX )
1060- # we can't test this function, which the trap is in the middle of.
1061- # erase everything from this function's output and onward, so we
1062- # only compare the previous trap-free code
1063- call_start = interpreter .rindex (FUZZ_EXEC_CALL_PREFIX , 0 , trap_index )
1064- call_end = interpreter .index ('\n ' , call_start )
1065- call_line = interpreter [call_start :call_end ]
1066- before = before [:before .index (call_line )]
1067- after = after [:after .index (call_line )]
1068- interpreter = interpreter [:interpreter .index (call_line )]
10691051
10701052 def fix_output_for_js (x ):
10711053 # start with the normal output fixes that all VMs need
@@ -1117,6 +1099,28 @@ def fix_number(x):
11171099
11181100 before = fix_output_for_js (before )
11191101 after = fix_output_for_js (after )
1102+
1103+ # we must not compare if the wasm hits a trap, as wasm2js does not
1104+ # trap on many things wasm would, and in those cases it can do weird
1105+ # undefined things. in such a case, at least compare up until before
1106+ # the trap, which lets us compare at least some results in some cases.
1107+ # (this is why wasm2js is not in CompareVMs, which does full
1108+ # comparisons - we need to limit the comparison in a special way here)
1109+ interpreter = run_bynterp (before_wasm_temp , ['--fuzz-exec-before' ])
1110+ if TRAP_PREFIX in interpreter :
1111+ trap_index = interpreter .index (TRAP_PREFIX )
1112+ # we can't test this function, which the trap is in the middle of.
1113+ # erase everything from this function's output and onward, so we
1114+ # only compare the previous trap-free code
1115+ call_start = interpreter .rindex (FUZZ_EXEC_CALL_PREFIX , 0 , trap_index )
1116+ call_end = interpreter .index ('\n ' , call_start )
1117+ call_line = interpreter [call_start :call_end ]
1118+ # fix up the call line so it matches the JS
1119+ fixed_call_line = fix_output_for_js (call_line )
1120+ before = before [:before .index (fixed_call_line )]
1121+ after = after [:after .index (fixed_call_line )]
1122+ interpreter = interpreter [:interpreter .index (call_line )]
1123+
11201124 if compare_before_to_after :
11211125 compare_between_vms (before , after , 'Wasm2JS (before/after)' )
11221126 if compare_to_interpreter :
0 commit comments