diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 429285058fdd..e48958a15573 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -2376,6 +2376,7 @@ Interpret(JSContext *cx, JSStackFrame *entryFrame, uintN inlineCallCount, JSInte interpReturnOK = mjit::JaegerShotAtSafePoint(cx, ncode); \ if (inlineCallCount) \ goto jit_return; \ + regs.fp->setFinishedInInterpreter(); \ goto leave_on_safe_point; \ } \ if (status == mjit::Compile_Abort) { \ diff --git a/js/src/methodjit/InvokeHelpers.cpp b/js/src/methodjit/InvokeHelpers.cpp index 4d986261a88b..59ac8c622935 100644 --- a/js/src/methodjit/InvokeHelpers.cpp +++ b/js/src/methodjit/InvokeHelpers.cpp @@ -759,16 +759,23 @@ PartialInterpret(VMFrame &f) JS_STATIC_ASSERT(JSOP_NOP == 0); -/* Returns whether the current PC would return, popping the frame. */ -static inline JSOp +/* + * Returns whether the current PC would return, or if the frame has already + * been completed. This distinction avoids re-entering the interpreter or JIT + * to complete a JSOP_RETURN. Instead, that edge case is handled in + * HandleFinishedFrame. We could consider reducing complexity, and making this + * function return only "finishedInInterpreter", and always using the full VM + * machinery to fully finish frames. + */ +static inline bool FrameIsFinished(JSContext *cx) { JSOp op = JSOp(*cx->regs->pc); return (op == JSOP_RETURN || op == JSOP_RETRVAL || op == JSOP_STOP) - ? op - : JSOP_NOP; + ? true + : cx->fp()->finishedInInterpreter(); } @@ -818,9 +825,9 @@ HandleFinishedFrame(VMFrame &f, JSStackFrame *entryFrame) * 4. No: Somewhere in the RunTracer call tree, we removed a frame, * and we returned to a JSOP_RETURN opcode. Note carefully * that in this situation, FrameIsFinished() returns true! - * 5. Yes: The function exited in the method JIT. However, in this - * case, we'll never enter HandleFinishedFrame(): we always - * immediately pop JIT'd frames. + * 5. Yes: The function exited in the method JIT, during + * FinishExcessFrames() However, in this case, we'll never enter + * HandleFinishedFrame(): we always immediately pop JIT'd frames. * * Since the only scenario where this fixup is NOT needed is a normal exit * from the interpreter, we can cleanly check for this scenario by checking