Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/compiler/int64-lowering.cc b/src/compiler/int64-lowering.cc
index 830a0de..68d3772 100644
--- a/src/compiler/int64-lowering.cc
+++ b/src/compiler/int64-lowering.cc
@@ -32,6 +32,8 @@
signature_(signature),
placeholder_(graph->NewNode(common->Parameter(-2, "placeholder"),
graph->start())) {
+ DCHECK_NOT_NULL(graph);
+ DCHECK_NOT_NULL(graph->end());
replacements_ = zone->NewArray<Replacement>(graph->NodeCount());
memset(replacements_, 0, sizeof(Replacement) * graph->NodeCount());
}
@@ -98,6 +100,27 @@
return result;
}
+void Int64Lowering::GetIndexNodes(Node* index, Node*& index_low,
+ Node*& index_high) {
+#if defined(V8_TARGET_LITTLE_ENDIAN)
+ index_low = index;
+ index_high = graph()->NewNode(machine()->Int32Add(), index,
+ graph()->NewNode(common()->Int32Constant(4)));
+#elif defined(V8_TARGET_BIG_ENDIAN)
+ index_low = graph()->NewNode(machine()->Int32Add(), index,
+ graph()->NewNode(common()->Int32Constant(4)));
+ index_high = index;
+#endif
+}
+
+#if defined(V8_TARGET_LITTLE_ENDIAN)
+const int Int64Lowering::kLowerWordOffset = 0;
+const int Int64Lowering::kHigherWordOffset = 4;
+#elif defined(V8_TARGET_BIG_ENDIAN)
+const int Int64Lowering::kLowerWordOffset = 4;
+const int Int64Lowering::kHigherWordOffset = 0;
+#endif
+
void Int64Lowering::LowerNode(Node* node) {
switch (node->opcode()) {
case IrOpcode::kInt64Constant: {
@@ -115,10 +138,9 @@
if (load_rep.representation() == MachineRepresentation::kWord64) {
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
- Node* index_high =
- graph()->NewNode(machine()->Int32Add(), index,
- graph()->NewNode(common()->Int32Constant(4)));
-
+ Node* index_low;
+ Node* index_high;
+ GetIndexNodes(index, index_low, index_high);
const Operator* load_op = machine()->Load(MachineType::Int32());
Node* high_node;
if (node->InputCount() > 2) {
@@ -132,6 +154,7 @@
} else {
high_node = graph()->NewNode(load_op, base, index_high);
}
+ node->ReplaceInput(1, index_low);
NodeProperties::ChangeOp(node, load_op);
ReplaceNode(node, node, high_node);
} else {
@@ -150,10 +173,9 @@
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
- Node* index_high =
- graph()->NewNode(machine()->Int32Add(), index,
- graph()->NewNode(common()->Int32Constant(4)));
-
+ Node* index_low;
+ Node* index_high;
+ GetIndexNodes(index, index_low, index_high);
Node* value = node->InputAt(2);
DCHECK(HasReplacementLow(value));
DCHECK(HasReplacementHigh(value));
@@ -175,6 +197,7 @@
GetReplacementHigh(value));
}
+ node->ReplaceInput(1, index_low);
node->ReplaceInput(2, GetReplacementLow(value));
NodeProperties::ChangeOp(node, store_op);
ReplaceNode(node, node, high_node);
@@ -241,8 +264,10 @@
if (descriptor->ReturnCount() == 1 &&
descriptor->GetReturnType(0) == MachineType::Int64()) {
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
}
break;
@@ -281,8 +306,10 @@
NodeProperties::ChangeOp(node, machine()->Int32PairAdd());
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
@@ -299,8 +326,10 @@
NodeProperties::ChangeOp(node, machine()->Int32PairSub());
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
@@ -317,8 +346,10 @@
NodeProperties::ChangeOp(node, machine()->Int32PairMul());
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
@@ -367,8 +398,10 @@
NodeProperties::ChangeOp(node, machine()->Word32PairShl());
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
@@ -389,8 +422,10 @@
NodeProperties::ChangeOp(node, machine()->Word32PairShr());
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
@@ -411,8 +446,10 @@
NodeProperties::ChangeOp(node, machine()->Word32PairSar());
// We access the additional return values through projections.
- Node* low_node = graph()->NewNode(common()->Projection(0), node);
- Node* high_node = graph()->NewNode(common()->Projection(1), node);
+ Node* low_node =
+ graph()->NewNode(common()->Projection(0), node, graph()->start());
+ Node* high_node =
+ graph()->NewNode(common()->Projection(1), node, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
@@ -489,14 +526,16 @@
machine()->Store(
StoreRepresentation(MachineRepresentation::kWord32,
WriteBarrierKind::kNoWriteBarrier)),
- stack_slot, graph()->NewNode(common()->Int32Constant(4)),
+ stack_slot,
+ graph()->NewNode(common()->Int32Constant(kHigherWordOffset)),
GetReplacementHigh(input), graph()->start(), graph()->start());
Node* store_low_word = graph()->NewNode(
machine()->Store(
StoreRepresentation(MachineRepresentation::kWord32,
WriteBarrierKind::kNoWriteBarrier)),
- stack_slot, graph()->NewNode(common()->Int32Constant(0)),
+ stack_slot,
+ graph()->NewNode(common()->Int32Constant(kLowerWordOffset)),
GetReplacementLow(input), store_high_word, graph()->start());
Node* load =
@@ -522,15 +561,15 @@
stack_slot, graph()->NewNode(common()->Int32Constant(0)), input,
graph()->start(), graph()->start());
- Node* high_node =
- graph()->NewNode(machine()->Load(MachineType::Int32()), stack_slot,
- graph()->NewNode(common()->Int32Constant(4)), store,
- graph()->start());
+ Node* high_node = graph()->NewNode(
+ machine()->Load(MachineType::Int32()), stack_slot,
+ graph()->NewNode(common()->Int32Constant(kHigherWordOffset)), store,
+ graph()->start());
- Node* low_node =
- graph()->NewNode(machine()->Load(MachineType::Int32()), stack_slot,
- graph()->NewNode(common()->Int32Constant(0)), store,
- graph()->start());
+ Node* low_node = graph()->NewNode(
+ machine()->Load(MachineType::Int32()), stack_slot,
+ graph()->NewNode(common()->Int32Constant(kLowerWordOffset)), store,
+ graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}