Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: src/compiler/int64-lowering.cc

Issue 2080213004: Fix int64 lowering on big-endian architectures. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address code review remarks. Remove skipped tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/int64-lowering.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/int64-lowering.cc
diff --git a/src/compiler/int64-lowering.cc b/src/compiler/int64-lowering.cc
index 71f500886b40afe101ff6a32ed570ead578d0bfa..d40db7c1eddc40c3ed7b82bd5e11393e9f353c18 100644
--- a/src/compiler/int64-lowering.cc
+++ b/src/compiler/int64-lowering.cc
@@ -100,6 +100,35 @@ static int GetReturnCountAfterLowering(
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
+}
+
+int Int64Lowering::GetLowerWordOffset() {
titzer 2016/06/22 16:03:09 Can you go all the way and make these simple stati
ivica.bogosavljevic 2016/06/23 10:56:54 Acknowledged.
+#if defined(V8_TARGET_LITTLE_ENDIAN)
+ return 0;
+#elif defined(V8_TARGET_BIG_ENDIAN)
+ return 4;
+#endif
+}
+
+int Int64Lowering::GetHigherWordOffset() {
+#if defined(V8_TARGET_LITTLE_ENDIAN)
+ return 4;
+#elif defined(V8_TARGET_BIG_ENDIAN)
+ return 0;
+#endif
+}
+
void Int64Lowering::LowerNode(Node* node) {
switch (node->opcode()) {
case IrOpcode::kInt64Constant: {
@@ -117,10 +146,9 @@ void Int64Lowering::LowerNode(Node* node) {
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) {
@@ -134,6 +162,7 @@ void Int64Lowering::LowerNode(Node* node) {
} 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 {
@@ -152,10 +181,9 @@ void Int64Lowering::LowerNode(Node* node) {
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));
@@ -177,6 +205,7 @@ void Int64Lowering::LowerNode(Node* node) {
GetReplacementHigh(value));
}
+ node->ReplaceInput(1, index_low);
node->ReplaceInput(2, GetReplacementLow(value));
NodeProperties::ChangeOp(node, store_op);
ReplaceNode(node, node, high_node);
@@ -491,14 +520,16 @@ void Int64Lowering::LowerNode(Node* node) {
machine()->Store(
StoreRepresentation(MachineRepresentation::kWord32,
WriteBarrierKind::kNoWriteBarrier)),
- stack_slot, graph()->NewNode(common()->Int32Constant(4)),
+ stack_slot,
+ graph()->NewNode(common()->Int32Constant(GetHigherWordOffset())),
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(GetLowerWordOffset())),
GetReplacementLow(input), store_high_word, graph()->start());
Node* load =
@@ -524,15 +555,15 @@ void Int64Lowering::LowerNode(Node* node) {
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(GetHigherWordOffset())),
+ 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(GetLowerWordOffset())),
+ store, graph()->start());
ReplaceNode(node, low_node, high_node);
break;
}
« no previous file with comments | « src/compiler/int64-lowering.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698