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/compiler/instruction-selector-impl.h" | 9 #include "src/compiler/instruction-selector-impl.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 case_values[index] = value; | 538 case_values[index] = value; |
539 if (min_value > value) min_value = value; | 539 if (min_value > value) min_value = value; |
540 if (max_value < value) max_value = value; | 540 if (max_value < value) max_value = value; |
541 } | 541 } |
542 DCHECK_LE(min_value, max_value); | 542 DCHECK_LE(min_value, max_value); |
543 return VisitSwitch(input, default_branch, case_branches, case_values, | 543 return VisitSwitch(input, default_branch, case_branches, case_values, |
544 case_count, min_value, max_value); | 544 case_count, min_value, max_value); |
545 } | 545 } |
546 case BasicBlock::kReturn: { | 546 case BasicBlock::kReturn: { |
547 // If the result itself is a return, return its input. | 547 // If the result itself is a return, return its input. |
548 Node* value = (input != NULL && input->opcode() == IrOpcode::kReturn) | 548 Node* value = (input != nullptr && input->opcode() == IrOpcode::kReturn) |
549 ? input->InputAt(0) | 549 ? input->InputAt(0) |
550 : input; | 550 : input; |
551 return VisitReturn(value); | 551 return VisitReturn(value); |
552 } | 552 } |
| 553 case BasicBlock::kDeoptimize: { |
| 554 // If the result itself is a return, return its input. |
| 555 Node* value = |
| 556 (input != nullptr && input->opcode() == IrOpcode::kDeoptimize) |
| 557 ? input->InputAt(0) |
| 558 : input; |
| 559 return VisitDeoptimize(value); |
| 560 } |
553 case BasicBlock::kThrow: | 561 case BasicBlock::kThrow: |
554 DCHECK_EQ(IrOpcode::kThrow, input->opcode()); | 562 DCHECK_EQ(IrOpcode::kThrow, input->opcode()); |
555 return VisitThrow(input->InputAt(0)); | 563 return VisitThrow(input->InputAt(0)); |
556 case BasicBlock::kNone: { | 564 case BasicBlock::kNone: { |
557 // TODO(titzer): exit block doesn't have control. | 565 // TODO(titzer): exit block doesn't have control. |
558 DCHECK_NULL(input); | 566 DCHECK_NULL(input); |
559 break; | 567 break; |
560 } | 568 } |
561 default: | 569 default: |
562 UNREACHABLE(); | 570 UNREACHABLE(); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 if (value != NULL) { | 1091 if (value != NULL) { |
1084 Emit(kArchRet, g.NoOutput(), | 1092 Emit(kArchRet, g.NoOutput(), |
1085 g.UseLocation(value, linkage()->GetReturnLocation(), | 1093 g.UseLocation(value, linkage()->GetReturnLocation(), |
1086 linkage()->GetReturnType())); | 1094 linkage()->GetReturnType())); |
1087 } else { | 1095 } else { |
1088 Emit(kArchRet, g.NoOutput()); | 1096 Emit(kArchRet, g.NoOutput()); |
1089 } | 1097 } |
1090 } | 1098 } |
1091 | 1099 |
1092 | 1100 |
| 1101 void InstructionSelector::VisitDeoptimize(Node* value) { |
| 1102 DCHECK(FLAG_turbo_deoptimization); |
| 1103 |
| 1104 OperandGenerator g(this); |
| 1105 |
| 1106 FrameStateDescriptor* desc = GetFrameStateDescriptor(value); |
| 1107 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id. |
| 1108 |
| 1109 InstructionOperandVector args(instruction_zone()); |
| 1110 args.reserve(arg_count); |
| 1111 |
| 1112 InstructionSequence::StateId state_id = |
| 1113 sequence()->AddFrameStateDescriptor(desc); |
| 1114 args.push_back(g.TempImmediate(state_id.ToInt())); |
| 1115 |
| 1116 AddFrameStateInputs(value, &args, desc); |
| 1117 |
| 1118 DCHECK_EQ(args.size(), arg_count); |
| 1119 |
| 1120 Emit(kArchDeoptimize, 0, nullptr, arg_count, &args.front(), 0, nullptr); |
| 1121 } |
| 1122 |
| 1123 |
1093 void InstructionSelector::VisitThrow(Node* value) { | 1124 void InstructionSelector::VisitThrow(Node* value) { |
1094 OperandGenerator g(this); | 1125 OperandGenerator g(this); |
1095 Emit(kArchNop, g.NoOutput()); // TODO(titzer) | 1126 Emit(kArchNop, g.NoOutput()); // TODO(titzer) |
1096 } | 1127 } |
1097 | 1128 |
1098 | 1129 |
1099 void InstructionSelector::FillTypeVectorFromStateValues( | 1130 void InstructionSelector::FillTypeVectorFromStateValues( |
1100 ZoneVector<MachineType>* types, Node* state_values) { | 1131 ZoneVector<MachineType>* types, Node* state_values) { |
1101 DCHECK(state_values->opcode() == IrOpcode::kStateValues); | 1132 DCHECK(state_values->opcode() == IrOpcode::kStateValues); |
1102 int count = state_values->InputCount(); | 1133 int count = state_values->InputCount(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 MachineOperatorBuilder::Flags | 1247 MachineOperatorBuilder::Flags |
1217 InstructionSelector::SupportedMachineOperatorFlags() { | 1248 InstructionSelector::SupportedMachineOperatorFlags() { |
1218 return MachineOperatorBuilder::Flag::kNoFlags; | 1249 return MachineOperatorBuilder::Flag::kNoFlags; |
1219 } | 1250 } |
1220 | 1251 |
1221 #endif // !V8_TURBOFAN_BACKEND | 1252 #endif // !V8_TURBOFAN_BACKEND |
1222 | 1253 |
1223 } // namespace compiler | 1254 } // namespace compiler |
1224 } // namespace internal | 1255 } // namespace internal |
1225 } // namespace v8 | 1256 } // namespace v8 |
OLD | NEW |