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 373a1a6abce6efacd5e6a6f00d62f25a4723aa65..c1f5148e6701b3332d844eac27458cf4ee0a89e5 100644 |
--- a/src/compiler/mips64/code-generator-mips64.cc |
+++ b/src/compiler/mips64/code-generator-mips64.cc |
@@ -501,13 +501,37 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
frame_access_state()->SetFrameAccessToSP(); |
} |
+void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, |
+ Register scratch1, |
+ Register scratch2, |
+ Register scratch3) { |
+ DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); |
+ Label done; |
+ |
+ // Check if current frame is an arguments adaptor frame. |
+ __ ld(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
+ __ Branch(&done, ne, scratch3, |
+ Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
+ |
+ // Load arguments count from current arguments adaptor frame (note, it |
+ // does not include receiver). |
+ Register caller_args_count_reg = scratch1; |
+ __ ld(caller_args_count_reg, |
+ MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
+ __ SmiUntag(caller_args_count_reg); |
+ |
+ ParameterCount callee_args_count(args_reg); |
+ __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
+ scratch3); |
+ __ bind(&done); |
+} |
// Assembles an instruction after register allocation, producing machine code. |
void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
MipsOperandConverter i(this, instr); |
InstructionCode opcode = instr->opcode(); |
- |
- switch (ArchOpcodeField::decode(opcode)) { |
+ ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
+ switch (arch_opcode) { |
case kArchCallCodeObject: { |
EnsureSpaceForLazyDeopt(); |
if (instr->InputAt(0)->IsImmediate()) { |
@@ -521,9 +545,15 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
frame_access_state()->ClearSPDelta(); |
break; |
} |
+ 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), |
+ i.TempRegister(2)); |
+ } |
if (instr->InputAt(0)->IsImmediate()) { |
__ Jump(Handle<Code>::cast(i.InputHeapObject(0)), |
RelocInfo::CODE_TARGET); |
@@ -548,6 +578,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
frame_access_state()->ClearSPDelta(); |
break; |
} |
+ case kArchTailCallJSFunctionFromJSFunction: |
case kArchTailCallJSFunction: { |
Register func = i.InputRegister(0); |
if (FLAG_debug_code) { |
@@ -557,6 +588,11 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
} |
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), |
+ i.TempRegister(2)); |
+ } |
__ ld(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); |
__ Jump(at); |
frame_access_state()->ClearSPDelta(); |