Commit d4d3f3fa authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Reuse simple operator logic

We already have specialized logic for unops and binops, and the generic
{BuildSimpleOperator} implementation (based on a signature) was
reimplementing these two cases.
This CL avoids the switch since we only need to handle exactly two
cases, and redirects to the existing methods for implementing them.

R=thibaudm@chromium.org

Bug: v8:10576
Change-Id: I8eb5c768f0fa59e48503c108498b334a0ae9037a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2249859Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68456}
parent a9384810
......@@ -3822,24 +3822,13 @@ class WasmFullDecoder : public WasmDecoder<validate> {
}
void BuildSimpleOperator(WasmOpcode opcode, const FunctionSig* sig) {
switch (sig->parameter_count()) {
case 1: {
Value val = Pop(0, sig->GetParam(0));
Value* ret =
sig->return_count() == 0 ? nullptr : Push(sig->GetReturn(0));
CALL_INTERFACE_IF_REACHABLE(UnOp, opcode, val, ret);
break;
}
case 2: {
Value rval = Pop(1, sig->GetParam(1));
Value lval = Pop(0, sig->GetParam(0));
Value* ret =
sig->return_count() == 0 ? nullptr : Push(sig->GetReturn(0));
CALL_INTERFACE_IF_REACHABLE(BinOp, opcode, lval, rval, ret);
break;
}
default:
UNREACHABLE();
DCHECK_GE(1, sig->return_count());
ValueType ret = sig->return_count() == 0 ? kWasmStmt : sig->GetReturn(0);
if (sig->parameter_count() == 1) {
BuildSimpleOperator(opcode, ret, sig->GetParam(0));
} else {
DCHECK_EQ(2, sig->parameter_count());
BuildSimpleOperator(opcode, ret, sig->GetParam(0), sig->GetParam(1));
}
}
......
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