Index: src/compiler/mips64/code-generator-mips64.cc |
diff --git a/src/compiler/mips64/code-generator-mips64.cc b/src/compiler/mips64/code-generator-mips64.cc |
index 3d80c4963e48a024a6e22e96acfbd9cb9c4d5185..157e0fd48a84b382e4d3122adf3f87042a6651d5 100644 |
--- a/src/compiler/mips64/code-generator-mips64.cc |
+++ b/src/compiler/mips64/code-generator-mips64.cc |
@@ -719,7 +719,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
break; |
} |
case kArchRet: |
- AssembleReturn(); |
+ AssembleReturn(instr->InputAt(0)); |
break; |
case kArchStackPointer: |
__ mov(i.OutputRegister(), sp); |
@@ -2278,8 +2278,7 @@ void CodeGenerator::AssembleConstructFrame() { |
} |
} |
- |
-void CodeGenerator::AssembleReturn() { |
+void CodeGenerator::AssembleReturn(InstructionOperand* pop) { |
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
// Restore GP registers. |
@@ -2294,19 +2293,33 @@ void CodeGenerator::AssembleReturn() { |
__ MultiPopFPU(saves_fpu); |
} |
+ MipsOperandConverter g(this, nullptr); |
if (descriptor->IsCFunctionCall()) { |
AssembleDeconstructFrame(); |
} else if (frame_access_state()->has_frame()) { |
- // Canonicalize JSFunction return sites for now. |
- if (return_label_.is_bound()) { |
- __ Branch(&return_label_); |
- return; |
+ // Canonicalize JSFunction return sites for now unless they have an variable |
+ // number of stack slot pops. |
+ if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { |
+ if (return_label_.is_bound()) { |
+ __ Branch(&return_label_); |
+ return; |
+ } else { |
+ __ bind(&return_label_); |
+ AssembleDeconstructFrame(); |
+ } |
} else { |
- __ bind(&return_label_); |
AssembleDeconstructFrame(); |
} |
} |
int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
+ if (pop->IsImmediate()) { |
+ DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); |
+ pop_count += g.ToConstant(pop).ToInt32(); |
+ } else { |
+ Register pop_reg = g.ToRegister(pop); |
+ __ dsll(pop_reg, pop_reg, kPointerSizeLog2); |
+ __ Daddu(sp, sp, pop_reg); |
+ } |
if (pop_count != 0) { |
__ DropAndRet(pop_count); |
} else { |