@@ -970,8 +970,6 @@ void FunctionValidator::visitSIMDShift(SIMDShift* curr) {
970970}
971971
972972void FunctionValidator::visitMemoryInit (MemoryInit* curr) {
973- shouldBeTrue (
974- getModule ()->memory .exists , curr, " Memory operations require a memory" );
975973 shouldBeTrue (getModule ()->features .hasBulkMemory (),
976974 curr,
977975 " Bulk memory operation (bulk memory is disabled)" );
@@ -983,27 +981,33 @@ void FunctionValidator::visitMemoryInit(MemoryInit* curr) {
983981 curr->offset ->type , i32 , curr, " memory.init offset must be an i32" );
984982 shouldBeEqualOrFirstIsUnreachable (
985983 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+ }
986989 shouldBeTrue (curr->segment < getModule ()->memory .segments .size (),
987990 curr,
988991 " memory.init segment index out of bounds" );
989992}
990993
991994void FunctionValidator::visitDataDrop (DataDrop* curr) {
992- shouldBeTrue (
993- getModule ()->memory .exists , curr, " Memory operations require a memory" );
994995 shouldBeTrue (getModule ()->features .hasBulkMemory (),
995996 curr,
996997 " Bulk memory operation (bulk memory is disabled)" );
997998 shouldBeEqualOrFirstIsUnreachable (
998999 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+ }
9991005 shouldBeTrue (curr->segment < getModule ()->memory .segments .size (),
10001006 curr,
10011007 " data.drop segment index out of bounds" );
10021008}
10031009
10041010void FunctionValidator::visitMemoryCopy (MemoryCopy* curr) {
1005- shouldBeTrue (
1006- getModule ()->memory .exists , curr, " Memory operations require a memory" );
10071011 shouldBeTrue (getModule ()->features .hasBulkMemory (),
10081012 curr,
10091013 " Bulk memory operation (bulk memory is disabled)" );
@@ -1015,11 +1019,11 @@ void FunctionValidator::visitMemoryCopy(MemoryCopy* curr) {
10151019 curr->source ->type , i32 , curr, " memory.copy source must be an i32" );
10161020 shouldBeEqualOrFirstIsUnreachable (
10171021 curr->size ->type , i32 , curr, " memory.copy size must be an i32" );
1022+ shouldBeTrue (
1023+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
10181024}
10191025
10201026void FunctionValidator::visitMemoryFill (MemoryFill* curr) {
1021- shouldBeTrue (
1022- getModule ()->memory .exists , curr, " Memory operations require a memory" );
10231027 shouldBeTrue (getModule ()->features .hasBulkMemory (),
10241028 curr,
10251029 " Bulk memory operation (bulk memory is disabled)" );
@@ -1031,6 +1035,8 @@ void FunctionValidator::visitMemoryFill(MemoryFill* curr) {
10311035 curr->value ->type , i32 , curr, " memory.fill value must be an i32" );
10321036 shouldBeEqualOrFirstIsUnreachable (
10331037 curr->size ->type , i32 , curr, " memory.fill size must be an i32" );
1038+ shouldBeTrue (
1039+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
10341040}
10351041
10361042void FunctionValidator::validateMemBytes (uint8_t bytes,
0 commit comments