@@ -970,6 +970,8 @@ void FunctionValidator::visitSIMDShift(SIMDShift* curr) {
970970}
971971
972972void FunctionValidator::visitMemoryInit (MemoryInit* curr) {
973+ shouldBeTrue (
974+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
973975 shouldBeTrue (getModule ()->features .hasBulkMemory (),
974976 curr,
975977 " Bulk memory operation (bulk memory is disabled)" );
@@ -981,33 +983,27 @@ void FunctionValidator::visitMemoryInit(MemoryInit* curr) {
981983 curr->offset ->type , i32 , curr, " memory.init offset must be an i32" );
982984 shouldBeEqualOrFirstIsUnreachable (
983985 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- }
989986 shouldBeTrue (curr->segment < getModule ()->memory .segments .size (),
990987 curr,
991988 " memory.init segment index out of bounds" );
992989}
993990
994991void FunctionValidator::visitDataDrop (DataDrop* curr) {
992+ shouldBeTrue (
993+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
995994 shouldBeTrue (getModule ()->features .hasBulkMemory (),
996995 curr,
997996 " Bulk memory operation (bulk memory is disabled)" );
998997 shouldBeEqualOrFirstIsUnreachable (
999998 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- }
1005999 shouldBeTrue (curr->segment < getModule ()->memory .segments .size (),
10061000 curr,
10071001 " data.drop segment index out of bounds" );
10081002}
10091003
10101004void FunctionValidator::visitMemoryCopy (MemoryCopy* curr) {
1005+ shouldBeTrue (
1006+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
10111007 shouldBeTrue (getModule ()->features .hasBulkMemory (),
10121008 curr,
10131009 " Bulk memory operation (bulk memory is disabled)" );
@@ -1019,11 +1015,11 @@ void FunctionValidator::visitMemoryCopy(MemoryCopy* curr) {
10191015 curr->source ->type , i32 , curr, " memory.copy source must be an i32" );
10201016 shouldBeEqualOrFirstIsUnreachable (
10211017 curr->size ->type , i32 , curr, " memory.copy size must be an i32" );
1022- shouldBeTrue (
1023- getModule ()->memory .exists , curr, " Memory operations require a memory" );
10241018}
10251019
10261020void FunctionValidator::visitMemoryFill (MemoryFill* curr) {
1021+ shouldBeTrue (
1022+ getModule ()->memory .exists , curr, " Memory operations require a memory" );
10271023 shouldBeTrue (getModule ()->features .hasBulkMemory (),
10281024 curr,
10291025 " Bulk memory operation (bulk memory is disabled)" );
@@ -1035,8 +1031,6 @@ void FunctionValidator::visitMemoryFill(MemoryFill* curr) {
10351031 curr->value ->type , i32 , curr, " memory.fill value must be an i32" );
10361032 shouldBeEqualOrFirstIsUnreachable (
10371033 curr->size ->type , i32 , curr, " memory.fill size must be an i32" );
1038- shouldBeTrue (
1039- getModule ()->memory .exists , curr, " Memory operations require a memory" );
10401034}
10411035
10421036void FunctionValidator::validateMemBytes (uint8_t bytes,
0 commit comments