| 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.h" | 5 #include "src/compiler/instruction-selector.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
| 10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 | 344 |
| 345 | 345 |
| 346 namespace { | 346 namespace { |
| 347 | 347 |
| 348 enum class FrameStateInputKind { kAny, kStackSlot }; | 348 enum class FrameStateInputKind { kAny, kStackSlot }; |
| 349 | 349 |
| 350 InstructionOperand OperandForDeopt(OperandGenerator* g, Node* input, | 350 InstructionOperand OperandForDeopt(OperandGenerator* g, Node* input, |
| 351 FrameStateInputKind kind, | 351 FrameStateInputKind kind, |
| 352 MachineRepresentation rep) { | 352 MachineRepresentation rep) { |
| 353 if (rep == MachineRepresentation::kNone) { | |
| 354 return g->TempImmediate(FrameStateDescriptor::kImpossibleValue); | |
| 355 } | |
| 356 | |
| 357 switch (input->opcode()) { | 353 switch (input->opcode()) { |
| 358 case IrOpcode::kInt32Constant: | 354 case IrOpcode::kInt32Constant: |
| 359 case IrOpcode::kInt64Constant: | 355 case IrOpcode::kInt64Constant: |
| 360 case IrOpcode::kNumberConstant: | 356 case IrOpcode::kNumberConstant: |
| 361 case IrOpcode::kFloat32Constant: | 357 case IrOpcode::kFloat32Constant: |
| 362 case IrOpcode::kFloat64Constant: | 358 case IrOpcode::kFloat64Constant: |
| 363 case IrOpcode::kHeapConstant: | 359 case IrOpcode::kHeapConstant: |
| 364 return g->UseImmediate(input); | 360 return g->UseImmediate(input); |
| 365 case IrOpcode::kObjectState: | 361 case IrOpcode::kObjectState: |
| 366 UNREACHABLE(); | 362 UNREACHABLE(); |
| 367 break; | 363 break; |
| 368 default: | 364 default: |
| 369 switch (kind) { | 365 if (rep == MachineRepresentation::kNone) { |
| 370 case FrameStateInputKind::kStackSlot: | 366 return g->TempImmediate(FrameStateDescriptor::kImpossibleValue); |
| 371 return g->UseUniqueSlot(input); | 367 } else { |
| 372 case FrameStateInputKind::kAny: | 368 switch (kind) { |
| 373 // Currently deopts "wrap" other operations, so the deopt's inputs | 369 case FrameStateInputKind::kStackSlot: |
| 374 // are potentially needed untill the end of the deoptimising code. | 370 return g->UseUniqueSlot(input); |
| 375 return g->UseAnyAtEnd(input); | 371 case FrameStateInputKind::kAny: |
| 372 // Currently deopts "wrap" other operations, so the deopt's inputs |
| 373 // are potentially needed untill the end of the deoptimising code. |
| 374 return g->UseAnyAtEnd(input); |
| 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 UNREACHABLE(); | 378 UNREACHABLE(); |
| 379 return InstructionOperand(); | 379 return InstructionOperand(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 | 382 |
| 383 class StateObjectDeduplicator { | 383 class StateObjectDeduplicator { |
| 384 public: | 384 public: |
| 385 explicit StateObjectDeduplicator(Zone* zone) : objects_(zone) {} | 385 explicit StateObjectDeduplicator(Zone* zone) : objects_(zone) {} |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 case IrOpcode::kChangeFloat32ToFloat64: | 1060 case IrOpcode::kChangeFloat32ToFloat64: |
| 1061 return MarkAsFloat64(node), VisitChangeFloat32ToFloat64(node); | 1061 return MarkAsFloat64(node), VisitChangeFloat32ToFloat64(node); |
| 1062 case IrOpcode::kChangeInt32ToFloat64: | 1062 case IrOpcode::kChangeInt32ToFloat64: |
| 1063 return MarkAsFloat64(node), VisitChangeInt32ToFloat64(node); | 1063 return MarkAsFloat64(node), VisitChangeInt32ToFloat64(node); |
| 1064 case IrOpcode::kChangeUint32ToFloat64: | 1064 case IrOpcode::kChangeUint32ToFloat64: |
| 1065 return MarkAsFloat64(node), VisitChangeUint32ToFloat64(node); | 1065 return MarkAsFloat64(node), VisitChangeUint32ToFloat64(node); |
| 1066 case IrOpcode::kChangeFloat64ToInt32: | 1066 case IrOpcode::kChangeFloat64ToInt32: |
| 1067 return MarkAsWord32(node), VisitChangeFloat64ToInt32(node); | 1067 return MarkAsWord32(node), VisitChangeFloat64ToInt32(node); |
| 1068 case IrOpcode::kChangeFloat64ToUint32: | 1068 case IrOpcode::kChangeFloat64ToUint32: |
| 1069 return MarkAsWord32(node), VisitChangeFloat64ToUint32(node); | 1069 return MarkAsWord32(node), VisitChangeFloat64ToUint32(node); |
| 1070 case IrOpcode::kImpossibleToWord32: |
| 1071 return MarkAsWord32(node), VisitImpossibleToWord32(node); |
| 1072 case IrOpcode::kImpossibleToWord64: |
| 1073 return MarkAsWord64(node), VisitImpossibleToWord64(node); |
| 1074 case IrOpcode::kImpossibleToFloat32: |
| 1075 return MarkAsFloat32(node), VisitImpossibleToFloat32(node); |
| 1076 case IrOpcode::kImpossibleToFloat64: |
| 1077 return MarkAsFloat64(node), VisitImpossibleToFloat64(node); |
| 1078 case IrOpcode::kImpossibleToTagged: |
| 1079 MarkAsRepresentation(MachineType::PointerRepresentation(), node); |
| 1080 return VisitImpossibleToTagged(node); |
| 1081 case IrOpcode::kImpossibleToBit: |
| 1082 return MarkAsWord32(node), VisitImpossibleToBit(node); |
| 1070 case IrOpcode::kFloat64SilenceNaN: | 1083 case IrOpcode::kFloat64SilenceNaN: |
| 1071 MarkAsFloat64(node); | 1084 MarkAsFloat64(node); |
| 1072 if (CanProduceSignalingNaN(node->InputAt(0))) { | 1085 if (CanProduceSignalingNaN(node->InputAt(0))) { |
| 1073 return VisitFloat64SilenceNaN(node); | 1086 return VisitFloat64SilenceNaN(node); |
| 1074 } else { | 1087 } else { |
| 1075 return EmitIdentity(node); | 1088 return EmitIdentity(node); |
| 1076 } | 1089 } |
| 1077 case IrOpcode::kTruncateFloat64ToUint32: | 1090 case IrOpcode::kTruncateFloat64ToUint32: |
| 1078 return MarkAsWord32(node), VisitTruncateFloat64ToUint32(node); | 1091 return MarkAsWord32(node), VisitTruncateFloat64ToUint32(node); |
| 1079 case IrOpcode::kTruncateFloat32ToInt32: | 1092 case IrOpcode::kTruncateFloat32ToInt32: |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 return MarkAsSimd128(node), VisitCreateInt32x4(node); | 1313 return MarkAsSimd128(node), VisitCreateInt32x4(node); |
| 1301 case IrOpcode::kInt32x4ExtractLane: | 1314 case IrOpcode::kInt32x4ExtractLane: |
| 1302 return MarkAsWord32(node), VisitInt32x4ExtractLane(node); | 1315 return MarkAsWord32(node), VisitInt32x4ExtractLane(node); |
| 1303 default: | 1316 default: |
| 1304 V8_Fatal(__FILE__, __LINE__, "Unexpected operator #%d:%s @ node #%d", | 1317 V8_Fatal(__FILE__, __LINE__, "Unexpected operator #%d:%s @ node #%d", |
| 1305 node->opcode(), node->op()->mnemonic(), node->id()); | 1318 node->opcode(), node->op()->mnemonic(), node->id()); |
| 1306 break; | 1319 break; |
| 1307 } | 1320 } |
| 1308 } | 1321 } |
| 1309 | 1322 |
| 1323 void InstructionSelector::VisitImpossibleToWord32(Node* node) { |
| 1324 OperandGenerator g(this); |
| 1325 Emit(kArchImpossible, g.DefineAsConstant(node, Constant(0))); |
| 1326 } |
| 1327 |
| 1328 void InstructionSelector::VisitImpossibleToWord64(Node* node) { |
| 1329 OperandGenerator g(this); |
| 1330 Emit(kArchImpossible, |
| 1331 g.DefineAsConstant(node, Constant(static_cast<int64_t>(0)))); |
| 1332 } |
| 1333 |
| 1334 void InstructionSelector::VisitImpossibleToFloat32(Node* node) { |
| 1335 OperandGenerator g(this); |
| 1336 Emit(kArchImpossible, g.DefineAsConstant(node, Constant(0.0f))); |
| 1337 } |
| 1338 |
| 1339 void InstructionSelector::VisitImpossibleToFloat64(Node* node) { |
| 1340 OperandGenerator g(this); |
| 1341 Emit(kArchImpossible, g.DefineAsConstant(node, Constant(0.0))); |
| 1342 } |
| 1343 |
| 1344 void InstructionSelector::VisitImpossibleToBit(Node* node) { |
| 1345 OperandGenerator g(this); |
| 1346 Emit(kArchImpossible, g.DefineAsConstant(node, Constant(0))); |
| 1347 } |
| 1348 |
| 1349 void InstructionSelector::VisitImpossibleToTagged(Node* node) { |
| 1350 OperandGenerator g(this); |
| 1351 #if V8_TARGET_ARCH_64_BIT |
| 1352 Emit(kArchImpossible, |
| 1353 g.DefineAsConstant(node, Constant(static_cast<int64_t>(0)))); |
| 1354 #else // V8_TARGET_ARCH_64_BIT |
| 1355 Emit(kArchImpossible, g.DefineAsConstant(node, Constant(0))); |
| 1356 #endif // V8_TARGET_ARCH_64_BIT |
| 1357 } |
| 1358 |
| 1310 void InstructionSelector::VisitLoadStackPointer(Node* node) { | 1359 void InstructionSelector::VisitLoadStackPointer(Node* node) { |
| 1311 OperandGenerator g(this); | 1360 OperandGenerator g(this); |
| 1312 Emit(kArchStackPointer, g.DefineAsRegister(node)); | 1361 Emit(kArchStackPointer, g.DefineAsRegister(node)); |
| 1313 } | 1362 } |
| 1314 | 1363 |
| 1315 void InstructionSelector::VisitLoadFramePointer(Node* node) { | 1364 void InstructionSelector::VisitLoadFramePointer(Node* node) { |
| 1316 OperandGenerator g(this); | 1365 OperandGenerator g(this); |
| 1317 Emit(kArchFramePointer, g.DefineAsRegister(node)); | 1366 Emit(kArchFramePointer, g.DefineAsRegister(node)); |
| 1318 } | 1367 } |
| 1319 | 1368 |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 return new (instruction_zone()) FrameStateDescriptor( | 2081 return new (instruction_zone()) FrameStateDescriptor( |
| 2033 instruction_zone(), state_info.type(), state_info.bailout_id(), | 2082 instruction_zone(), state_info.type(), state_info.bailout_id(), |
| 2034 state_info.state_combine(), parameters, locals, stack, | 2083 state_info.state_combine(), parameters, locals, stack, |
| 2035 state_info.shared_info(), outer_state); | 2084 state_info.shared_info(), outer_state); |
| 2036 } | 2085 } |
| 2037 | 2086 |
| 2038 | 2087 |
| 2039 } // namespace compiler | 2088 } // namespace compiler |
| 2040 } // namespace internal | 2089 } // namespace internal |
| 2041 } // namespace v8 | 2090 } // namespace v8 |
| OLD | NEW |