summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-08 18:55:20 -0800
committerGitHub <noreply@github.com>2020-12-08 18:55:20 -0800
commit63a042e3a94df7ba3a5c9dde03990a9813fdc366 (patch)
tree50c05727ce20615f4d0c0206e62dcd56c246766f /src/wasm/wasm-validator.cpp
parent2a0059dec2fe01dcf1358e0120c32aadd2d765b6 (diff)
downloadbinaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.tar.gz
binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.tar.bz2
binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.zip
[GC] Add basic RTT support (#3432)
This adds rtt.canon and rtt.sub together with RTT type support that is necessary for them. Together this lets us test roundtripping the instructions and types. Also fixes a missing traversal over globals in collectHeapTypes, which the example from the GC docs requires, as the RTTs are in globals there. This does not yet add full interpreter support and other things. It disables initial contents on GC in the fuzzer, to avoid the fuzzer breaking. Renames the binary ID for exnref, which is being removed from the spec, and which overlaps with the binary ID for rtt.
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) {