Skip to content

Commit f3bb6a0

Browse files
Fuzzer
1 parent 241a56b commit f3bb6a0

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/tools/fuzzing.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ class TranslateToFuzzReader {
464464
Expression* makeGlobalGet(Type type);
465465
Expression* makeGlobalSet(Type type);
466466
Expression* makeTupleMake(Type type);
467+
Expression* makeWideIntAddSub(Type type);
468+
Expression* makeWideIntMul(Type type);
467469
Expression* makeTupleExtract(Type type);
468470
Expression* makePointer();
469471
Expression* makeNonAtomicLoad(Type type);

src/tools/fuzzing/fuzzing.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,10 @@ Expression* TranslateToFuzzReader::_makeConcrete(Type type) {
25642564
}
25652565
if (type.isTuple()) {
25662566
options.add(FeatureSet::Multivalue, &Self::makeTupleMake);
2567+
if (type == Types::getI64Pair()) {
2568+
options.add(FeatureSet::WideArithmetic, &Self::makeWideIntAddSub);
2569+
options.add(FeatureSet::WideArithmetic, &Self::makeWideIntMul);
2570+
}
25672571
}
25682572
if (type.isRef()) {
25692573
auto heapType = type.getHeapType();
@@ -3246,6 +3250,26 @@ Expression* TranslateToFuzzReader::makeTupleMake(Type type) {
32463250
return builder.makeTupleMake(std::move(elements));
32473251
}
32483252

3253+
Expression* TranslateToFuzzReader::makeWideIntAddSub(Type type) {
3254+
assert(wasm.features.hasWideArithmetic());
3255+
assert(type == Types::getI64Pair());
3256+
auto op = upTo(2) == 0 ? AddInt128 : SubInt128;
3257+
auto* leftLow = make(Type::i64);
3258+
auto* leftHigh = make(Type::i64);
3259+
auto* rightLow = make(Type::i64);
3260+
auto* rightHigh = make(Type::i64);
3261+
return builder.makeWideIntAddSub(op, leftLow, leftHigh, rightLow, rightHigh);
3262+
}
3263+
3264+
Expression* TranslateToFuzzReader::makeWideIntMul(Type type) {
3265+
assert(wasm.features.hasWideArithmetic());
3266+
assert(type == Types::getI64Pair());
3267+
auto op = upTo(2) == 0 ? MulWideSInt64 : MulWideUInt64;
3268+
auto* left = make(Type::i64);
3269+
auto* right = make(Type::i64);
3270+
return builder.makeWideIntMul(op, left, right);
3271+
}
3272+
32493273
Expression* TranslateToFuzzReader::makeTupleExtract(Type type) {
32503274
// Tuples can require locals in binary format conversions.
32513275
if (!type.isDefaultable()) {

0 commit comments

Comments
 (0)