From 12ad604c17407f6b36d52c6404f2dab32e5c7960 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 19 Dec 2022 15:45:34 -0800 Subject: [Wasm GC] Do not cache signature types in nominal mode if they have a super (#5364) This reduces the amount of public types, since if there is a super then using the type in a public place would make the super also public. It is safer for closed-world mode to reuse types without supers. --- src/wasm/wasm-type.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 284d6d7d6..b65debc73 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -2967,7 +2967,11 @@ TypeBuilder::BuildResult TypeBuilder::build() { // Note built signature types. See comment in `HeapType::HeapType(Signature)`. for (auto type : state.results) { - if (type.isSignature() && (getTypeSystem() == TypeSystem::Nominal)) { + // Do not cache types with explicit supertypes (that is, whose supertype is + // not HeapType::func). We don't want to reuse such types because then we'd + // be adding subtyping relationships that are not in the input. + if (type.isSignature() && (getTypeSystem() == TypeSystem::Nominal) && + !type.getSuperType()) { nominalSignatureCache.insertType(type); } } -- cgit v1.2.3