diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-type.cpp | 18 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 3 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 6b11ff95e..9ac23bd96 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1087,9 +1087,6 @@ FeatureSet Type::getFeatures() const { // A reference type implies we need that feature. Some also require more, // such as GC or exceptions. auto heapType = t.getHeapType(); - if (heapType.isStruct() || heapType.isArray()) { - return FeatureSet::ReferenceTypes | FeatureSet::GC; - } if (heapType.isBasic()) { switch (heapType.getBasic()) { case HeapType::ext: @@ -1114,11 +1111,16 @@ FeatureSet Type::getFeatures() const { return FeatureSet::ReferenceTypes; } } - // Note: Technically typed function references also require the typed - // function references feature, however, we use these types internally - // regardless of the presence of features (in particular, since during - // load of the wasm we don't know the features yet, so we apply the more - // refined types), so we don't add that in any case here. + if (heapType.isStruct() || heapType.isArray() || + heapType.getRecGroup().size() > 1 || heapType.getSuperType()) { + return FeatureSet::ReferenceTypes | FeatureSet::GC; + } + // Note: Technically typed function references also require GC, however, + // we use these types internally regardless of the presence of GC (in + // particular, since during load of the wasm we don't know the features + // yet, so we apply the more refined types), so we don't add that in any + // case here. + assert(heapType.isSignature()); return FeatureSet::ReferenceTypes; } TODO_SINGLE_COMPOUND(t); diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index c1316f283..37fbebef9 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2903,6 +2903,9 @@ void FunctionValidator::visitFunction(Function* curr) { "Multivalue function results (multivalue is not enabled)"); } FeatureSet features; + // Check for things like having a rec group with GC enabled. + features |= + (Type(curr->type, Nullable).getFeatures() & ~FeatureSet::ReferenceTypes); for (const auto& param : curr->getParams()) { features |= param.getFeatures(); shouldBeTrue(param.isConcrete(), curr, "params must be concretely typed"); |