diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 731423e131..82924a5be4 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -2468,9 +2468,6 @@ void LCodeGen::DoReturn(LReturn* instr) { __ Pop(ra, fp); __ Addu(sp, sp, Operand(sp_delta)); } - if (info()->IsStub()) { - __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); - } __ Jump(ra); } diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index b883ad459e..3d5d663e67 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1002,7 +1002,14 @@ LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { LInstruction* LChunkBuilder::DoContext(HContext* instr) { - return instr->HasNoUses() ? NULL : DefineAsRegister(new(zone()) LContext); + // If there is a non-return use, the context must be allocated in a register. + for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { + if (!it.value()->IsReturn()) { + return DefineAsRegister(new(zone()) LContext); + } + } + + return NULL; }