summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-11 08:27:43 -0800
committerGitHub <noreply@github.com>2020-12-11 08:27:43 -0800
commite16cf5818de5a6e37ffcbce0bcde320290d9f9f1 (patch)
tree84a8a0d0e1031409501a548e465a89380ce7da80 /src/wasm/wasm-validator.cpp
parente1978e0274de74aa9ce5c6bcfa71e03ddadeb685 (diff)
downloadbinaryen-e16cf5818de5a6e37ffcbce0bcde320290d9f9f1.tar.gz
binaryen-e16cf5818de5a6e37ffcbce0bcde320290d9f9f1.tar.bz2
binaryen-e16cf5818de5a6e37ffcbce0bcde320290d9f9f1.zip
[GC] Add ref.test and ref.cast (#3439)
This adds enough to read and write them and test that, but leaves interpreter support for later.
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 cf92cf4d3..56cf9c114 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2192,13 +2192,27 @@ void FunctionValidator::visitI31Get(I31Get* curr) {
void FunctionValidator::visitRefTest(RefTest* curr) {
shouldBeTrue(
getModule()->features.hasGC(), curr, "ref.test requires gc to be enabled");
- WASM_UNREACHABLE("TODO (gc): ref.test");
+ if (curr->ref->type != Type::unreachable) {
+ shouldBeTrue(
+ curr->ref->type.isRef(), curr, "ref.test ref must have ref type");
+ }
+ if (curr->rtt->type != Type::unreachable) {
+ shouldBeTrue(
+ curr->rtt->type.isRtt(), curr, "ref.test rtt must have rtt type");
+ }
}
void FunctionValidator::visitRefCast(RefCast* curr) {
shouldBeTrue(
getModule()->features.hasGC(), curr, "ref.cast requires gc to be enabled");
- WASM_UNREACHABLE("TODO (gc): ref.cast");
+ if (curr->ref->type != Type::unreachable) {
+ shouldBeTrue(
+ curr->ref->type.isRef(), curr, "ref.test ref must have ref type");
+ }
+ if (curr->rtt->type != Type::unreachable) {
+ shouldBeTrue(
+ curr->rtt->type.isRtt(), curr, "ref.test rtt must have rtt type");
+ }
}
void FunctionValidator::visitBrOnCast(BrOnCast* curr) {