From bf7635728e80ddda845e0b893b775e75a154e48e Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 16 Nov 2023 00:56:39 +0100 Subject: Implement more TypeGeneralizing transfer functions (#6118) Finish the transfer functions for all expressions except for string instructions, exception handling instructions, tuple instructions, and branch instructions that carry values. The latter require more work in the CFG builder because dropping the extra stack values happens after the branch but before the target block. --- src/wasm/wasm-validator.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 68d1f786d..cb54e1597 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2967,28 +2967,30 @@ void FunctionValidator::visitArrayCopy(ArrayCopy* curr) { if (curr->type == Type::unreachable) { return; } - if (!shouldBeSubType(curr->srcRef->type, - Type(HeapType::array, Nullable), - curr, - "array.copy source should be an array reference")) { + if (!shouldBeTrue(curr->srcRef->type.isRef(), + curr, + "array.copy source should be a reference")) { return; } - if (!shouldBeSubType(curr->destRef->type, - Type(HeapType::array, Nullable), - curr, - "array.copy destination should be an array reference")) { + if (!shouldBeTrue(curr->destRef->type.isRef(), + curr, + "array.copy destination should be a reference")) { return; } auto srcHeapType = curr->srcRef->type.getHeapType(); auto destHeapType = curr->destRef->type.getHeapType(); - if (srcHeapType == HeapType::none || - !shouldBeTrue(srcHeapType.isArray(), + // Normally both types need to be references to specifc arrays, but if either + // of the types are bottom, we don't further constrain the other at all + // because this will be emitted as an unreachable. + if (srcHeapType.isBottom() || destHeapType.isBottom()) { + return; + } + if (!shouldBeTrue(srcHeapType.isArray(), curr, "array.copy source should be an array reference")) { return; } - if (destHeapType == HeapType::none || - !shouldBeTrue(destHeapType.isArray(), + if (!shouldBeTrue(destHeapType.isArray(), curr, "array.copy destination should be an array reference")) { return; -- cgit v1.2.3