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