From e1d74ef2acdd88f06b9e58f91f30bb56b9a26fe8 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Thu, 17 Sep 2020 07:46:40 +0200 Subject: Add GC feature flag (#3135) Adds the `--enable-gc` feature flag, so far enabling the `anyref` type incl. subtyping, and removes the temporary `--enable-anyref` feature flag that it replaces. --- src/tools/fuzzing.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/tools/fuzzing.h') diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 9768b63c4..e6cc4e444 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -848,8 +848,7 @@ private: } Expression* _makeConcrete(Type type) { - bool canMakeControlFlow = - !type.isTuple() || wasm.features.has(FeatureSet::Multivalue); + bool canMakeControlFlow = !type.isTuple() || wasm.features.hasMultivalue(); using Self = TranslateToFuzzReader; FeatureOptions options; using WeightedOption = decltype(options)::WeightedOption; @@ -2609,16 +2608,7 @@ private: Expression* makeRefIsNull(Type type) { assert(type == Type::i32); assert(wasm.features.hasReferenceTypes()); - SmallVector options; - options.push_back(Type::externref); - options.push_back(Type::funcref); - if (wasm.features.hasExceptionHandling()) { - options.push_back(Type::exnref); - } - if (wasm.features.hasAnyref()) { - options.push_back(Type::anyref); - } - return builder.makeRefIsNull(make(pick(options))); + return builder.makeRefIsNull(make(getReferenceType())); } Expression* makeMemoryInit() { @@ -2684,11 +2674,22 @@ private: .add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref) .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, Type::exnref) - .add(FeatureSet::ReferenceTypes | FeatureSet::Anyref, Type::anyref)); + .add(FeatureSet::ReferenceTypes | FeatureSet::GC, Type::anyref)); } Type getSingleConcreteType() { return pick(getSingleConcreteTypes()); } + std::vector getReferenceTypes() { + return items( + FeatureOptions() + .add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref) + .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, + Type::exnref) + .add(FeatureSet::ReferenceTypes | FeatureSet::GC, Type::anyref)); + } + + Type getReferenceType() { return pick(getReferenceTypes()); } + Type getTupleType() { std::vector elements; size_t numElements = 2 + upTo(MAX_TUPLE_SIZE - 1); -- cgit v1.2.3