Commit 54a66487 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[wasm][fuzzer] Generate return calls in the compile fuzzer

If the types allow it, sometimes generate a return call instead of a
regular call in the wasm-compile fuzzer.

R=clemensb@chromium.org

Bug: v8:10693
Change-Id: Ie5e92f2b012f655b9d7d5847dba4a669152635c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2316297
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69063}
parent 183cbdaf
......@@ -474,14 +474,26 @@ class WasmGenerator {
}
void call(DataRange* data, ValueType wanted_type) {
int func_index = data->get<uint8_t>() % functions_.size();
uint8_t random_byte = data->get<uint8_t>();
int func_index = random_byte % functions_.size();
FunctionSig* sig = functions_[func_index];
// Generate arguments.
for (size_t i = 0; i < sig->parameter_count(); ++i) {
Generate(sig->GetParam(i), data);
}
// Emit call.
builder_->EmitWithU32V(kExprCallFunction, func_index);
// If the return types of the callee happen to match the return types of the
// caller, generate a tail call.
bool use_return_call = random_byte > 127;
if (use_return_call &&
std::equal(sig->returns().begin(), sig->returns().end(),
builder_->signature()->returns().begin(),
builder_->signature()->returns().end())) {
builder_->EmitWithU32V(kExprReturnCall, func_index);
return;
} else {
builder_->EmitWithU32V(kExprCallFunction, func_index);
}
if (sig->return_count() == 0 && wanted_type != kWasmStmt) {
// The call did not generate a value. Thus just generate it here.
Generate(wanted_type, data);
......
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