Commit f0d96868 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [fuzzer] Add the drop opcode

Adds support for emitting the drop opcode in the wasm compile fuzzer.

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

Change-Id: Idb6f07f3f50ffda472107bd6276221e803c37152
Reviewed-on: https://chromium-review.googlesource.com/839760
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50267}
parent 88a9495c
......@@ -74,6 +74,20 @@ class DataRange {
}
};
ValueType GetValueType(DataRange data) {
switch (data.get<uint8_t>() % 4) {
case 0:
return kWasmI32;
case 1:
return kWasmI64;
case 2:
return kWasmF32;
case 3:
return kWasmF64;
}
UNREACHABLE();
}
class WasmGenerator {
template <WasmOpcode Op, ValueType... Args>
void op(DataRange data) {
......@@ -173,6 +187,11 @@ class WasmGenerator {
builder_->EmitU32V(offset);
}
void drop(DataRange data) {
Generate(GetValueType(data), data);
builder_->Emit(kExprDrop);
}
template <ValueType T1, ValueType T2>
void sequence(DataRange data) {
Generate<T1, T2>(data);
......@@ -257,7 +276,8 @@ void WasmGenerator::Generate<kWasmStmt>(DataRange data) {
&WasmGenerator::memop<kExprI64StoreMem32, kWasmI64>,
&WasmGenerator::memop<kExprF32StoreMem, kWasmF32>,
&WasmGenerator::memop<kExprF64StoreMem, kWasmF64>,
};
&WasmGenerator::drop};
GenerateOneOf(alternates, 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