diff options
author | Alon Zakai <azakai@google.com> | 2023-04-17 09:24:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-17 09:24:26 -0700 |
commit | cbe637f6c1517c9fb501453ba3774e73f12489d8 (patch) | |
tree | 1ef2e98853da4e164d9e3d581226bc8cec5d4003 /src | |
parent | 55a5fcec460ad402c55e37d1da0f278404c64dda (diff) | |
download | binaryen-cbe637f6c1517c9fb501453ba3774e73f12489d8.tar.gz binaryen-cbe637f6c1517c9fb501453ba3774e73f12489d8.tar.bz2 binaryen-cbe637f6c1517c9fb501453ba3774e73f12489d8.zip |
[Wasm GC] Fix SignatureRefining on a call_ref to a bottom type (#5670)
Before this PR we hit the assert on the type not being basic.
We could also look into fixing the caller to skip bottom types, but as
bottom types trivially have no subtypes, it is more future-facing to
simply handle it.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/subtypes.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ir/subtypes.h b/src/ir/subtypes.h index 420bdcc1d..2a629a05d 100644 --- a/src/ir/subtypes.h +++ b/src/ir/subtypes.h @@ -37,14 +37,21 @@ struct SubTypes { SubTypes(Module& wasm) : SubTypes(ModuleUtils::collectHeapTypes(wasm)) {} const std::vector<HeapType>& getStrictSubTypes(HeapType type) const { + // When we return an empty result, use a canonical constant empty vec to + // avoid allocation. + static const std::vector<HeapType> empty; + + if (type.isBottom()) { + // Bottom types have no subtypes. + return empty; + } + assert(!type.isBasic()); if (auto iter = typeSubTypes.find(type); iter != typeSubTypes.end()) { return iter->second; } - // No entry exists. Return a canonical constant empty vec, to avoid - // allocation. - static const std::vector<HeapType> empty; + // No entry exists. return empty; } |