Commit 16b83b1b authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[wasm] Fix interpreter multi-value stack height issue

Block inputs are removed from the stack. Set expected stack height
accordingly.

R=ahaas@chromium.org

Bug: v8:9867
Change-Id: I7e3fd2985c0e77e83d5551cac613788f3cf0a370
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1872404
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64465}
parent 2d4fe83a
...@@ -221,11 +221,14 @@ class InterpreterHandle { ...@@ -221,11 +221,14 @@ class InterpreterHandle {
} }
// Copy back the return value. // Copy back the return value.
DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); #ifdef DEBUG
// TODO(wasm): Handle multi-value returns. const int max_count = WasmFeaturesFromIsolate(isolate_).mv
DCHECK_EQ(1, kV8MaxWasmFunctionReturns); ? kV8MaxWasmFunctionMultiReturns
if (sig->return_count()) { : kV8MaxWasmFunctionReturns;
return_values[0] = thread->GetReturnValue(0); #endif
DCHECK_GE(max_count, sig->return_count());
for (unsigned i = 0; i < sig->return_count(); ++i) {
return_values[i] = thread->GetReturnValue(i);
} }
FinishActivation(frame_pointer, activation_id); FinishActivation(frame_pointer, activation_id);
......
...@@ -826,7 +826,7 @@ class SideTable : public ZoneObject { ...@@ -826,7 +826,7 @@ class SideTable : public ZoneObject {
TRACE("control @%u: %s, arity %d->%d\n", i.pc_offset(), TRACE("control @%u: %s, arity %d->%d\n", i.pc_offset(),
is_loop ? "Loop" : "Block", imm.in_arity(), imm.out_arity()); is_loop ? "Loop" : "Block", imm.in_arity(), imm.out_arity());
CLabel* label = CLabel* label =
CLabel::New(&control_transfer_zone, stack_height, CLabel::New(&control_transfer_zone, stack_height - imm.in_arity(),
is_loop ? imm.in_arity() : imm.out_arity()); is_loop ? imm.in_arity() : imm.out_arity());
control_stack.emplace_back(i.pc(), label, imm.out_arity()); control_stack.emplace_back(i.pc(), label, imm.out_arity());
copy_unreachable(); copy_unreachable();
...@@ -841,8 +841,9 @@ class SideTable : public ZoneObject { ...@@ -841,8 +841,9 @@ class SideTable : public ZoneObject {
} }
TRACE("control @%u: If, arity %d->%d\n", i.pc_offset(), TRACE("control @%u: If, arity %d->%d\n", i.pc_offset(),
imm.in_arity(), imm.out_arity()); imm.in_arity(), imm.out_arity());
CLabel* end_label = CLabel::New(&control_transfer_zone, stack_height, CLabel* end_label =
imm.out_arity()); CLabel::New(&control_transfer_zone, stack_height - imm.in_arity(),
imm.out_arity());
CLabel* else_label = CLabel* else_label =
CLabel::New(&control_transfer_zone, stack_height, 0); CLabel::New(&control_transfer_zone, stack_height, 0);
control_stack.emplace_back(i.pc(), end_label, else_label, control_stack.emplace_back(i.pc(), end_label, else_label,
...@@ -861,9 +862,9 @@ class SideTable : public ZoneObject { ...@@ -861,9 +862,9 @@ class SideTable : public ZoneObject {
DCHECK_NOT_NULL(c->else_label); DCHECK_NOT_NULL(c->else_label);
c->else_label->Bind(i.pc() + 1); c->else_label->Bind(i.pc() + 1);
c->else_label->Finish(&map_, code->orig_start); c->else_label->Finish(&map_, code->orig_start);
stack_height = c->else_label->target_stack_height;
c->else_label = nullptr; c->else_label = nullptr;
DCHECK_GE(stack_height, c->end_label->target_stack_height); DCHECK_GE(stack_height, c->end_label->target_stack_height);
stack_height = c->end_label->target_stack_height;
break; break;
} }
case kExprTry: { case kExprTry: {
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-mv --wasm-interpret-all
load("test/mjsunit/wasm/multi-value.js");
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