From 569f789622f116177c8a1e32fb62a4e5a5c9dfe0 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 20 Dec 2022 09:52:54 -0600 Subject: Update RefCast representation to drop extra HeapType (#5350) The latest upstream version of ref.cast is parameterized with a target reference type, not just a heap type, because the nullability of the result is parameterizable. As a first step toward implementing these new, more flexible ref.cast instructions, change the internal representation of ref.cast to use the expression type as the cast target rather than storing a separate heap type field. For now require that the encoded semantics match the previously allowed semantics, though, so that none of the optimization passes need to be updated. --- src/wasm/wasm-validator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 726c70c7c..b102ecb1c 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2530,10 +2530,16 @@ void FunctionValidator::visitRefCast(RefCast* curr) { return; } shouldBeEqual( - curr->intendedType.getBottom(), + curr->type.getHeapType().getBottom(), curr->ref->type.getHeapType().getBottom(), curr, "ref.cast target type and ref type must have a common supertype"); + + // TODO: Remove this restriction + shouldBeEqual(curr->type.getNullability(), + curr->ref->type.getNullability(), + curr, + "ref.cast to a different nullability not yet implemented"); } void FunctionValidator::visitBrOn(BrOn* curr) { -- cgit v1.2.3