Commit b2de7441 authored by Sven Sauleau's avatar Sven Sauleau Committed by Commit Bot

[wasm] fix special parameter in int64-lowering

In the int64 lowering pass some parameter nodes are considered special
and don't require any transformation. For instance the Wasm instance.

With the experimental-wasm-bigint proposal, two new special parameters
are going through the pass, this CL avoids transforming them.

Change-Id: Ie99ffaff125b9ef8c56e1883aac9e18e4072fc3e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1532336
Auto-Submit: Sven Sauleau <ssauleau@igalia.com>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Sven Sauleau <ssauleau@igalia.com>
Cr-Commit-Position: refs/heads/master@{#60404}
parent 84bc212c
......@@ -284,16 +284,16 @@ void Int64Lowering::LowerNode(Node* node) {
}
case IrOpcode::kParameter: {
DCHECK_EQ(1, node->InputCount());
int paramCount = static_cast<int>(signature()->parameter_count());
// Only exchange the node if the parameter count actually changed. We do
// not even have to do the default lowering because the the start node,
// the only input of a parameter node, only changes if the parameter count
// changes.
if (GetParameterCountAfterLowering(signature()) !=
static_cast<int>(signature()->parameter_count())) {
if (GetParameterCountAfterLowering(signature()) != paramCount) {
int old_index = ParameterIndexOf(node->op());
// TODO(wasm): Make this part not wasm specific.
// Prevent special lowering of the instance parameter.
if (old_index == wasm::kWasmInstanceParameterIndex) {
// Prevent special lowering of wasm's instance or JS
// context/closure parameters.
if (old_index <= 0 || old_index > paramCount) {
DefaultLowering(node);
break;
}
......
......@@ -322,6 +322,40 @@ TEST_F(Int64LoweringTest, Parameter2) {
EXPECT_THAT(start()->op()->ValueOutputCount(), start_parameter + 2);
}
TEST_F(Int64LoweringTest, ParameterWithJSContextParam) {
Signature<MachineRepresentation>::Builder sig_builder(zone(), 0, 2);
sig_builder.AddParam(MachineRepresentation::kWord64);
sig_builder.AddParam(MachineRepresentation::kWord64);
auto sig = sig_builder.Build();
Node* js_context = graph()->NewNode(
common()->Parameter(Linkage::GetJSCallContextParamIndex(
static_cast<int>(sig->parameter_count()) + 1),
"%context"),
start());
LowerGraph(js_context, sig);
EXPECT_THAT(graph()->end()->InputAt(1),
IsReturn(js_context, start(), start()));
}
TEST_F(Int64LoweringTest, ParameterWithJSClosureParam) {
Signature<MachineRepresentation>::Builder sig_builder(zone(), 0, 2);
sig_builder.AddParam(MachineRepresentation::kWord64);
sig_builder.AddParam(MachineRepresentation::kWord64);
auto sig = sig_builder.Build();
Node* js_closure = graph()->NewNode(
common()->Parameter(Linkage::kJSCallClosureParamIndex, "%closure"),
start());
LowerGraph(js_closure, sig);
EXPECT_THAT(graph()->end()->InputAt(1),
IsReturn(js_closure, start(), start()));
}
// The following tests assume that pointers are 32 bit and therefore pointers do
// not get lowered. This assumption does not hold on 64 bit platforms, which
// invalidates these tests.
......
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