Commit 37430ba3 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by V8 LUCI CQ

[wasm] Move misplaced DCHECK in wasm interpreter

When handling the 'end' opcode, there was a confusion with the value of
"unreachable". This DCHECK assumes the value of "unreachable" before
closing the scope, but was placed after the value is potentially updated
to reflect the state after the 'end' opcode.

R=clemensb@chromium.org

Bug: chromium:1251845
Change-Id: Iea526e6485fa705f6ff4077f54a53204cc70a926
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3190102Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77116}
parent 44b68bc2
......@@ -524,12 +524,25 @@ TEST(Regress1246712) {
TEST(Regress1249306) {
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
TestSignatures sigs;
BUILD(r, kExprTry, kVoid, kExprCatchAll, kExprTry, kVoid, kExprDelegate, 0,
kExprEnd, kExprI32Const, 0);
r.Call();
}
TEST(Regress1251845) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(
TestExecutionTier::kInterpreter);
ValueType reps[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32};
FunctionSig sig_iii_i(1, 3, reps);
byte sig = r.builder().AddSignature(&sig_iii_i);
BUILD(r, kExprI32Const, 0, kExprI32Const, 0, kExprI32Const, 0, kExprTry, sig,
kExprI32Const, 0, kExprTry, 0, kExprTry, 0, kExprI32Const, 0, kExprTry,
sig, kExprUnreachable, kExprTry, 0, kExprUnreachable, kExprEnd,
kExprTry, sig, kExprUnreachable, kExprEnd, kExprEnd, kExprUnreachable,
kExprEnd, kExprEnd, kExprUnreachable, kExprEnd);
r.Call(0, 0, 0);
}
} // namespace test_run_wasm_interpreter
} // namespace wasm
} // namespace internal
......
......@@ -929,6 +929,9 @@ class SideTable : public ZoneObject {
// Bind else label for one-armed if.
c->else_label->Bind(i.pc());
} else if (!exception_stack.empty()) {
DCHECK_IMPLIES(
!unreachable,
stack_height >= c->else_label->target_stack_height);
// No catch_all block, prepare for implicit rethrow.
if (exception_stack.back() == control_stack.size() - 1) {
// Close try scope for catch-less try.
......@@ -940,9 +943,6 @@ class SideTable : public ZoneObject {
constexpr int kUnusedControlIndex = -1;
c->else_label->Bind(i.pc(), kRethrowOrDelegateExceptionIndex,
kUnusedControlIndex);
DCHECK_IMPLIES(
!unreachable,
stack_height >= c->else_label->target_stack_height);
stack_height = c->else_label->target_stack_height;
rethrow = !unreachable && !exception_stack.empty();
}
......
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