summaryrefslogtreecommitdiff
path: root/src/tools/fuzzing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/fuzzing.h')
-rw-r--r--src/tools/fuzzing.h39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index cab33e3b5..ecc548e22 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -326,13 +326,13 @@ private:
}
if (wasm.features.hasGC()) {
options.push_back(Type::eqref);
- // TODO: i31ref
+ options.push_back(Type::i31ref);
}
}
break;
case Type::eqref:
if (wasm.features.hasGC()) {
- // TODO: i31ref
+ options.push_back(Type::i31ref);
}
break;
default:
@@ -893,11 +893,16 @@ private:
if (type == Type::i32) {
options.add(FeatureSet::ReferenceTypes, &Self::makeRefIsNull);
options.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
- &Self::makeRefEq);
+ &Self::makeRefEq,
+ &Self::makeI31Get);
}
if (type.isTuple()) {
options.add(FeatureSet::Multivalue, &Self::makeTupleMake);
}
+ if (type == Type::i31ref) {
+ options.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
+ &Self::makeI31New);
+ }
return (this->*pick(options))(type);
}
@@ -1786,6 +1791,9 @@ private:
}
return builder.makeRefFunc(target->name);
}
+ if (type == Type::i31ref) {
+ return builder.makeI31New(makeConst(Type::i32));
+ }
return builder.makeRefNull(type);
}
if (type.isTuple()) {
@@ -2652,6 +2660,20 @@ private:
return builder.makeRefEq(left, right);
}
+ Expression* makeI31New(Type type) {
+ assert(type == Type::i31ref);
+ assert(wasm.features.hasReferenceTypes() && wasm.features.hasGC());
+ auto* value = make(Type::i32);
+ return builder.makeI31New(value);
+ }
+
+ Expression* makeI31Get(Type type) {
+ assert(type == Type::i32);
+ assert(wasm.features.hasReferenceTypes() && wasm.features.hasGC());
+ auto* i31 = make(Type::i31ref);
+ return builder.makeI31Get(i31, bool(oneIn(2)));
+ }
+
Expression* makeMemoryInit() {
if (!allowMemory) {
return makeTrivial(Type::none);
@@ -2717,7 +2739,8 @@ private:
Type::exnref)
.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
Type::anyref,
- Type::eqref)); // TODO: i31ref
+ Type::eqref,
+ Type::i31ref));
}
Type getSingleConcreteType() { return pick(getSingleConcreteTypes()); }
@@ -2730,15 +2753,15 @@ private:
Type::exnref)
.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
Type::anyref,
- Type::eqref)); // TODO: i31ref
+ Type::eqref,
+ Type::i31ref));
}
Type getReferenceType() { return pick(getReferenceTypes()); }
std::vector<Type> getEqReferenceTypes() {
- return items(
- FeatureOptions<Type>().add(FeatureSet::ReferenceTypes | FeatureSet::GC,
- Type::eqref)); // TODO: i31ref
+ return items(FeatureOptions<Type>().add(
+ FeatureSet::ReferenceTypes | FeatureSet::GC, Type::eqref, Type::i31ref));
}
Type getEqReferenceType() { return pick(getEqReferenceTypes()); }