summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/module-utils.cpp1
-rw-r--r--src/tools/fuzzing/fuzzing.cpp22
2 files changed, 21 insertions, 2 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp
index 2f26cfa77..7aed263a9 100644
--- a/src/ir/module-utils.cpp
+++ b/src/ir/module-utils.cpp
@@ -175,6 +175,7 @@ Table* copyTable(const Table* table, Module& out) {
ret->initial = table->initial;
ret->max = table->max;
+ ret->indexType = table->indexType;
return out.addTable(std::move(ret));
}
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp
index 26c321961..ed3287a7c 100644
--- a/src/tools/fuzzing/fuzzing.cpp
+++ b/src/tools/fuzzing/fuzzing.cpp
@@ -370,8 +370,26 @@ void TranslateToFuzzReader::setupTables() {
if (iter != wasm.tables.end()) {
table = iter->get();
} else {
- auto tablePtr = builder.makeTable(
- Names::getValidTableName(wasm, "fuzzing_table"), funcref, 0, 0);
+ // Start from a potentially empty table.
+ Address initial = upTo(10);
+ // Make the max potentially higher, or unlimited.
+ Address max;
+ if (oneIn(2)) {
+ max = initial + upTo(4);
+ } else {
+ max = Memory::kUnlimitedSize;
+ }
+ // Fuzz wasm64 when possible, sometimes.
+ auto indexType = Type::i32;
+ if (wasm.features.hasMemory64() && oneIn(2)) {
+ indexType = Type::i64;
+ }
+ auto tablePtr =
+ builder.makeTable(Names::getValidTableName(wasm, "fuzzing_table"),
+ funcref,
+ initial,
+ max,
+ indexType);
tablePtr->hasExplicitName = true;
table = wasm.addTable(std::move(tablePtr));
}