Commit b3d18785 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[wasm][liftoff] Fix debug side table indexing

Take locals into account when computing the stack index for the next
control. Also include unwind in the list of blocks that have an implicit
exception reference on the stack.

R=ahaas@chromium.org

Bug: chromium:1183774
Change-Id: I29c67d286f1ec5efa9f2f80e13d083d6eff5836e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2794421Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73722}
parent 00afef3c
......@@ -3066,10 +3066,12 @@ class LiftoffCompiler {
for (int j = decoder->control_depth() - 1; j >= 0; j--) {
Control* control = decoder->control_at(j);
Control* next_control = j > 0 ? decoder->control_at(j - 1) : nullptr;
int end_index = next_control ? next_control->stack_depth +
next_control->num_exceptions
: __ cache_state()->stack_height();
bool exception = control->is_try_catch() || control->is_try_catchall();
int end_index = next_control
? next_control->stack_depth + __ num_locals() +
next_control->num_exceptions
: __ cache_state()->stack_height();
bool exception = control->is_try_catch() || control->is_try_catchall() ||
control->is_try_unwind();
for (; index < end_index; ++index) {
auto& slot = stack_state[index];
auto& value = values[index];
......
......@@ -433,7 +433,7 @@ TEST(Liftoff_debug_side_table_catch_all) {
int ex = env.builder()->AddException(sigs.v_v());
ValueType exception_type = ValueType::Ref(HeapType::kExtern, kNonNullable);
auto debug_side_table = env.GenerateDebugSideTable(
{}, {},
{}, {kWasmI32},
{WASM_TRY_CATCH_ALL_T(kWasmI32, WASM_STMTS(WASM_I32V(0), WASM_THROW(ex)),
WASM_I32V(1)),
WASM_DROP},
......@@ -443,10 +443,12 @@ TEST(Liftoff_debug_side_table_catch_all) {
CheckDebugSideTable(
{
// function entry.
{0, {}},
{1, {Register(0, kWasmI32)}},
// breakpoint.
{2, {Register(0, exception_type), Constant(1, kWasmI32, 1)}},
{0, {}},
{3,
{Stack(0, kWasmI32), Register(1, exception_type),
Constant(2, kWasmI32, 1)}},
{1, {}},
},
debug_side_table.get());
}
......
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