[wasm] Consider void returns in the int64-lowering

The int64-lowering lowers return nodes which return one int64 value into
a return node which returns two int32 values. For this lowering it has
to adjust the input count of the return operator.

The existing code assumed that if the signature of a function said that
the return type is int64, then all return nodes have int64 inputs.
However, with a recent CL we also introduced void returns. With this CL
I check if the number of inputs of a return node changes with the
DefaultLowering, and only if the number of inputs changes, then I check
if I also have to change the operator of the return node.

R=mstarzinger@chromium.org
TEST=mjsunit/regress/wasm/regression-6164
BUG=v8:6164

Change-Id: I004ab1b4be942cc045719f306705d95b48707a1c
Reviewed-on: https://chromium-review.googlesource.com/461941
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44232}
This commit is contained in:
Andreas Haas 2017-03-29 11:37:49 +02:00 committed by Commit Bot
parent 29f005e69b
commit 151cad81cf
2 changed files with 25 additions and 3 deletions

View File

@ -278,10 +278,13 @@ void Int64Lowering::LowerNode(Node* node) {
break; break;
} }
case IrOpcode::kReturn: { case IrOpcode::kReturn: {
int input_count = node->InputCount();
DefaultLowering(node); DefaultLowering(node);
int new_return_count = GetReturnCountAfterLowering(signature()); if (input_count != node->InputCount()) {
if (static_cast<int>(signature()->return_count()) != new_return_count) { int new_return_count = GetReturnCountAfterLowering(signature());
NodeProperties::ChangeOp(node, common()->Return(new_return_count)); if (static_cast<int>(signature()->return_count()) != new_return_count) {
NodeProperties::ChangeOp(node, common()->Return(new_return_count));
}
} }
break; break;
} }

View File

@ -0,0 +1,19 @@
// 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.
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
(function() {
var builder = new WasmModuleBuilder();
builder.addMemory(31, 31, false);
builder.addFunction('test', kSig_l_v)
.addBodyWithEnd([
// body:
kExprUnreachable,
kExprEnd, // @374
])
.exportFunc();
var module = builder.instantiate();
})();