[wasm] [fuzzer] [cleanup] Reuse helper method

We already have a helper method for generating a sequence of values.
Reuse this instead of reimplementing the same thing two more times.

R=ahaas@chromium.org
CC=eholk@chromium.org

Change-Id: Ifbbe1324173951156c1ec9bba84fd1aa4bcb2adb
Reviewed-on: https://chromium-review.googlesource.com/758365
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49216}
This commit is contained in:
Clemens Hammacher 2017-11-08 11:25:14 +01:00 committed by Commit Bot
parent 731d0fcfa5
commit 54d68665f2

View File

@ -106,22 +106,13 @@ class WasmGenerator {
blocks_.pop_back(); blocks_.pop_back();
} }
template <WasmOpcode memory_op, ValueType arg_type = kWasmStmt> template <WasmOpcode memory_op, ValueType... arg_types>
void memop(DataRange data) { void memop(DataRange data) {
const auto align = data.get<uint32_t>(); const auto align = data.get<uint32_t>();
const auto offset = data.get<uint32_t>(); const auto offset = data.get<uint32_t>();
if (arg_type == kWasmStmt) { // Generate the index and the arguments, if any.
// Generate the index Generate<kWasmI32, arg_types...>(data);
Generate<kWasmI32>(data);
} else {
const auto parts = data.split();
// Generate the index
Generate<kWasmI32>(parts.first);
// Generate the value
Generate<arg_type>(parts.second);
}
builder_->Emit(memory_op); builder_->Emit(memory_op);
builder_->EmitU32V(align); builder_->EmitU32V(align);
@ -130,9 +121,7 @@ class WasmGenerator {
template <ValueType T1, ValueType T2> template <ValueType T1, ValueType T2>
void sequence(DataRange data) { void sequence(DataRange data) {
const auto parts = data.split(); Generate<T1, T2>(data);
Generate<T1>(parts.first);
Generate<T2>(parts.second);
} }
void current_memory(DataRange data) { void current_memory(DataRange data) {