Commit 8aa72152 authored by svenpanne's avatar svenpanne Committed by Commit bot

Simplified 'return' handling in the instruction selector.

The RawMachineAssembler now behaves like the rest of TurboFan,
removing the need for some special cases.

Review URL: https://codereview.chromium.org/1090393003

Cr-Commit-Position: refs/heads/master@{#28028}
parent fe9efc12
...@@ -558,11 +558,8 @@ void InstructionSelector::VisitControl(BasicBlock* block) { ...@@ -558,11 +558,8 @@ void InstructionSelector::VisitControl(BasicBlock* block) {
return VisitSwitch(input, sw); return VisitSwitch(input, sw);
} }
case BasicBlock::kReturn: { case BasicBlock::kReturn: {
// If the result itself is a return, return its input. DCHECK_EQ(IrOpcode::kReturn, input->opcode());
Node* value = (input != nullptr && input->opcode() == IrOpcode::kReturn) return VisitReturn(input->InputAt(0));
? input->InputAt(0)
: input;
return VisitReturn(value);
} }
case BasicBlock::kDeoptimize: { case BasicBlock::kDeoptimize: {
// If the result itself is a return, return its input. // If the result itself is a return, return its input.
...@@ -1045,14 +1042,11 @@ void InstructionSelector::VisitGoto(BasicBlock* target) { ...@@ -1045,14 +1042,11 @@ void InstructionSelector::VisitGoto(BasicBlock* target) {
void InstructionSelector::VisitReturn(Node* value) { void InstructionSelector::VisitReturn(Node* value) {
DCHECK_NOT_NULL(value);
OperandGenerator g(this); OperandGenerator g(this);
if (value != NULL) { Emit(kArchRet, g.NoOutput(),
Emit(kArchRet, g.NoOutput(), g.UseLocation(value, linkage()->GetReturnLocation(),
g.UseLocation(value, linkage()->GetReturnLocation(), linkage()->GetReturnType()));
linkage()->GetReturnType()));
} else {
Emit(kArchRet, g.NoOutput());
}
} }
......
...@@ -101,7 +101,8 @@ void RawMachineAssembler::Switch(Node* index, Label* default_label, ...@@ -101,7 +101,8 @@ void RawMachineAssembler::Switch(Node* index, Label* default_label,
void RawMachineAssembler::Return(Node* value) { void RawMachineAssembler::Return(Node* value) {
schedule()->AddReturn(CurrentBlock(), value); Node* ret = NewNode(common()->Return(), value);
schedule()->AddReturn(CurrentBlock(), ret);
current_block_ = NULL; current_block_ = NULL;
} }
...@@ -183,7 +184,9 @@ Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count, ...@@ -183,7 +184,9 @@ Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count,
Node* node = graph()->NewNode(op, input_count, inputs, incomplete); Node* node = graph()->NewNode(op, input_count, inputs, incomplete);
BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start() BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start()
: CurrentBlock(); : CurrentBlock();
schedule()->AddNode(block, node); if (op->opcode() != IrOpcode::kReturn) {
schedule()->AddNode(block, node);
}
return node; return node;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment