[wasm][interpreter][eh] Fix unreachable ref

The delegate instruction is executed when an exception is thrown, not
after the last instruction of the block. Handle reachability
accordingly.

R=ahaas@chromium.org

Bug: chromium:1212396
Change-Id: I55e342cd73da44142cfbad7e16ab65ef513e6a60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2928499
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74855}
This commit is contained in:
Thibaud Michaud 2021-05-31 11:26:42 +02:00 committed by V8 LUCI CQ
parent 67e97125eb
commit ca1a2cfb39
2 changed files with 12 additions and 1 deletions

View File

@ -699,6 +699,17 @@ TEST(Regress1197408) {
CHECK_EQ(0, r.CallInterpreter(0, 0, 0));
}
TEST(Regress1212396) {
TestSignatures sigs;
EXPERIMENTAL_FLAG_SCOPE(eh);
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
uint32_t except = r.builder().AddException(sigs.v_v());
BUILD(r, kExprTry, kVoidCode, kExprTry, kVoidCode, kExprI32Const, 0,
kExprThrow, except, kExprDelegate, 0, kExprCatch, except, kExprEnd,
kExprI32Const, 42);
CHECK_EQ(42, r.CallInterpreter());
}
} // namespace test_run_wasm_exceptions
} // namespace wasm
} // namespace internal

View File

@ -1005,7 +1005,7 @@ class SideTable : public ZoneObject {
Control* target = &control_stack[max_depth - imm.depth];
DCHECK_EQ(*target->pc, kExprTry);
DCHECK_NOT_NULL(target->else_label);
if (!unreachable) {
if (!control_parent().unreachable) {
target->else_label->Ref(i.pc(),
c->end_label->target_stack_height);
}