summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index b2e208d53..c6e22899c 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2211,13 +2211,27 @@ void FunctionValidator::visitBrOnCast(BrOnCast* curr) {
void FunctionValidator::visitRttCanon(RttCanon* curr) {
shouldBeTrue(
getModule()->features.hasGC(), curr, "rtt.canon requires gc to be enabled");
- WASM_UNREACHABLE("TODO (gc): rtt.canon");
+ 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");
}
void FunctionValidator::visitRttSub(RttSub* curr) {
shouldBeTrue(
getModule()->features.hasGC(), curr, "rtt.sub requires gc to be enabled");
- WASM_UNREACHABLE("TODO (gc): rtt.sub");
+ shouldBeTrue(curr->type.isRtt(), curr, "rtt.sub must have RTT type");
+ if (curr->parent->type != Type::unreachable) {
+ shouldBeTrue(
+ curr->parent->type.isRtt(), curr, "rtt.sub parent must have RTT type");
+ auto parentRtt = curr->parent->type.getRtt();
+ auto rtt = curr->type.getRtt();
+ if (rtt.hasDepth() && parentRtt.hasDepth()) {
+ shouldBeEqual(rtt.depth,
+ parentRtt.depth + 1,
+ curr,
+ "rtt.canon has a depth of 1 over the parent");
+ }
+ }
}
void FunctionValidator::visitStructNew(StructNew* curr) {