| Index: src/mips/builtins-mips.cc | 
| diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc | 
| index 76d0640bc9a303003be8dd0bbd44514a35f37fec..530e8116166a17954bb5b47078a4d722036f467a 100644 | 
| --- a/src/mips/builtins-mips.cc | 
| +++ b/src/mips/builtins-mips.cc | 
| @@ -952,6 +952,22 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { | 
| } | 
| } | 
|  | 
| +static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { | 
| +  Register args_count = scratch; | 
| + | 
| +  // Get the arguments + receiver count. | 
| +  __ lw(args_count, | 
| +        MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); | 
| +  __ lw(args_count, | 
| +        FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); | 
| + | 
| +  // Leave the frame (also dropping the register file). | 
| +  __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 
| + | 
| +  // Drop receiver + arguments. | 
| +  __ Addu(sp, sp, args_count); | 
| +} | 
| + | 
| // Generate code for entering a JS function with the interpreter. | 
| // On entry to the function the receiver and arguments have been pushed on the | 
| // stack left to right.  The actual argument count matches the formal parameter | 
| @@ -1054,16 +1070,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { | 
| masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); | 
|  | 
| // The return value is in v0. | 
| - | 
| -  // Get the arguments + reciever count. | 
| -  __ lw(t0, MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); | 
| -  __ lw(t0, FieldMemOperand(t0, BytecodeArray::kParameterSizeOffset)); | 
| - | 
| -  // Leave the frame (also dropping the register file). | 
| -  __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 
| - | 
| -  // Drop receiver + arguments and return. | 
| -  __ Addu(sp, sp, t0); | 
| +  LeaveInterpreterFrame(masm, t0); | 
| __ Jump(ra); | 
|  | 
| // Load debug copy of the bytecode array. | 
| @@ -1085,6 +1092,31 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { | 
| __ Jump(t0); | 
| } | 
|  | 
| +void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { | 
| +  // Save the function and context for call to CompileBaseline. | 
| +  __ lw(a1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); | 
| +  __ lw(kContextRegister, | 
| +        MemOperand(fp, StandardFrameConstants::kContextOffset)); | 
| + | 
| +  // Leave the frame before recompiling for baseline so that we don't count as | 
| +  // an activation on the stack. | 
| +  LeaveInterpreterFrame(masm, t0); | 
| + | 
| +  { | 
| +    FrameScope frame_scope(masm, StackFrame::INTERNAL); | 
| +    // Push return value. | 
| +    __ push(v0); | 
| + | 
| +    // Push function as argument and compile for baseline. | 
| +    __ push(a1); | 
| +    __ CallRuntime(Runtime::kCompileBaseline); | 
| + | 
| +    // Restore return value. | 
| +    __ pop(v0); | 
| +  } | 
| +  __ Jump(ra); | 
| +} | 
| + | 
| // static | 
| void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 
| MacroAssembler* masm, TailCallMode tail_call_mode) { | 
|  |