[wasm][fuzzer] Dump data segments when generating tests

Data segments were missing in the output of --wasm-fuzzer-gen-test.

R=manoskouk@chromium.org

Bug: v8:11863
Change-Id: I40e60ef8626125ca9df6bead688607215d9e5b58
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3461932
Reviewed-by: Manos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79106}
This commit is contained in:
Clemens Backes 2022-02-15 12:08:51 +01:00 committed by V8 LUCI CQ
parent 846790f1c1
commit 88b931f7ce

View File

@ -623,6 +623,24 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
os << ");\n";
}
for (WasmDataSegment segment : module->data_segments) {
base::Vector<const uint8_t> data = wire_bytes.module_bytes().SubVector(
segment.source.offset(), segment.source.end_offset());
if (segment.active) {
// TODO(wasm): Add other expressions when needed.
CHECK_EQ(ConstantExpression::kI32Const, segment.dest_addr.kind());
os << "builder.addDataSegment(" << segment.dest_addr.i32_value() << ", ";
} else {
os << "builder.addPassiveDataSegment(";
}
os << "[";
if (!data.empty()) {
os << unsigned{data[0]};
for (unsigned byte : data + 1) os << ", " << byte;
}
os << "]);\n";
}
for (WasmGlobal& global : module->globals) {
os << "builder.addGlobal(" << ValueTypeToConstantName(global.type) << ", "
<< global.mutability << ", ";