Simplified 'return' handling in the instruction selector.
authorsvenpanne <svenpanne@chromium.org>
Thu, 23 Apr 2015 12:39:34 +0000 (05:39 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 23 Apr 2015 12:39:18 +0000 (12:39 +0000)
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}

src/compiler/instruction-selector.cc
src/compiler/raw-machine-assembler.cc

index 169c6ae..1e2ab97 100644 (file)
@@ -558,11 +558,8 @@ void InstructionSelector::VisitControl(BasicBlock* block) {
       return VisitSwitch(input, sw);
     }
     case BasicBlock::kReturn: {
-      // If the result itself is a return, return its input.
-      Node* value = (input != nullptr && input->opcode() == IrOpcode::kReturn)
-                        ? input->InputAt(0)
-                        : input;
-      return VisitReturn(value);
+      DCHECK_EQ(IrOpcode::kReturn, input->opcode());
+      return VisitReturn(input->InputAt(0));
     }
     case BasicBlock::kDeoptimize: {
       // If the result itself is a return, return its input.
@@ -1045,14 +1042,11 @@ void InstructionSelector::VisitGoto(BasicBlock* target) {
 
 
 void InstructionSelector::VisitReturn(Node* value) {
+  DCHECK_NOT_NULL(value);
   OperandGenerator g(this);
-  if (value != NULL) {
-    Emit(kArchRet, g.NoOutput(),
-         g.UseLocation(value, linkage()->GetReturnLocation(),
-                       linkage()->GetReturnType()));
-  } else {
-    Emit(kArchRet, g.NoOutput());
-  }
+  Emit(kArchRet, g.NoOutput(),
+       g.UseLocation(value, linkage()->GetReturnLocation(),
+                     linkage()->GetReturnType()));
 }
 
 
index 489c2ca..6a339e7 100644 (file)
@@ -101,7 +101,8 @@ void RawMachineAssembler::Switch(Node* index, Label* default_label,
 
 
 void RawMachineAssembler::Return(Node* value) {
-  schedule()->AddReturn(CurrentBlock(), value);
+  Node* ret = NewNode(common()->Return(), value);
+  schedule()->AddReturn(CurrentBlock(), ret);
   current_block_ = NULL;
 }
 
@@ -183,7 +184,9 @@ Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count,
   Node* node = graph()->NewNode(op, input_count, inputs, incomplete);
   BasicBlock* block = op->opcode() == IrOpcode::kParameter ? schedule()->start()
                                                            : CurrentBlock();
-  schedule()->AddNode(block, node);
+  if (op->opcode() != IrOpcode::kReturn) {
+    schedule()->AddNode(block, node);
+  }
   return node;
 }