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