| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
| 6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
| 7 #include "src/compiler/node-properties.h" |
| 7 | 8 |
| 8 namespace v8 { | 9 namespace v8 { |
| 9 namespace internal { | 10 namespace internal { |
| 10 namespace compiler { | 11 namespace compiler { |
| 11 | 12 |
| 12 // Adds X64-specific methods for generating operands. | 13 // Adds X64-specific methods for generating operands. |
| 13 class X64OperandGenerator FINAL : public OperandGenerator { | 14 class X64OperandGenerator FINAL : public OperandGenerator { |
| 14 public: | 15 public: |
| 15 explicit X64OperandGenerator(InstructionSelector* selector) | 16 explicit X64OperandGenerator(InstructionSelector* selector) |
| 16 : OperandGenerator(selector) {} | 17 : OperandGenerator(selector) {} |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 frame_state_descriptor = GetFrameStateDescriptor( | 932 frame_state_descriptor = GetFrameStateDescriptor( |
| 932 node->InputAt(static_cast<int>(descriptor->InputCount()))); | 933 node->InputAt(static_cast<int>(descriptor->InputCount()))); |
| 933 } | 934 } |
| 934 | 935 |
| 935 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 936 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
| 936 | 937 |
| 937 // Compute InstructionOperands for inputs and outputs. | 938 // Compute InstructionOperands for inputs and outputs. |
| 938 InitializeCallBuffer(node, &buffer, true, true); | 939 InitializeCallBuffer(node, &buffer, true, true); |
| 939 | 940 |
| 940 // Push any stack arguments. | 941 // Push any stack arguments. |
| 941 for (NodeVectorRIter input = buffer.pushed_nodes.rbegin(); | 942 for (auto i = buffer.pushed_nodes.rbegin(); i != buffer.pushed_nodes.rend(); |
| 942 input != buffer.pushed_nodes.rend(); input++) { | 943 ++i) { |
| 943 // TODO(titzer): handle pushing double parameters. | 944 // TODO(titzer): handle pushing double parameters. |
| 944 Emit(kX64Push, NULL, | 945 Emit(kX64Push, nullptr, |
| 945 g.CanBeImmediate(*input) ? g.UseImmediate(*input) : g.Use(*input)); | 946 g.CanBeImmediate(*i) ? g.UseImmediate(*i) : g.Use(*i)); |
| 946 } | 947 } |
| 947 | 948 |
| 948 // Select the appropriate opcode based on the call type. | 949 // Select the appropriate opcode based on the call type. |
| 949 InstructionCode opcode; | 950 InstructionCode opcode; |
| 950 switch (descriptor->kind()) { | 951 switch (descriptor->kind()) { |
| 951 case CallDescriptor::kCallCodeObject: { | 952 case CallDescriptor::kCallCodeObject: { |
| 952 opcode = kArchCallCodeObject; | 953 opcode = kArchCallCodeObject; |
| 953 break; | 954 break; |
| 954 } | 955 } |
| 955 case CallDescriptor::kCallJSFunction: | 956 case CallDescriptor::kCallJSFunction: |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 return VisitFloat64Compare(this, value, &cont); | 1105 return VisitFloat64Compare(this, value, &cont); |
| 1105 case IrOpcode::kFloat64LessThan: | 1106 case IrOpcode::kFloat64LessThan: |
| 1106 cont.OverwriteAndNegateIfEqual(kUnsignedGreaterThan); | 1107 cont.OverwriteAndNegateIfEqual(kUnsignedGreaterThan); |
| 1107 return VisitFloat64Compare(this, value, &cont); | 1108 return VisitFloat64Compare(this, value, &cont); |
| 1108 case IrOpcode::kFloat64LessThanOrEqual: | 1109 case IrOpcode::kFloat64LessThanOrEqual: |
| 1109 cont.OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); | 1110 cont.OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); |
| 1110 return VisitFloat64Compare(this, value, &cont); | 1111 return VisitFloat64Compare(this, value, &cont); |
| 1111 case IrOpcode::kProjection: | 1112 case IrOpcode::kProjection: |
| 1112 // Check if this is the overflow output projection of an | 1113 // Check if this is the overflow output projection of an |
| 1113 // <Operation>WithOverflow node. | 1114 // <Operation>WithOverflow node. |
| 1114 if (OpParameter<size_t>(value) == 1u) { | 1115 if (ProjectionIndexOf(value->op()) == 1u) { |
| 1115 // We cannot combine the <Operation>WithOverflow with this branch | 1116 // We cannot combine the <Operation>WithOverflow with this branch |
| 1116 // unless the 0th projection (the use of the actual value of the | 1117 // unless the 0th projection (the use of the actual value of the |
| 1117 // <Operation> is either NULL, which means there's no use of the | 1118 // <Operation> is either NULL, which means there's no use of the |
| 1118 // actual value, or was already defined, which means it is scheduled | 1119 // actual value, or was already defined, which means it is scheduled |
| 1119 // *AFTER* this branch). | 1120 // *AFTER* this branch). |
| 1120 Node* node = value->InputAt(0); | 1121 Node* const node = value->InputAt(0); |
| 1121 Node* result = node->FindProjection(0); | 1122 Node* const result = NodeProperties::FindProjection(node, 0); |
| 1122 if (result == NULL || IsDefined(result)) { | 1123 if (result == NULL || IsDefined(result)) { |
| 1123 switch (node->opcode()) { | 1124 switch (node->opcode()) { |
| 1124 case IrOpcode::kInt32AddWithOverflow: | 1125 case IrOpcode::kInt32AddWithOverflow: |
| 1125 cont.OverwriteAndNegateIfEqual(kOverflow); | 1126 cont.OverwriteAndNegateIfEqual(kOverflow); |
| 1126 return VisitBinop(this, node, kX64Add32, &cont); | 1127 return VisitBinop(this, node, kX64Add32, &cont); |
| 1127 case IrOpcode::kInt32SubWithOverflow: | 1128 case IrOpcode::kInt32SubWithOverflow: |
| 1128 cont.OverwriteAndNegateIfEqual(kOverflow); | 1129 cont.OverwriteAndNegateIfEqual(kOverflow); |
| 1129 return VisitBinop(this, node, kX64Sub32, &cont); | 1130 return VisitBinop(this, node, kX64Sub32, &cont); |
| 1130 default: | 1131 default: |
| 1131 break; | 1132 break; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 break; | 1242 break; |
| 1242 } | 1243 } |
| 1243 } | 1244 } |
| 1244 return VisitCompareZero(this, value, kX64Cmp, &cont); | 1245 return VisitCompareZero(this, value, kX64Cmp, &cont); |
| 1245 } | 1246 } |
| 1246 VisitWordCompare(this, node, kX64Cmp, &cont); | 1247 VisitWordCompare(this, node, kX64Cmp, &cont); |
| 1247 } | 1248 } |
| 1248 | 1249 |
| 1249 | 1250 |
| 1250 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { | 1251 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { |
| 1251 if (Node* ovf = node->FindProjection(1)) { | 1252 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
| 1252 FlagsContinuation cont(kOverflow, ovf); | 1253 FlagsContinuation cont(kOverflow, ovf); |
| 1253 VisitBinop(this, node, kX64Add32, &cont); | 1254 VisitBinop(this, node, kX64Add32, &cont); |
| 1254 } | 1255 } |
| 1255 FlagsContinuation cont; | 1256 FlagsContinuation cont; |
| 1256 VisitBinop(this, node, kX64Add32, &cont); | 1257 VisitBinop(this, node, kX64Add32, &cont); |
| 1257 } | 1258 } |
| 1258 | 1259 |
| 1259 | 1260 |
| 1260 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { | 1261 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { |
| 1261 if (Node* ovf = node->FindProjection(1)) { | 1262 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
| 1262 FlagsContinuation cont(kOverflow, ovf); | 1263 FlagsContinuation cont(kOverflow, ovf); |
| 1263 return VisitBinop(this, node, kX64Sub32, &cont); | 1264 return VisitBinop(this, node, kX64Sub32, &cont); |
| 1264 } | 1265 } |
| 1265 FlagsContinuation cont; | 1266 FlagsContinuation cont; |
| 1266 VisitBinop(this, node, kX64Sub32, &cont); | 1267 VisitBinop(this, node, kX64Sub32, &cont); |
| 1267 } | 1268 } |
| 1268 | 1269 |
| 1269 | 1270 |
| 1270 void InstructionSelector::VisitInt64LessThan(Node* node) { | 1271 void InstructionSelector::VisitInt64LessThan(Node* node) { |
| 1271 FlagsContinuation cont(kSignedLessThan, node); | 1272 FlagsContinuation cont(kSignedLessThan, node); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 MachineOperatorBuilder::kFloat64Ceil | | 1312 MachineOperatorBuilder::kFloat64Ceil | |
| 1312 MachineOperatorBuilder::kFloat64RoundTruncate | | 1313 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1313 MachineOperatorBuilder::kWord32ShiftIsSafe; | 1314 MachineOperatorBuilder::kWord32ShiftIsSafe; |
| 1314 } | 1315 } |
| 1315 return MachineOperatorBuilder::kNoFlags; | 1316 return MachineOperatorBuilder::kNoFlags; |
| 1316 } | 1317 } |
| 1317 | 1318 |
| 1318 } // namespace compiler | 1319 } // namespace compiler |
| 1319 } // namespace internal | 1320 } // namespace internal |
| 1320 } // namespace v8 | 1321 } // namespace v8 |
| OLD | NEW |