summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-11-16 00:56:39 +0100
committerGitHub <noreply@github.com>2023-11-15 15:56:39 -0800
commitbf7635728e80ddda845e0b893b775e75a154e48e (patch)
tree78ab40302d5a45e748b7e328eff0df3a125a41cc /src/wasm/wasm-validator.cpp
parent20fe882b47c4b2570c70b2f9d82189c5b2144d03 (diff)
downloadbinaryen-bf7635728e80ddda845e0b893b775e75a154e48e.tar.gz
binaryen-bf7635728e80ddda845e0b893b775e75a154e48e.tar.bz2
binaryen-bf7635728e80ddda845e0b893b775e75a154e48e.zip
Implement more TypeGeneralizing transfer functions (#6118)
Finish the transfer functions for all expressions except for string instructions, exception handling instructions, tuple instructions, and branch instructions that carry values. The latter require more work in the CFG builder because dropping the extra stack values happens after the branch but before the target block.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 68d1f786d..cb54e1597 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2967,28 +2967,30 @@ void FunctionValidator::visitArrayCopy(ArrayCopy* curr) {
if (curr->type == Type::unreachable) {
return;
}
- if (!shouldBeSubType(curr->srcRef->type,
- Type(HeapType::array, Nullable),
- curr,
- "array.copy source should be an array reference")) {
+ if (!shouldBeTrue(curr->srcRef->type.isRef(),
+ curr,
+ "array.copy source should be a reference")) {
return;
}
- if (!shouldBeSubType(curr->destRef->type,
- Type(HeapType::array, Nullable),
- curr,
- "array.copy destination should be an array reference")) {
+ if (!shouldBeTrue(curr->destRef->type.isRef(),
+ curr,
+ "array.copy destination should be a reference")) {
return;
}
auto srcHeapType = curr->srcRef->type.getHeapType();
auto destHeapType = curr->destRef->type.getHeapType();
- if (srcHeapType == HeapType::none ||
- !shouldBeTrue(srcHeapType.isArray(),
+ // Normally both types need to be references to specifc arrays, but if either
+ // of the types are bottom, we don't further constrain the other at all
+ // because this will be emitted as an unreachable.
+ if (srcHeapType.isBottom() || destHeapType.isBottom()) {
+ return;
+ }
+ if (!shouldBeTrue(srcHeapType.isArray(),
curr,
"array.copy source should be an array reference")) {
return;
}
- if (destHeapType == HeapType::none ||
- !shouldBeTrue(destHeapType.isArray(),
+ if (!shouldBeTrue(destHeapType.isArray(),
curr,
"array.copy destination should be an array reference")) {
return;