| Index: src/mips/builtins-mips.cc
 | 
| diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc
 | 
| index 9b79da73fbbc772fc32666de3e94fa408ae042f0..f6010fb1281023f93390b97c1c47387e7dff20cf 100644
 | 
| --- a/src/mips/builtins-mips.cc
 | 
| +++ b/src/mips/builtins-mips.cc
 | 
| @@ -948,6 +948,58 @@ void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
 | 
|    __ Jump(ra);
 | 
|  }
 | 
|  
 | 
| +static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index,
 | 
| +                                         Register limit, Register scratch) {
 | 
| +  Label loop_header, loop_check;
 | 
| +  __ Branch(&loop_check);
 | 
| +  __ bind(&loop_header);
 | 
| +  __ lw(scratch, MemOperand(index));
 | 
| +  __ Addu(index, index, Operand(-kPointerSize));
 | 
| +  __ push(scratch);
 | 
| +  __ bind(&loop_check);
 | 
| +  __ Branch(&loop_header, gt, index, Operand(limit));
 | 
| +}
 | 
| +
 | 
| +static void Generate_InterpreterComputeLastArgumentAddress(
 | 
| +    MacroAssembler* masm, Register num_args, Register start_address,
 | 
| +    Register output_reg) {
 | 
| +  __ Addu(output_reg, num_args, Operand(1));  // Add one for receiver.
 | 
| +  __ sll(output_reg, output_reg, kPointerSizeLog2);
 | 
| +  __ Subu(output_reg, start_address, output_reg);
 | 
| +}
 | 
| +
 | 
| +// static
 | 
| +void Builtins::Generate_InterpreterPushArgsAndCallICImpl(
 | 
| +    MacroAssembler* masm, TailCallMode tail_call_mode) {
 | 
| +  // ----------- S t a t e -------------
 | 
| +  //  -- a0 : the number of arguments (not including the receiver)
 | 
| +  //  -- t0 : the address of the first argument to be pushed. Subsequent
 | 
| +  //          arguments should be consecutive above this, in the same order as
 | 
| +  //          they are to be pushed onto the stack.
 | 
| +  //  -- a1 : the target to call (can be any Object).
 | 
| +  //  -- a3 : feedback vector slot id
 | 
| +  //  -- a2 : type feedback vector
 | 
| +  // -----------------------------------
 | 
| +
 | 
| +  {
 | 
| +    FrameScope scope(masm, StackFrame::INTERNAL);
 | 
| +
 | 
| +    // Computes the address of last argument in t1.
 | 
| +    Generate_InterpreterComputeLastArgumentAddress(masm, a0, t0, t1);
 | 
| +
 | 
| +    // Push the arguments.
 | 
| +    Generate_InterpreterPushArgs(masm, t0, t1, at);
 | 
| +
 | 
| +    // Call via the CallIC stub.
 | 
| +    CallICState call_ic_state(0, ConvertReceiverMode::kAny, tail_call_mode,
 | 
| +                              true);
 | 
| +    CallICStub stub(masm->isolate(), call_ic_state);
 | 
| +    // TODO(mythria): This should be replaced by a TailCallStub, when we
 | 
| +    // update the code to find the target IC from jump instructions.
 | 
| +    __ CallStub(&stub);
 | 
| +  }
 | 
| +  __ Ret();
 | 
| +}
 | 
|  
 | 
|  // static
 | 
|  void Builtins::Generate_InterpreterPushArgsAndCallImpl(
 | 
| @@ -960,20 +1012,11 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
 | 
|    //  -- a1 : the target to call (can be any Object).
 | 
|    // -----------------------------------
 | 
|  
 | 
| -  // Find the address of the last argument.
 | 
| -  __ Addu(a3, a0, Operand(1));  // Add one for receiver.
 | 
| -  __ sll(a3, a3, kPointerSizeLog2);
 | 
| -  __ Subu(a3, a2, Operand(a3));
 | 
| +  // Computes the address of last argument in a3.
 | 
| +  Generate_InterpreterComputeLastArgumentAddress(masm, a0, a2, a3);
 | 
|  
 | 
|    // Push the arguments.
 | 
| -  Label loop_header, loop_check;
 | 
| -  __ Branch(&loop_check);
 | 
| -  __ bind(&loop_header);
 | 
| -  __ lw(t0, MemOperand(a2));
 | 
| -  __ Addu(a2, a2, Operand(-kPointerSize));
 | 
| -  __ push(t0);
 | 
| -  __ bind(&loop_check);
 | 
| -  __ Branch(&loop_header, gt, a2, Operand(a3));
 | 
| +  Generate_InterpreterPushArgs(masm, a2, a3, at);
 | 
|  
 | 
|    // Call the target.
 | 
|    __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
 | 
| @@ -981,7 +1024,6 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
 | 
|            RelocInfo::CODE_TARGET);
 | 
|  }
 | 
|  
 | 
| -
 | 
|  // static
 | 
|  void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
 | 
|    // ----------- S t a t e -------------
 | 
| @@ -1956,6 +1998,17 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
 | 
|    __ lb(scratch1, MemOperand(at));
 | 
|    __ Branch(&done, ne, scratch1, Operand(zero_reg));
 | 
|  
 | 
| +  // Drop possible internal frame pushed for calling CallICStub.
 | 
| +  // TODO(mythria): when we tail call the CallICStub, remove this.
 | 
| +  {
 | 
| +    Label no_internal_callic_frame;
 | 
| +    __ lw(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset));
 | 
| +    __ Branch(&no_internal_callic_frame, ne, scratch3,
 | 
| +              Operand(Smi::FromInt(StackFrame::INTERNAL)));
 | 
| +    __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
 | 
| +    __ bind(&no_internal_callic_frame);
 | 
| +  }
 | 
| +
 | 
|    // Drop possible interpreter handler/stub frame.
 | 
|    {
 | 
|      Label no_interpreter_frame;
 | 
| 
 |