@@ -970,6 +970,8 @@ void FunctionValidator::visitSIMDShift(SIMDShift* curr) {
970
970
}
971
971
972
972
void FunctionValidator::visitMemoryInit (MemoryInit* curr) {
973
+ shouldBeTrue (
974
+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
973
975
shouldBeTrue (getModule ()->features .hasBulkMemory (),
974
976
curr,
975
977
" Bulk memory operation (bulk memory is disabled)" );
@@ -981,33 +983,27 @@ void FunctionValidator::visitMemoryInit(MemoryInit* curr) {
981
983
curr->offset ->type , i32, curr, " memory.init offset must be an i32" );
982
984
shouldBeEqualOrFirstIsUnreachable (
983
985
curr->size ->type , i32, curr, " memory.init size must be an i32" );
984
- if (!shouldBeTrue (getModule ()->memory .exists ,
985
- curr,
986
- " Memory operations require a memory" )) {
987
- return ;
988
- }
989
986
shouldBeTrue (curr->segment < getModule ()->memory .segments .size (),
990
987
curr,
991
988
" memory.init segment index out of bounds" );
992
989
}
993
990
994
991
void FunctionValidator::visitDataDrop (DataDrop* curr) {
992
+ shouldBeTrue (
993
+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
995
994
shouldBeTrue (getModule ()->features .hasBulkMemory (),
996
995
curr,
997
996
" Bulk memory operation (bulk memory is disabled)" );
998
997
shouldBeEqualOrFirstIsUnreachable (
999
998
curr->type , none, curr, " data.drop must have type none" );
1000
- if (!shouldBeTrue (getModule ()->memory .exists ,
1001
- curr,
1002
- " Memory operations require a memory" )) {
1003
- return ;
1004
- }
1005
999
shouldBeTrue (curr->segment < getModule ()->memory .segments .size (),
1006
1000
curr,
1007
1001
" data.drop segment index out of bounds" );
1008
1002
}
1009
1003
1010
1004
void FunctionValidator::visitMemoryCopy (MemoryCopy* curr) {
1005
+ shouldBeTrue (
1006
+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
1011
1007
shouldBeTrue (getModule ()->features .hasBulkMemory (),
1012
1008
curr,
1013
1009
" Bulk memory operation (bulk memory is disabled)" );
@@ -1019,11 +1015,11 @@ void FunctionValidator::visitMemoryCopy(MemoryCopy* curr) {
1019
1015
curr->source ->type , i32, curr, " memory.copy source must be an i32" );
1020
1016
shouldBeEqualOrFirstIsUnreachable (
1021
1017
curr->size ->type , i32, curr, " memory.copy size must be an i32" );
1022
- shouldBeTrue (
1023
- getModule ()->memory .exists , curr, " Memory operations require a memory" );
1024
1018
}
1025
1019
1026
1020
void FunctionValidator::visitMemoryFill (MemoryFill* curr) {
1021
+ shouldBeTrue (
1022
+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
1027
1023
shouldBeTrue (getModule ()->features .hasBulkMemory (),
1028
1024
curr,
1029
1025
" Bulk memory operation (bulk memory is disabled)" );
@@ -1035,8 +1031,6 @@ void FunctionValidator::visitMemoryFill(MemoryFill* curr) {
1035
1031
curr->value ->type , i32, curr, " memory.fill value must be an i32" );
1036
1032
shouldBeEqualOrFirstIsUnreachable (
1037
1033
curr->size ->type , i32, curr, " memory.fill size must be an i32" );
1038
- shouldBeTrue (
1039
- getModule ()->memory .exists , curr, " Memory operations require a memory" );
1040
1034
}
1041
1035
1042
1036
void FunctionValidator::validateMemBytes (uint8_t bytes,
0 commit comments