[wasm][fuzzer] Fix test generation for indirect calls

Indirect calls rely on fixed signature indexes. Thus make test case
generation output the signatures exactly like they appear in the module.

R=ahaas@chromium.org

Change-Id: I80b088024da759ec87695363aeefb28685e1d704
Reviewed-on: https://chromium-review.googlesource.com/c/1350831
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57837}
This commit is contained in:
Clemens Hammacher 2018-11-26 14:05:51 +01:00 committed by Commit Bot
parent e8a1c25f6a
commit 623f20ff6f

View File

@ -193,19 +193,21 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
<< glob.mutability << ");\n";
}
for (const FunctionSig* sig : module->signatures) {
os << " builder.addType(makeSig(" << PrintParameters(sig) << ", "
<< PrintReturns(sig) << "));\n";
}
Zone tmp_zone(isolate->allocator(), ZONE_NAME);
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 "
<< module->functions.size() << ").\n";
// Generate signature.
os << " sig" << (func.func_index + 1) << " = makeSig("
<< PrintParameters(func.sig) << ", " << PrintReturns(func.sig) << ");\n";
// Add function.
os << " builder.addFunction(undefined, sig" << (func.func_index + 1)
<< ")\n";
os << " builder.addFunction(undefined, " << func.sig_index
<< " /* sig */)\n";
// Add locals.
BodyLocalDecls decls(&tmp_zone);