From 8670f15676b3c6406d6e82327a7258c7c4d08b43 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 28 Jul 2021 12:00:11 -0700 Subject: Support subtyping in tail calls (#4032) The tail call spec does not include subtyping because it is based on the upstream spec, which does not contain subtyping. However, there is no reason that subtyping shouldn't apply to tail calls like it does for any other call or return. Update the validator to allow subtyping and avoid a related null pointer dereference while we're at it. Do not run the test in with --nominal because it is buggy in that mode. --- src/wasm/wasm-validator.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index f492c7110..450a7b956 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -460,9 +460,9 @@ private: Type(Type::unreachable), curr, "return_call* should have unreachable type"); - shouldBeEqual( - getFunction()->getResults(), + shouldBeSubType( sig.results, + getFunction()->getResults(), curr, "return_call* callee return type must match caller return type"); } else { @@ -798,9 +798,11 @@ void FunctionValidator::visitCallIndirect(CallIndirect* curr) { if (curr->target->type != Type::unreachable) { auto* table = getModule()->getTableOrNull(curr->table); shouldBeTrue(!!table, curr, "call-indirect table must exist"); - shouldBeTrue(table->type.isFunction(), - curr, - "call-indirect table must be of function type."); + if (table) { + shouldBeTrue(table->type.isFunction(), + curr, + "call-indirect table must be of function type."); + } } validateCallParamsAndResult(curr, curr->sig); -- cgit v1.2.3