Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 1391333003: Adding support for multiple returns in compiled functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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* ret) {
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 ret_count = ret->op()->ValueInputCount();
1019 g.UseLocation(value, linkage()->GetReturnLocation(), 1018 auto value_locations = zone()->NewArray<InstructionOperand>(ret_count);
1020 linkage()->GetReturnType())); 1019 for (int i = 0; i < ret_count; ++i) {
1020 value_locations[i] =
1021 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i),
1022 linkage()->GetReturnType(i));
1023 }
1024 Emit(kArchRet, 0, nullptr, ret_count, value_locations);
1021 } 1025 }
1022 } 1026 }
1023 1027
1024 1028
1025 void InstructionSelector::VisitDeoptimize(Node* value) { 1029 void InstructionSelector::VisitDeoptimize(Node* value) {
1026 OperandGenerator g(this); 1030 OperandGenerator g(this);
1027 1031
1028 FrameStateDescriptor* desc = GetFrameStateDescriptor(value); 1032 FrameStateDescriptor* desc = GetFrameStateDescriptor(value);
1029 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id. 1033 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id.
1030 1034
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { 1148 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) {
1145 inputs->push_back(OperandForDeopt(&g, input_node.node, kind)); 1149 inputs->push_back(OperandForDeopt(&g, input_node.node, kind));
1146 descriptor->SetType(value_index++, input_node.type); 1150 descriptor->SetType(value_index++, input_node.type);
1147 } 1151 }
1148 DCHECK(value_index == descriptor->GetSize()); 1152 DCHECK(value_index == descriptor->GetSize());
1149 } 1153 }
1150 1154
1151 } // namespace compiler 1155 } // namespace compiler
1152 } // namespace internal 1156 } // namespace internal
1153 } // namespace v8 1157 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698