Index: src/compiler/mips/code-generator-mips.cc |
diff --git a/src/compiler/mips/code-generator-mips.cc b/src/compiler/mips/code-generator-mips.cc |
index 64e3664265b1f2c15758d4ad5fce206ddc8a4fce..5cb929e72ba44410d222bc1c31d21874ce73c904 100644 |
--- a/src/compiler/mips/code-generator-mips.cc |
+++ b/src/compiler/mips/code-generator-mips.cc |
@@ -513,21 +513,7 @@ void CodeGenerator::AssembleDeconstructFrame() { |
__ Pop(ra, fp); |
} |
-void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
- int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
- if (sp_slot_delta > 0) { |
- __ addiu(sp, sp, sp_slot_delta * kPointerSize); |
- } |
- frame_access_state()->SetFrameAccessToDefault(); |
-} |
- |
- |
-void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
- int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
- if (sp_slot_delta < 0) { |
- __ Subu(sp, sp, Operand(-sp_slot_delta * kPointerSize)); |
- frame_access_state()->IncreaseSPDelta(-sp_slot_delta); |
- } |
+void CodeGenerator::AssemblePrepareTailCall() { |
if (frame_access_state()->has_frame()) { |
__ lw(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); |
__ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
@@ -560,6 +546,38 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, |
__ bind(&done); |
} |
+namespace { |
+ |
+void AdjustStackPointerForTailCall(MacroAssembler* masm, |
+ FrameAccessState* state, |
+ int new_slot_above_sp, |
+ bool allow_shrinkage = true) { |
+ int current_sp_offset = state->GetSPToFPSlotCount() + |
+ StandardFrameConstants::kFixedSlotCountAboveFp; |
+ int stack_slot_delta = new_slot_above_sp - current_sp_offset; |
+ if (stack_slot_delta > 0) { |
+ masm->Subu(sp, sp, stack_slot_delta * kPointerSize); |
+ state->IncreaseSPDelta(stack_slot_delta); |
+ } else if (allow_shrinkage && stack_slot_delta < 0) { |
+ masm->Addu(sp, sp, stack_slot_delta * kPointerSize); |
+ state->IncreaseSPDelta(stack_slot_delta); |
+ } |
+} |
+ |
+} // namespace |
+ |
+void CodeGenerator::AssembleTailCallBeforeGap(Instruction* instr, |
+ int first_unused_stack_slot) { |
+ AdjustStackPointerForTailCall(masm(), frame_access_state(), |
+ first_unused_stack_slot, false); |
+} |
+ |
+void CodeGenerator::AssembleTailCallAfterGap(Instruction* instr, |
+ int first_unused_stack_slot) { |
+ AdjustStackPointerForTailCall(masm(), frame_access_state(), |
+ first_unused_stack_slot); |
+} |
+ |
// Assembles an instruction after register allocation, producing machine code. |
CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
Instruction* instr) { |
@@ -582,8 +600,6 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
} |
case kArchTailCallCodeObjectFromJSFunction: |
case kArchTailCallCodeObject: { |
- int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
- AssembleDeconstructActivationRecord(stack_param_delta); |
if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { |
AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, |
i.TempRegister(0), i.TempRegister(1), |
@@ -597,11 +613,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ Jump(at); |
} |
frame_access_state()->ClearSPDelta(); |
+ frame_access_state()->SetFrameAccessToDefault(); |
break; |
} |
case kArchTailCallAddress: { |
- int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
- AssembleDeconstructActivationRecord(stack_param_delta); |
CHECK(!instr->InputAt(0)->IsImmediate()); |
__ Jump(i.InputRegister(0)); |
frame_access_state()->ClearSPDelta(); |
@@ -620,6 +635,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ Call(at); |
RecordCallPosition(instr); |
frame_access_state()->ClearSPDelta(); |
+ frame_access_state()->SetFrameAccessToDefault(); |
break; |
} |
case kArchTailCallJSFunctionFromJSFunction: |
@@ -631,8 +647,6 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg)); |
} |
- int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
- AssembleDeconstructActivationRecord(stack_param_delta); |
if (arch_opcode == kArchTailCallJSFunctionFromJSFunction) { |
AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, |
i.TempRegister(0), i.TempRegister(1), |
@@ -641,6 +655,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ lw(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); |
__ Jump(at); |
frame_access_state()->ClearSPDelta(); |
+ frame_access_state()->SetFrameAccessToDefault(); |
break; |
} |
case kArchPrepareCallCFunction: { |
@@ -651,7 +666,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
break; |
} |
case kArchPrepareTailCall: |
- AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1)); |
+ AssemblePrepareTailCall(); |
break; |
case kArchCallCFunction: { |
int const num_parameters = MiscField::decode(instr->opcode()); |