Commit 6476c47b authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm][fuzzer] Output table bounds and initializers

For indirect calls, we need to set up the tables correctly. This CL
adds this to the test case generation logic.

R=ahaas@chromium.org

Change-Id: I18a5a8e0659c46daec00d46d02fe50d5d94638d6
Reviewed-on: https://chromium-review.googlesource.com/c/1349985Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57838}
parent 623f20ff
......@@ -200,6 +200,31 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
Zone tmp_zone(isolate->allocator(), ZONE_NAME);
// There currently cannot be more than one table.
DCHECK_GE(1, module->tables.size());
for (const WasmTable& table : module->tables) {
os << " builder.setTableBounds(" << table.initial_size << ", ";
if (table.has_maximum_size) {
os << table.maximum_size << ");\n";
} else {
os << "undefined);\n";
}
}
for (const WasmTableInit& table_init : module->table_inits) {
os << " builder.addElementSegment(";
switch (table_init.offset.kind) {
case WasmInitExpr::kGlobalIndex:
os << table_init.offset.val.global_index << ", true";
break;
case WasmInitExpr::kI32Const:
os << table_init.offset.val.i32_const << ", false";
break;
default:
UNREACHABLE();
}
os << ", " << PrintCollection(table_init.entries) << ");\n";
}
for (const WasmFunction& func : module->functions) {
Vector<const uint8_t> func_code = wire_bytes.GetFunctionBytes(&func);
os << " // Generate function " << (func.func_index + 1) << " (out of "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment