Skip to content
Draft

Fuzzer #8661

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tools/fuzzing.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ class TranslateToFuzzReader {
Expression* makeGlobalGet(Type type);
Expression* makeGlobalSet(Type type);
Expression* makeTupleMake(Type type);
Expression* makeWideIntAddSub(Type type);
Expression* makeWideIntMul(Type type);
Expression* makeTupleExtract(Type type);
Expression* makePointer();
Expression* makeNonAtomicLoad(Type type);
Expand Down
24 changes: 24 additions & 0 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,10 @@ Expression* TranslateToFuzzReader::_makeConcrete(Type type) {
}
if (type.isTuple()) {
options.add(FeatureSet::Multivalue, &Self::makeTupleMake);
if (type == Types::getI64Pair()) {
options.add(FeatureSet::WideArithmetic, &Self::makeWideIntAddSub);
options.add(FeatureSet::WideArithmetic, &Self::makeWideIntMul);
}
}
if (type.isRef()) {
auto heapType = type.getHeapType();
Expand Down Expand Up @@ -3246,6 +3250,26 @@ Expression* TranslateToFuzzReader::makeTupleMake(Type type) {
return builder.makeTupleMake(std::move(elements));
}

Expression* TranslateToFuzzReader::makeWideIntAddSub(Type type) {
assert(wasm.features.hasWideArithmetic());
assert(type == Types::getI64Pair());
auto op = upTo(2) == 0 ? AddInt128 : SubInt128;
auto* leftLow = make(Type::i64);
auto* leftHigh = make(Type::i64);
auto* rightLow = make(Type::i64);
auto* rightHigh = make(Type::i64);
return builder.makeWideIntAddSub(op, leftLow, leftHigh, rightLow, rightHigh);
}

Expression* TranslateToFuzzReader::makeWideIntMul(Type type) {
assert(wasm.features.hasWideArithmetic());
assert(type == Types::getI64Pair());
auto op = upTo(2) == 0 ? MulWideSInt64 : MulWideUInt64;
auto* left = make(Type::i64);
auto* right = make(Type::i64);
return builder.makeWideIntMul(op, left, right);
}

Expression* TranslateToFuzzReader::makeTupleExtract(Type type) {
// Tuples can require locals in binary format conversions.
if (!type.isDefaultable()) {
Expand Down
Loading