@@ -807,7 +807,7 @@ def can_run(self, wasm):
807
807
def can_compare_to_self (self ):
808
808
return True
809
809
810
- def can_compare_to_others (self ):
810
+ def can_compare_to_other (self , other ):
811
811
return True
812
812
813
813
class D8 :
@@ -828,12 +828,15 @@ def can_compare_to_self(self):
828
828
# can compare to themselves after opts in that case.
829
829
return not NANS
830
830
831
- def can_compare_to_others (self ):
831
+ def can_compare_to_other (self , other ):
832
+ # Relaxed SIMD allows different behavior between VMs, so only
833
+ # allow comparisons to other d8 variants if it is enabled.
834
+ if not all_disallowed (['relaxed-simd' ]) and not other .name .startswith ('d8' ):
835
+ return False
836
+
832
837
# If not legalized, the JS will fail immediately, so no point to
833
- # compare to others. Relaxed SIMD allows different behavior
834
- # between VMs (in principle we could compare to other D8
835
- # variants, though TODO).
836
- return self .can_compare_to_self () and LEGALIZE and all_disallowed (['relaxed-simd' ])
838
+ # compare to others.
839
+ return self .can_compare_to_self () and LEGALIZE
837
840
838
841
class D8Liftoff (D8 ):
839
842
name = 'd8_liftoff'
@@ -887,7 +890,7 @@ def can_compare_to_self(self):
887
890
# expects, but that's not quite what C has
888
891
return not NANS
889
892
890
- def can_compare_to_others (self ):
893
+ def can_compare_to_other (self , other ):
891
894
# C won't trap on OOB, and NaNs can differ from wasm VMs
892
895
return not OOB and not NANS
893
896
@@ -934,7 +937,7 @@ def can_run(self, wasm):
934
937
return super (Wasm2C2Wasm , self ).can_run (wasm ) and self .has_emcc and \
935
938
os .path .getsize (wasm ) <= INPUT_SIZE_MEAN
936
939
937
- def can_compare_to_others (self ):
940
+ def can_compare_to_other (self , other ):
938
941
# NaNs can differ from wasm VMs
939
942
return not NANS
940
943
@@ -962,10 +965,12 @@ def run_vms(self, wasm):
962
965
ignored_before = ignored_vm_runs
963
966
964
967
# vm_results will map vms to their results
968
+ relevant_vms = []
965
969
vm_results = {}
966
970
for vm in self .vms :
967
971
if vm .can_run (wasm ):
968
972
print (f'[CompareVMs] running { vm .name } ' )
973
+ relevant_vms .append (vm )
969
974
vm_results [vm ] = fix_output (vm .run (wasm ))
970
975
971
976
# If the binaryen interpreter hit a host limitation then do not
@@ -986,13 +991,13 @@ def run_vms(self, wasm):
986
991
return vm_results
987
992
988
993
# compare between the vms on this specific input
989
- first_vm = None
990
- for vm in vm_results . keys ( ):
991
- if vm . can_compare_to_others ( ):
992
- if first_vm is None :
993
- first_vm = vm
994
- else :
995
- compare_between_vms (vm_results [first_vm ], vm_results [vm ], 'CompareVMs between VMs: ' + first_vm .name + ' and ' + vm .name )
994
+ num_vms = len ( relevant_vms )
995
+ for i in range ( 0 , num_vms ):
996
+ for j in range ( i + 1 , num_vms ):
997
+ vm1 = relevant_vms [ i ]
998
+ vm2 = relevant_vms [ j ]
999
+ if vm1 . can_compare_to_other ( vm2 ) and vm2 . can_compare_to_other ( vm1 ) :
1000
+ compare_between_vms (vm_results [vm1 ], vm_results [vm2 ], 'CompareVMs between VMs: ' + vm1 .name + ' and ' + vm2 .name )
996
1001
997
1002
return vm_results
998
1003
0 commit comments