Commit 00e6d962 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[wasm] DCHECK that all simple unary operators return a value

Since {WasmGraphBuildingInterface::UnOp} always sets the result value
node, we have to ensure the passed {result} is not null.
Note: This can never happen with the current set of operators; this is
guarding against possible future operators.

Bug: chromium:1285041
Change-Id: I657cb02a9c650121a51ee795ef5572a5abd66933
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3447373Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78995}
parent dfecb7bd
...@@ -5363,11 +5363,13 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -5363,11 +5363,13 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
int BuildSimpleOperator(WasmOpcode opcode, const FunctionSig* sig) { int BuildSimpleOperator(WasmOpcode opcode, const FunctionSig* sig) {
DCHECK_GE(1, sig->return_count()); DCHECK_GE(1, sig->return_count());
ValueType ret = sig->return_count() == 0 ? kWasmVoid : sig->GetReturn(0);
if (sig->parameter_count() == 1) { if (sig->parameter_count() == 1) {
return BuildSimpleOperator(opcode, ret, sig->GetParam(0)); // All current simple unary operators have exactly 1 return value.
DCHECK_EQ(1, sig->return_count());
return BuildSimpleOperator(opcode, sig->GetReturn(0), sig->GetParam(0));
} else { } else {
DCHECK_EQ(2, sig->parameter_count()); DCHECK_EQ(2, sig->parameter_count());
ValueType ret = sig->return_count() == 0 ? kWasmVoid : sig->GetReturn(0);
return BuildSimpleOperator(opcode, ret, sig->GetParam(0), return BuildSimpleOperator(opcode, ret, sig->GetParam(0),
sig->GetParam(1)); sig->GetParam(1));
} }
...@@ -5375,16 +5377,12 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -5375,16 +5377,12 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
int BuildSimpleOperator(WasmOpcode opcode, ValueType return_type, int BuildSimpleOperator(WasmOpcode opcode, ValueType return_type,
ValueType arg_type) { ValueType arg_type) {
DCHECK_NE(kWasmVoid, return_type);
Value val = Peek(0, 0, arg_type); Value val = Peek(0, 0, arg_type);
if (return_type == kWasmVoid) { Value ret = CreateValue(return_type);
CALL_INTERFACE_IF_OK_AND_REACHABLE(UnOp, opcode, val, nullptr); CALL_INTERFACE_IF_OK_AND_REACHABLE(UnOp, opcode, val, &ret);
Drop(val); Drop(val);
} else { Push(ret);
Value ret = CreateValue(return_type);
CALL_INTERFACE_IF_OK_AND_REACHABLE(UnOp, opcode, val, &ret);
Drop(val);
Push(ret);
}
return 1; return 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