From e16cf5818de5a6e37ffcbce0bcde320290d9f9f1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 11 Dec 2020 08:27:43 -0800 Subject: [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. --- src/wasm/wasm-validator.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/wasm/wasm-validator.cpp') 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) { -- cgit v1.2.3