Skip to content

Commit ca1a2cf

Browse files
thibaudmichaudV8 LUCI CQ
authored andcommitted
[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}
1 parent 67e9712 commit ca1a2cf

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

test/cctest/wasm/test-run-wasm-exceptions.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,17 @@ TEST(Regress1197408) {
699699
CHECK_EQ(0, r.CallInterpreter(0, 0, 0));
700700
}
701701

702+
TEST(Regress1212396) {
703+
TestSignatures sigs;
704+
EXPERIMENTAL_FLAG_SCOPE(eh);
705+
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
706+
uint32_t except = r.builder().AddException(sigs.v_v());
707+
BUILD(r, kExprTry, kVoidCode, kExprTry, kVoidCode, kExprI32Const, 0,
708+
kExprThrow, except, kExprDelegate, 0, kExprCatch, except, kExprEnd,
709+
kExprI32Const, 42);
710+
CHECK_EQ(42, r.CallInterpreter());
711+
}
712+
702713
} // namespace test_run_wasm_exceptions
703714
} // namespace wasm
704715
} // namespace internal

test/common/wasm/wasm-interpreter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ class SideTable : public ZoneObject {
10051005
Control* target = &control_stack[max_depth - imm.depth];
10061006
DCHECK_EQ(*target->pc, kExprTry);
10071007
DCHECK_NOT_NULL(target->else_label);
1008-
if (!unreachable) {
1008+
if (!control_parent().unreachable) {
10091009
target->else_label->Ref(i.pc(),
10101010
c->end_label->target_stack_height);
10111011
}

0 commit comments

Comments
 (0)