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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 DCHECK_LE(sw.min_value, sw.max_value); | 497 DCHECK_LE(sw.min_value, sw.max_value); |
498 // Note that {value_range} can be 0 if {min_value} is -2^31 and | 498 // Note that {value_range} can be 0 if {min_value} is -2^31 and |
499 // {max_value} | 499 // {max_value} |
500 // is 2^31-1, so don't assume that it's non-zero below. | 500 // is 2^31-1, so don't assume that it's non-zero below. |
501 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) - | 501 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) - |
502 bit_cast<uint32_t>(sw.min_value); | 502 bit_cast<uint32_t>(sw.min_value); |
503 return VisitSwitch(input, sw); | 503 return VisitSwitch(input, sw); |
504 } | 504 } |
505 case BasicBlock::kReturn: { | 505 case BasicBlock::kReturn: { |
506 DCHECK_EQ(IrOpcode::kReturn, input->opcode()); | 506 DCHECK_EQ(IrOpcode::kReturn, input->opcode()); |
507 return VisitReturn(input->InputAt(0)); | 507 return VisitReturn(input); |
508 } | 508 } |
509 case BasicBlock::kDeoptimize: { | 509 case BasicBlock::kDeoptimize: { |
510 // If the result itself is a return, return its input. | 510 // If the result itself is a return, return its input. |
511 Node* value = | 511 Node* value = |
512 (input != nullptr && input->opcode() == IrOpcode::kDeoptimize) | 512 (input != nullptr && input->opcode() == IrOpcode::kDeoptimize) |
513 ? input->InputAt(0) | 513 ? input->InputAt(0) |
514 : input; | 514 : input; |
515 return VisitDeoptimize(value); | 515 return VisitDeoptimize(value); |
516 } | 516 } |
517 case BasicBlock::kThrow: | 517 case BasicBlock::kThrow: |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 } | 1002 } |
1003 | 1003 |
1004 | 1004 |
1005 void InstructionSelector::VisitGoto(BasicBlock* target) { | 1005 void InstructionSelector::VisitGoto(BasicBlock* target) { |
1006 // jump to the next block. | 1006 // jump to the next block. |
1007 OperandGenerator g(this); | 1007 OperandGenerator g(this); |
1008 Emit(kArchJmp, g.NoOutput(), g.Label(target)); | 1008 Emit(kArchJmp, g.NoOutput(), g.Label(target)); |
1009 } | 1009 } |
1010 | 1010 |
1011 | 1011 |
1012 void InstructionSelector::VisitReturn(Node* value) { | 1012 void InstructionSelector::VisitReturn(Node* input) { |
1013 DCHECK_NOT_NULL(value); | |
1014 OperandGenerator g(this); | 1013 OperandGenerator g(this); |
1015 if (linkage()->GetIncomingDescriptor()->ReturnCount() == 0) { | 1014 if (linkage()->GetIncomingDescriptor()->ReturnCount() == 0) { |
1016 Emit(kArchRet, g.NoOutput()); | 1015 Emit(kArchRet, g.NoOutput()); |
1017 } else { | 1016 } else { |
1018 Emit(kArchRet, g.NoOutput(), | 1017 const int input_count = input->op()->ValueInputCount(); |
1019 g.UseLocation(value, linkage()->GetReturnLocation(), | 1018 auto value_locations = zone()->NewArray<InstructionOperand>(input_count); |
1020 linkage()->GetReturnType())); | 1019 for (int i = 0; i < input_count; ++i) { |
1020 DCHECK_NOT_NULL(input->InputAt(i)); | |
1021 value_locations[i] = | |
1022 g.UseLocation(input->InputAt(i), linkage()->GetReturnLocation(i), | |
1023 linkage()->GetReturnType()); | |
titzer
2015/10/07 23:57:05
GetReturnType(i) ?
bradn
2015/10/08 17:13:37
Done.
| |
1024 } | |
1025 Emit(kArchRet, 0, nullptr, input_count, value_locations); | |
1021 } | 1026 } |
1022 } | 1027 } |
1023 | 1028 |
1024 | 1029 |
1025 void InstructionSelector::VisitDeoptimize(Node* value) { | 1030 void InstructionSelector::VisitDeoptimize(Node* value) { |
1026 OperandGenerator g(this); | 1031 OperandGenerator g(this); |
1027 | 1032 |
1028 FrameStateDescriptor* desc = GetFrameStateDescriptor(value); | 1033 FrameStateDescriptor* desc = GetFrameStateDescriptor(value); |
1029 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id. | 1034 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id. |
1030 | 1035 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1144 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { | 1149 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { |
1145 inputs->push_back(OperandForDeopt(&g, input_node.node, kind)); | 1150 inputs->push_back(OperandForDeopt(&g, input_node.node, kind)); |
1146 descriptor->SetType(value_index++, input_node.type); | 1151 descriptor->SetType(value_index++, input_node.type); |
1147 } | 1152 } |
1148 DCHECK(value_index == descriptor->GetSize()); | 1153 DCHECK(value_index == descriptor->GetSize()); |
1149 } | 1154 } |
1150 | 1155 |
1151 } // namespace compiler | 1156 } // namespace compiler |
1152 } // namespace internal | 1157 } // namespace internal |
1153 } // namespace v8 | 1158 } // namespace v8 |
OLD | NEW |