diff options
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 532529d2a..75cbcf53a 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -424,6 +424,7 @@ public: void visitMemoryGrow(MemoryGrow* curr); void visitRefNull(RefNull* curr); void visitRefIs(RefIs* curr); + void visitRefAs(RefAs* curr); void visitRefFunc(RefFunc* curr); void visitRefEq(RefEq* curr); void visitTableGet(TableGet* curr); @@ -2125,6 +2126,40 @@ void FunctionValidator::visitRefIs(RefIs* curr) { "ref.is_*'s argument should be a reference type"); } +void FunctionValidator::visitRefAs(RefAs* curr) { + switch (curr->op) { + default: + // TODO: validate all the other ref.as_* + break; + case ExternInternalize: { + shouldBeTrue(getModule()->features.hasGC(), + curr, + "extern.internalize requries GC to be enabled"); + if (curr->type == Type::unreachable) { + return; + } + shouldBeSubType(curr->value->type, + Type(HeapType::ext, Nullable), + curr->value, + "extern.internalize value should be an externref"); + break; + } + case ExternExternalize: { + shouldBeTrue(getModule()->features.hasGC(), + curr, + "extern.externalize requries GC to be enabled"); + if (curr->type == Type::unreachable) { + return; + } + shouldBeSubType(curr->value->type, + Type(HeapType::any, Nullable), + curr->value, + "extern.externalize value should be an anyref"); + break; + } + } +} + void FunctionValidator::visitRefFunc(RefFunc* curr) { // If we are not in a function, this is a global location like a table. We // allow RefFunc there as we represent tables that way regardless of what |