Skip to content
Merged
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
19 changes: 15 additions & 4 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,17 @@ void TranslateToFuzzReader::setupHeapTypes() {
// initial content we began with.
auto possibleHeapTypes = ModuleUtils::collectHeapTypes(wasm);

// Use heap types from an imported module, if present.
if (importedModule) {
auto importedHeapTypes = ModuleUtils::collectHeapTypes(*importedModule);
auto rate = upTo(11);
for (auto type : importedHeapTypes) {
if (upTo(10) < rate) {
possibleHeapTypes.push_back(type);
}
}
}

// Filter away uninhabitable heap types, that is, heap types that we cannot
// construct, like a type with a non-nullable reference to itself.
interestingHeapTypes = HeapTypeGenerator::getInhabitable(possibleHeapTypes);
Expand Down Expand Up @@ -1213,9 +1224,9 @@ void TranslateToFuzzReader::useImportedFunctions() {
}

// Add some of the module's exported functions as imports, at a random rate.
auto rate = upTo(100);
auto rate = upTo(11);
for (auto& exp : importedModule->exports) {
if (exp->kind != ExternalKind::Function || upTo(100) > rate) {
if (exp->kind != ExternalKind::Function || upTo(10) >= rate) {
continue;
}

Expand Down Expand Up @@ -1243,9 +1254,9 @@ void TranslateToFuzzReader::useImportedGlobals() {
}

// Add some of the module's exported globals as imports, at a random rate.
auto rate = upTo(100);
auto rate = upTo(11);
for (auto& exp : importedModule->exports) {
if (exp->kind != ExternalKind::Global || upTo(100) > rate) {
if (exp->kind != ExternalKind::Global || upTo(10) >= rate) {
continue;
}

Expand Down
Loading