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

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

Issue 1090393003: Simplified 'return' handling in the instruction selector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | src/compiler/raw-machine-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 551 }
552 DCHECK_LE(sw.min_value, sw.max_value); 552 DCHECK_LE(sw.min_value, sw.max_value);
553 // Note that {value_range} can be 0 if {min_value} is -2^31 and 553 // Note that {value_range} can be 0 if {min_value} is -2^31 and
554 // {max_value} 554 // {max_value}
555 // is 2^31-1, so don't assume that it's non-zero below. 555 // is 2^31-1, so don't assume that it's non-zero below.
556 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) - 556 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) -
557 bit_cast<uint32_t>(sw.min_value); 557 bit_cast<uint32_t>(sw.min_value);
558 return VisitSwitch(input, sw); 558 return VisitSwitch(input, sw);
559 } 559 }
560 case BasicBlock::kReturn: { 560 case BasicBlock::kReturn: {
561 // If the result itself is a return, return its input. 561 DCHECK_EQ(IrOpcode::kReturn, input->opcode());
562 Node* value = (input != nullptr && input->opcode() == IrOpcode::kReturn) 562 return VisitReturn(input->InputAt(0));
563 ? input->InputAt(0)
564 : input;
565 return VisitReturn(value);
566 } 563 }
567 case BasicBlock::kDeoptimize: { 564 case BasicBlock::kDeoptimize: {
568 // If the result itself is a return, return its input. 565 // If the result itself is a return, return its input.
569 Node* value = 566 Node* value =
570 (input != nullptr && input->opcode() == IrOpcode::kDeoptimize) 567 (input != nullptr && input->opcode() == IrOpcode::kDeoptimize)
571 ? input->InputAt(0) 568 ? input->InputAt(0)
572 : input; 569 : input;
573 return VisitDeoptimize(value); 570 return VisitDeoptimize(value);
574 } 571 }
575 case BasicBlock::kThrow: 572 case BasicBlock::kThrow:
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1035
1039 1036
1040 void InstructionSelector::VisitGoto(BasicBlock* target) { 1037 void InstructionSelector::VisitGoto(BasicBlock* target) {
1041 // jump to the next block. 1038 // jump to the next block.
1042 OperandGenerator g(this); 1039 OperandGenerator g(this);
1043 Emit(kArchJmp, g.NoOutput(), g.Label(target)); 1040 Emit(kArchJmp, g.NoOutput(), g.Label(target));
1044 } 1041 }
1045 1042
1046 1043
1047 void InstructionSelector::VisitReturn(Node* value) { 1044 void InstructionSelector::VisitReturn(Node* value) {
1045 DCHECK_NOT_NULL(value);
1048 OperandGenerator g(this); 1046 OperandGenerator g(this);
1049 if (value != NULL) { 1047 Emit(kArchRet, g.NoOutput(),
1050 Emit(kArchRet, g.NoOutput(), 1048 g.UseLocation(value, linkage()->GetReturnLocation(),
1051 g.UseLocation(value, linkage()->GetReturnLocation(), 1049 linkage()->GetReturnType()));
1052 linkage()->GetReturnType()));
1053 } else {
1054 Emit(kArchRet, g.NoOutput());
1055 }
1056 } 1050 }
1057 1051
1058 1052
1059 void InstructionSelector::VisitDeoptimize(Node* value) { 1053 void InstructionSelector::VisitDeoptimize(Node* value) {
1060 DCHECK(FLAG_turbo_deoptimization); 1054 DCHECK(FLAG_turbo_deoptimization);
1061 1055
1062 OperandGenerator g(this); 1056 OperandGenerator g(this);
1063 1057
1064 FrameStateDescriptor* desc = GetFrameStateDescriptor(value); 1058 FrameStateDescriptor* desc = GetFrameStateDescriptor(value);
1065 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id. 1059 size_t arg_count = desc->GetTotalSize() + 1; // Include deopt id.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 MachineOperatorBuilder::Flags 1194 MachineOperatorBuilder::Flags
1201 InstructionSelector::SupportedMachineOperatorFlags() { 1195 InstructionSelector::SupportedMachineOperatorFlags() {
1202 return MachineOperatorBuilder::Flag::kNoFlags; 1196 return MachineOperatorBuilder::Flag::kNoFlags;
1203 } 1197 }
1204 1198
1205 #endif // !V8_TURBOFAN_BACKEND 1199 #endif // !V8_TURBOFAN_BACKEND
1206 1200
1207 } // namespace compiler 1201 } // namespace compiler
1208 } // namespace internal 1202 } // namespace internal
1209 } // namespace v8 1203 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/raw-machine-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698