summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2024-05-09 14:45:25 -0700
committerGitHub <noreply@github.com>2024-05-09 14:45:25 -0700
commit006181bb98118c70d36e84e6f1f72b5d60264817 (patch)
treebe42541727442ba40b8eaea9cb0d376754c706bc
parenta816627051c67ae14f6defc8fc5c616ba427a29e (diff)
downloadbinaryen-006181bb98118c70d36e84e6f1f72b5d60264817.tar.gz
binaryen-006181bb98118c70d36e84e6f1f72b5d60264817.tar.bz2
binaryen-006181bb98118c70d36e84e6f1f72b5d60264817.zip
[validator] Remove indexType helper function (#6576)
It seems like that each of the callsites already has looked up the `Memory` object so this helper is not doing anything useful.
-rw-r--r--src/wasm/wasm-validator.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index d44c75c8f..aad9a0582 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -593,11 +593,6 @@ private:
void validateCallParamsAndResult(T* curr, HeapType sigType) {
validateCallParamsAndResult(curr, sigType, curr);
}
-
- Type indexType(Name memoryName) {
- auto memory = getModule()->getMemory(memoryName);
- return memory->indexType;
- }
};
void FunctionValidator::noteLabelName(Name name) {
@@ -1056,7 +1051,7 @@ void FunctionValidator::visitLoad(Load* curr) {
validateAlignment(curr->align, curr->type, curr->bytes, curr->isAtomic, curr);
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"load pointer type must match memory index type");
if (curr->isAtomic) {
@@ -1088,7 +1083,7 @@ void FunctionValidator::visitStore(Store* curr) {
curr->align, curr->valueType, curr->bytes, curr->isAtomic, curr);
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"store pointer must match memory index type");
shouldBeUnequal(curr->value->type,
@@ -1112,7 +1107,7 @@ void FunctionValidator::visitAtomicRMW(AtomicRMW* curr) {
validateMemBytes(curr->bytes, curr->type, curr);
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"AtomicRMW pointer type must match memory index type");
shouldBeEqualOrFirstIsUnreachable(curr->type,
@@ -1132,7 +1127,7 @@ void FunctionValidator::visitAtomicCmpxchg(AtomicCmpxchg* curr) {
validateMemBytes(curr->bytes, curr->type, curr);
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"cmpxchg pointer must match memory index type");
if (curr->expected->type != Type::unreachable &&
@@ -1166,7 +1161,7 @@ void FunctionValidator::visitAtomicWait(AtomicWait* curr) {
curr->type, Type(Type::i32), curr, "AtomicWait must have type i32");
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"AtomicWait pointer must match memory index type");
shouldBeIntOrUnreachable(
@@ -1192,7 +1187,7 @@ void FunctionValidator::visitAtomicNotify(AtomicNotify* curr) {
curr->type, Type(Type::i32), curr, "AtomicNotify must have type i32");
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"AtomicNotify pointer must match memory index type");
shouldBeEqualOrFirstIsUnreachable(
@@ -1354,7 +1349,7 @@ void FunctionValidator::visitSIMDLoad(SIMDLoad* curr) {
curr->type, Type(Type::v128), curr, "load_splat must have type v128");
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"load_splat address must match memory index type");
Type memAlignType = Type::none;
@@ -1395,7 +1390,7 @@ void FunctionValidator::visitSIMDLoadStoreLane(SIMDLoadStoreLane* curr) {
}
shouldBeEqualOrFirstIsUnreachable(
curr->ptr->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"loadX_lane or storeX_lane address must match memory index type");
shouldBeEqualOrFirstIsUnreachable(
@@ -1435,6 +1430,7 @@ void FunctionValidator::visitSIMDLoadStoreLane(SIMDLoadStoreLane* curr) {
}
void FunctionValidator::visitMemoryInit(MemoryInit* curr) {
+ auto* memory = getModule()->getMemoryOrNull(curr->memory);
shouldBeTrue(
getModule()->features.hasBulkMemory(),
curr,
@@ -1443,7 +1439,7 @@ void FunctionValidator::visitMemoryInit(MemoryInit* curr) {
curr->type, Type(Type::none), curr, "memory.init must have type none");
shouldBeEqualOrFirstIsUnreachable(
curr->dest->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"memory.init dest must match memory index type");
shouldBeEqualOrFirstIsUnreachable(curr->offset->type,
@@ -1452,7 +1448,6 @@ void FunctionValidator::visitMemoryInit(MemoryInit* curr) {
"memory.init offset must be an i32");
shouldBeEqualOrFirstIsUnreachable(
curr->size->type, Type(Type::i32), curr, "memory.init size must be an i32");
- auto* memory = getModule()->getMemoryOrNull(curr->memory);
if (!shouldBeTrue(!!memory, curr, "memory.init memory must exist")) {
return;
}
@@ -1486,27 +1481,28 @@ void FunctionValidator::visitMemoryCopy(MemoryCopy* curr) {
shouldBeTrue(!!sourceMemory, curr, "memory.copy sourceMemory must exist");
shouldBeEqualOrFirstIsUnreachable(
curr->dest->type,
- indexType(curr->destMemory),
+ destMemory->indexType,
curr,
"memory.copy dest must match destMemory index type");
shouldBeEqualOrFirstIsUnreachable(
curr->source->type,
- indexType(curr->sourceMemory),
+ sourceMemory->indexType,
curr,
"memory.copy source must match sourceMemory index type");
shouldBeEqualOrFirstIsUnreachable(
curr->size->type,
- indexType(curr->destMemory),
+ destMemory->indexType,
curr,
"memory.copy size must match destMemory index type");
shouldBeEqualOrFirstIsUnreachable(
curr->size->type,
- indexType(curr->sourceMemory),
+ sourceMemory->indexType,
curr,
"memory.copy size must match destMemory index type");
}
void FunctionValidator::visitMemoryFill(MemoryFill* curr) {
+ auto* memory = getModule()->getMemoryOrNull(curr->memory);
shouldBeTrue(
getModule()->features.hasBulkMemory(),
curr,
@@ -1515,7 +1511,7 @@ void FunctionValidator::visitMemoryFill(MemoryFill* curr) {
curr->type, Type(Type::none), curr, "memory.fill must have type none");
shouldBeEqualOrFirstIsUnreachable(
curr->dest->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"memory.fill dest must match memory index type");
shouldBeEqualOrFirstIsUnreachable(curr->value->type,
@@ -1524,10 +1520,9 @@ void FunctionValidator::visitMemoryFill(MemoryFill* curr) {
"memory.fill value must be an i32");
shouldBeEqualOrFirstIsUnreachable(
curr->size->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"memory.fill size must match memory index type");
- auto* memory = getModule()->getMemoryOrNull(curr->memory);
shouldBeTrue(!!memory, curr, "memory.fill memory must exist");
}
@@ -2162,7 +2157,7 @@ void FunctionValidator::visitMemoryGrow(MemoryGrow* curr) {
auto* memory = getModule()->getMemoryOrNull(curr->memory);
shouldBeTrue(!!memory, curr, "memory.grow memory must exist");
shouldBeEqualOrFirstIsUnreachable(curr->delta->type,
- indexType(curr->memory),
+ memory->indexType,
curr,
"memory.grow must match memory index type");
}