Commit 9beac383 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[fuzzer] Slightly improve generated test cases

Mostly cosmetic changes. The biggest change is to encode block result
types using symbolic names instead of hex numbers.

R=ahaas@chromium.org

Change-Id: Ic0e6eccf687338e68508094168ddd70734cef301
Reviewed-on: https://chromium-review.googlesource.com/973527
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52138}
parent 3ed7c64b
......@@ -959,9 +959,32 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
os << RawOpcodeName(opcode) << ",";
if (opcode == kExprLoop || opcode == kExprIf || opcode == kExprBlock ||
opcode == kExprTry) {
DCHECK_EQ(2, length);
switch (i.pc()[1]) {
#define CASE_LOCAL_TYPE(local_name, type_name) \
case kLocal##local_name: \
os << " kWasm" #type_name ","; \
break;
CASE_LOCAL_TYPE(I32, I32)
CASE_LOCAL_TYPE(I64, I64)
CASE_LOCAL_TYPE(F32, F32)
CASE_LOCAL_TYPE(F64, F64)
CASE_LOCAL_TYPE(S128, S128)
CASE_LOCAL_TYPE(Void, Stmt)
default:
os << " 0x" << AsHex(i.pc()[1], 2) << ",";
break;
}
#undef CASE_LOCAL_TYPE
} else {
for (unsigned j = 1; j < length; ++j) {
os << " 0x" << AsHex(i.pc()[j], 2) << ",";
}
}
switch (opcode) {
case kExprElse:
......
......@@ -165,7 +165,7 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
"load('test/mjsunit/wasm/wasm-module-builder.js');\n"
"\n"
"(function() {\n"
" var builder = new WasmModuleBuilder();\n";
" const builder = new WasmModuleBuilder();\n";
if (module->has_memory) {
os << " builder.addMemory(" << module->initial_pages;
......@@ -185,14 +185,15 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
for (const WasmFunction& func : module->functions) {
Vector<const uint8_t> func_code = wire_bytes.GetFunctionBytes(&func);
os << " // Generate function " << func.func_index << " (out of "
os << " // Generate function " << (func.func_index + 1) << " (out of "
<< module->functions.size() << ").\n";
// Generate signature.
os << " sig" << func.func_index << " = makeSig("
os << " sig" << (func.func_index + 1) << " = makeSig("
<< PrintParameters(func.sig) << ", " << PrintReturns(func.sig) << ");\n";
// Add function.
os << " builder.addFunction(undefined, sig" << func.func_index << ")\n";
os << " builder.addFunction(undefined, sig" << (func.func_index + 1)
<< ")\n";
// Add locals.
BodyLocalDecls decls(&tmp_zone);
......@@ -226,8 +227,8 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
}
if (compiles) {
os << " var module = builder.instantiate();\n"
" module.exports.main(1, 2, 3);\n";
os << " const instance = builder.instantiate();\n"
" print(instance.exports.main(1, 2, 3));\n";
} else {
os << " assertThrows(function() { builder.instantiate(); }, "
"WebAssembly.CompileError);\n";
......
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