summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-11-03 14:44:59 -0700
committerGitHub <noreply@github.com>2021-11-03 21:44:59 +0000
commitab66e9ab1210a87d1db8ebe93cf8463eafe34e33 (patch)
tree2b28bd76b12f35420c77d3e3526f1d18b9a847e2 /src/wasm/wasm-validator.cpp
parent7b75f93898d37a87f16ef603b1c24def6ad6d9e4 (diff)
downloadbinaryen-ab66e9ab1210a87d1db8ebe93cf8463eafe34e33.tar.gz
binaryen-ab66e9ab1210a87d1db8ebe93cf8463eafe34e33.tar.bz2
binaryen-ab66e9ab1210a87d1db8ebe93cf8463eafe34e33.zip
Fix RTTs for RTT-less instructions (#4294)
Allocation and cast instructions without explicit RTTs should use the canonical RTTs for the given types. Furthermore, the RTTs for nominal types should reflect the static type hierarchy. Previously, however, we implemented allocations and casts without RTTs using an alternative system that only used static types rather than RTT values. This alternative system would work fine in a world without first-class RTTs, but it did not properly allow mixing instructions that use RTTs and instructions that do not use RTTs as intended by the M4 GC spec. This PR fixes the issue by using canonical RTTs where appropriate and cleans up the relevant casting code using std::variant.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index f8669961c..bb0e99cc2 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2361,7 +2361,10 @@ void FunctionValidator::visitRttCanon(RttCanon* curr) {
getModule()->features.hasGC(), curr, "rtt.canon requires gc to be enabled");
shouldBeTrue(curr->type.isRtt(), curr, "rtt.canon must have RTT type");
auto rtt = curr->type.getRtt();
- shouldBeEqual(rtt.depth, Index(0), curr, "rtt.canon has a depth of 0");
+ shouldBeEqual(rtt.depth,
+ Index(curr->type.getHeapType().getDepth()),
+ curr,
+ "rtt.canon must have the depth of its heap type");
}
void FunctionValidator::visitRttSub(RttSub* curr) {