[wasm-gc] Add missing types to Int64Lowering
Drive-by: Make the code less verbose my returning the input node from SetInt32Type. Bug: v8:7748, chromium:1332385 Change-Id: I2fde9c2168af1365e305e7e8d894b03487e8a8d9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3687692 Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Cr-Commit-Position: refs/heads/main@{#80970}
This commit is contained in:
parent
886838b9cd
commit
c202e30109
@ -127,12 +127,14 @@ int GetReturnCountAfterLowering(Signature<MachineRepresentation>* signature) {
|
||||
|
||||
} // namespace
|
||||
|
||||
void Int64Lowering::SetInt32Type(Node* node) {
|
||||
Node* Int64Lowering::SetInt32Type(Node* node) {
|
||||
NodeProperties::SetType(node, int32_type_);
|
||||
return node;
|
||||
}
|
||||
|
||||
void Int64Lowering::SetFloat64Type(Node* node) {
|
||||
Node* Int64Lowering::SetFloat64Type(Node* node) {
|
||||
NodeProperties::SetType(node, float64_type_);
|
||||
return node;
|
||||
}
|
||||
|
||||
void Int64Lowering::LowerWord64AtomicBinop(Node* node, const Operator* op) {
|
||||
@ -142,7 +144,6 @@ void Int64Lowering::LowerWord64AtomicBinop(Node* node, const Operator* op) {
|
||||
node->ReplaceInput(2, GetReplacementLow(value));
|
||||
node->InsertInput(zone(), 3, GetReplacementHigh(value));
|
||||
NodeProperties::ChangeOp(node, op);
|
||||
SetInt32Type(node);
|
||||
ReplaceNodeWithProjections(node);
|
||||
}
|
||||
|
||||
@ -204,9 +205,7 @@ void Int64Lowering::LowerLoadOperator(Node* node, MachineRepresentation rep,
|
||||
}
|
||||
node->ReplaceInput(1, index_low);
|
||||
NodeProperties::ChangeOp(node, load_op);
|
||||
SetInt32Type(node);
|
||||
SetInt32Type(high_node);
|
||||
ReplaceNode(node, node, high_node);
|
||||
ReplaceNode(node, SetInt32Type(node), SetInt32Type(high_node));
|
||||
} else {
|
||||
DefaultLowering(node);
|
||||
}
|
||||
@ -362,10 +361,9 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
|
||||
if (signature()->GetParam(old_index) ==
|
||||
MachineRepresentation::kWord64) {
|
||||
Node* high_node = graph()->NewNode(common()->Parameter(new_index + 1),
|
||||
graph()->start());
|
||||
SetInt32Type(node);
|
||||
SetInt32Type(high_node);
|
||||
Node* high_node = SetInt32Type(graph()->NewNode(
|
||||
common()->Parameter(new_index + 1), graph()->start()));
|
||||
ReplaceNode(node, node, high_node);
|
||||
}
|
||||
}
|
||||
@ -429,9 +427,9 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
}
|
||||
if (call_descriptor->GetReturnType(old_index).representation() ==
|
||||
MachineRepresentation::kWord64) {
|
||||
Node* high_node = graph()->NewNode(
|
||||
common()->Projection(new_index + 1), node, graph()->start());
|
||||
ReplaceNode(use_node, use_node, high_node);
|
||||
Node* high_node = SetInt32Type(graph()->NewNode(
|
||||
common()->Projection(new_index + 1), node, graph()->start()));
|
||||
ReplaceNode(use_node, SetInt32Type(use_node), high_node);
|
||||
++new_index;
|
||||
}
|
||||
}
|
||||
@ -444,14 +442,12 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
Node* left = node->InputAt(0);
|
||||
Node* right = node->InputAt(1);
|
||||
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->Word32And(), GetReplacementLow(left),
|
||||
GetReplacementLow(right));
|
||||
Node* high_node =
|
||||
Node* low_node = SetInt32Type(graph()->NewNode(machine()->Word32And(),
|
||||
GetReplacementLow(left),
|
||||
GetReplacementLow(right)));
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32And(), GetReplacementHigh(left),
|
||||
GetReplacementHigh(right));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
GetReplacementHigh(right)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
break;
|
||||
}
|
||||
@ -515,14 +511,12 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
Node* left = node->InputAt(0);
|
||||
Node* right = node->InputAt(1);
|
||||
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->Word32Or(), GetReplacementLow(left),
|
||||
GetReplacementLow(right));
|
||||
Node* high_node =
|
||||
Node* low_node = SetInt32Type(graph()->NewNode(machine()->Word32Or(),
|
||||
GetReplacementLow(left),
|
||||
GetReplacementLow(right)));
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Or(), GetReplacementHigh(left),
|
||||
GetReplacementHigh(right));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
GetReplacementHigh(right)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
break;
|
||||
}
|
||||
@ -531,14 +525,12 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
Node* left = node->InputAt(0);
|
||||
Node* right = node->InputAt(1);
|
||||
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->Word32Xor(), GetReplacementLow(left),
|
||||
GetReplacementLow(right));
|
||||
Node* high_node =
|
||||
Node* low_node = SetInt32Type(graph()->NewNode(machine()->Word32Xor(),
|
||||
GetReplacementLow(left),
|
||||
GetReplacementLow(right)));
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left),
|
||||
GetReplacementHigh(right));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
GetReplacementHigh(right)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
break;
|
||||
}
|
||||
@ -617,9 +609,7 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left),
|
||||
GetReplacementHigh(right))),
|
||||
graph()->NewNode(common()->Int32Constant(0)));
|
||||
|
||||
SetInt32Type(replacement);
|
||||
ReplaceNode(node, replacement, nullptr);
|
||||
ReplaceNode(node, SetInt32Type(replacement), nullptr);
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kInt64LessThan: {
|
||||
@ -650,10 +640,9 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
input = GetReplacementLow(input);
|
||||
}
|
||||
// We use SAR to preserve the sign in the high word.
|
||||
Node* high_node =
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Sar(), input,
|
||||
graph()->NewNode(common()->Int32Constant(31)));
|
||||
SetInt32Type(high_node);
|
||||
graph()->NewNode(common()->Int32Constant(31))));
|
||||
ReplaceNode(node, input, high_node);
|
||||
node->NullAllInputs();
|
||||
break;
|
||||
@ -689,12 +678,10 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
input = GetReplacementLow(input);
|
||||
}
|
||||
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->Float64ExtractLowWord32(), input);
|
||||
Node* high_node =
|
||||
graph()->NewNode(machine()->Float64ExtractHighWord32(), input);
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
Node* low_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Float64ExtractLowWord32(), input));
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Float64ExtractHighWord32(), input));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
break;
|
||||
}
|
||||
@ -738,16 +725,14 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
bool is_ror = node->opcode() == IrOpcode::kWord64RorLowerable;
|
||||
if (!is_ror) std::swap(op1, op2);
|
||||
|
||||
Node* low_node =
|
||||
Node* low_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Or(),
|
||||
graph()->NewNode(op1, low_input, masked_shift),
|
||||
graph()->NewNode(op2, high_input, inv_shift));
|
||||
Node* high_node =
|
||||
graph()->NewNode(op2, high_input, inv_shift)));
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Or(),
|
||||
graph()->NewNode(op1, high_input, masked_shift),
|
||||
graph()->NewNode(op2, low_input, inv_shift));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
graph()->NewNode(op2, low_input, inv_shift)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
}
|
||||
} else {
|
||||
@ -812,16 +797,14 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
auto* mask2 = inv_mask;
|
||||
if (!is_ror) std::swap(mask1, mask2);
|
||||
|
||||
Node* low_node = graph()->NewNode(
|
||||
Node* low_node = SetInt32Type(graph()->NewNode(
|
||||
machine()->Word32Or(),
|
||||
graph()->NewNode(machine()->Word32And(), rotate_low, mask1),
|
||||
graph()->NewNode(machine()->Word32And(), rotate_high, mask2));
|
||||
Node* high_node = graph()->NewNode(
|
||||
graph()->NewNode(machine()->Word32And(), rotate_high, mask2)));
|
||||
Node* high_node = SetInt32Type(graph()->NewNode(
|
||||
machine()->Word32Or(),
|
||||
graph()->NewNode(machine()->Word32And(), rotate_high, mask1),
|
||||
graph()->NewNode(machine()->Word32And(), rotate_low, mask2));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
graph()->NewNode(machine()->Word32And(), rotate_low, mask2)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
}
|
||||
break;
|
||||
@ -842,8 +825,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
GetReplacementLow(input)),
|
||||
graph()->NewNode(common()->Int32Constant(32))),
|
||||
graph()->NewNode(machine()->Word32Clz(), GetReplacementHigh(input)));
|
||||
SetInt32Type(low_node);
|
||||
ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
|
||||
ReplaceNode(node, SetInt32Type(low_node),
|
||||
SetInt32Type(graph()->NewNode(common()->Int32Constant(0))));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kWord64CtzLowerable: {
|
||||
@ -864,8 +847,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
graph()->NewNode(common()->Int32Constant(32))),
|
||||
graph()->NewNode(machine()->Word32Ctz().op(),
|
||||
GetReplacementLow(input)));
|
||||
SetInt32Type(low_node);
|
||||
ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
|
||||
ReplaceNode(node, SetInt32Type(low_node),
|
||||
SetInt32Type(graph()->NewNode(common()->Int32Constant(0))));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kWord64Ror:
|
||||
@ -886,8 +869,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
GetReplacementLow(input)),
|
||||
graph()->NewNode(machine()->Word32Popcnt().op(),
|
||||
GetReplacementHigh(input)));
|
||||
SetInt32Type(low_node);
|
||||
ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
|
||||
ReplaceNode(node, SetInt32Type(low_node),
|
||||
SetInt32Type(graph()->NewNode(common()->Int32Constant(0))));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kPhi: {
|
||||
@ -909,14 +892,12 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
case IrOpcode::kLoopExitValue: {
|
||||
MachineRepresentation rep = LoopExitValueRepresentationOf(node->op());
|
||||
if (rep == MachineRepresentation::kWord64) {
|
||||
Node* low_node = graph()->NewNode(
|
||||
Node* low_node = SetInt32Type(graph()->NewNode(
|
||||
common()->LoopExitValue(MachineRepresentation::kWord32),
|
||||
GetReplacementLow(node->InputAt(0)), node->InputAt(1));
|
||||
Node* high_node = graph()->NewNode(
|
||||
GetReplacementLow(node->InputAt(0)), node->InputAt(1)));
|
||||
Node* high_node = SetInt32Type(graph()->NewNode(
|
||||
common()->LoopExitValue(MachineRepresentation::kWord32),
|
||||
GetReplacementHigh(node->InputAt(0)), node->InputAt(1));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
GetReplacementHigh(node->InputAt(0)), node->InputAt(1)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
} else {
|
||||
DefaultLowering(node);
|
||||
@ -925,12 +906,10 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
}
|
||||
case IrOpcode::kWord64ReverseBytes: {
|
||||
Node* input = node->InputAt(0);
|
||||
Node* low_node = graph()->NewNode(machine()->Word32ReverseBytes(),
|
||||
GetReplacementHigh(input));
|
||||
Node* high_node = graph()->NewNode(machine()->Word32ReverseBytes(),
|
||||
GetReplacementLow(input));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
Node* low_node = SetInt32Type(graph()->NewNode(
|
||||
machine()->Word32ReverseBytes(), GetReplacementHigh(input)));
|
||||
Node* high_node = SetInt32Type(graph()->NewNode(
|
||||
machine()->Word32ReverseBytes(), GetReplacementLow(input)));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
break;
|
||||
}
|
||||
@ -941,14 +920,12 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
input = GetReplacementLow(input);
|
||||
}
|
||||
// Sign extend low node to Int32
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->SignExtendWord8ToInt32(), input);
|
||||
Node* low_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->SignExtendWord8ToInt32(), input));
|
||||
// We use SAR to preserve the sign in the high word.
|
||||
Node* high_node =
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Sar(), low_node,
|
||||
graph()->NewNode(common()->Int32Constant(31)));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
graph()->NewNode(common()->Int32Constant(31))));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
node->NullAllInputs();
|
||||
break;
|
||||
@ -960,14 +937,12 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
input = GetReplacementLow(input);
|
||||
}
|
||||
// Sign extend low node to Int32
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->SignExtendWord16ToInt32(), input);
|
||||
Node* low_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->SignExtendWord16ToInt32(), input));
|
||||
// We use SAR to preserve the sign in the high word.
|
||||
Node* high_node =
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->Word32Sar(), low_node,
|
||||
graph()->NewNode(common()->Int32Constant(31)));
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
graph()->NewNode(common()->Int32Constant(31))));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
node->NullAllInputs();
|
||||
break;
|
||||
@ -982,8 +957,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
ReplaceNodeWithProjections(node);
|
||||
} else {
|
||||
NodeProperties::ChangeOp(node, machine()->Word32AtomicLoad(params));
|
||||
SetInt32Type(node);
|
||||
ReplaceNode(node, node, graph()->NewNode(common()->Int32Constant(0)));
|
||||
ReplaceNode(node, SetInt32Type(node),
|
||||
SetInt32Type(graph()->NewNode(common()->Int32Constant(0))));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1039,8 +1014,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
DefaultLowering(node, true);
|
||||
NodeProperties::ChangeOp(node,
|
||||
machine()->Word32AtomicCompareExchange(type));
|
||||
SetInt32Type(node);
|
||||
ReplaceNode(node, node, graph()->NewNode(common()->Int32Constant(0)));
|
||||
ReplaceNode(node, SetInt32Type(node),
|
||||
SetInt32Type(graph()->NewNode(common()->Int32Constant(0))));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1056,12 +1031,10 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
DCHECK_EQ(1, node->InputCount());
|
||||
Node* input = node->InputAt(0);
|
||||
int32_t lane = OpParameter<int32_t>(node->op());
|
||||
Node* low_node =
|
||||
graph()->NewNode(machine()->I32x4ExtractLane(lane * 2), input);
|
||||
Node* high_node =
|
||||
graph()->NewNode(machine()->I32x4ExtractLane(lane * 2 + 1), input);
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
Node* low_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->I32x4ExtractLane(lane * 2), input));
|
||||
Node* high_node = SetInt32Type(
|
||||
graph()->NewNode(machine()->I32x4ExtractLane(lane * 2 + 1), input));
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
break;
|
||||
}
|
||||
@ -1094,8 +1067,7 @@ void Int64Lowering::LowerComparison(Node* node, const Operator* high_word_op,
|
||||
GetReplacementHigh(right)),
|
||||
graph()->NewNode(low_word_op, GetReplacementLow(left),
|
||||
GetReplacementLow(right))));
|
||||
SetInt32Type(replacement);
|
||||
ReplaceNode(node, replacement, nullptr);
|
||||
ReplaceNode(node, SetInt32Type(replacement), nullptr);
|
||||
}
|
||||
|
||||
bool Int64Lowering::DefaultLowering(Node* node, bool low_word_only) {
|
||||
@ -1184,9 +1156,7 @@ void Int64Lowering::ReplaceNodeWithProjections(Node* node) {
|
||||
graph()->NewNode(common()->Projection(0), node, graph()->start());
|
||||
Node* high_node =
|
||||
graph()->NewNode(common()->Projection(1), node, graph()->start());
|
||||
SetInt32Type(low_node);
|
||||
SetInt32Type(high_node);
|
||||
ReplaceNode(node, low_node, high_node);
|
||||
ReplaceNode(node, SetInt32Type(low_node), SetInt32Type(high_node));
|
||||
}
|
||||
|
||||
void Int64Lowering::LowerMemoryBaseAndIndex(Node* node) {
|
||||
|
@ -73,8 +73,8 @@ class V8_EXPORT_PRIVATE Int64Lowering {
|
||||
|
||||
const CallDescriptor* LowerCallDescriptor(
|
||||
const CallDescriptor* call_descriptor);
|
||||
void SetInt32Type(Node* node);
|
||||
void SetFloat64Type(Node* node);
|
||||
Node* SetInt32Type(Node* node);
|
||||
Node* SetFloat64Type(Node* node);
|
||||
|
||||
void ReplaceNode(Node* old, Node* new_low, Node* new_high);
|
||||
bool HasReplacementLow(Node* node);
|
||||
|
Loading…
Reference in New Issue
Block a user