From f1fbba550a19cb68cccd069df4b1739ba1f9a75b Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Mon, 2 Apr 2012 08:57:27 -0700 Subject: [PATCH] Bug 740654 - Hoist recursion checks out of Interpret into callers so that Interpret does not throw when trying to rejoin from mjit (r=bhackett) --HG-- extra : rebase_source : f85c12860d9172e5167e5952352b02d367e53057 --- js/src/jsinterp.cpp | 9 ++++++--- js/src/methodjit/InvokeHelpers.cpp | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 4aeb2ac550b..34e8b22aabf 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -428,10 +428,13 @@ js::RunScript(JSContext *cx, JSScript *script, StackFrame *fp) JS_ASSERT(script); JS_ASSERT(fp == cx->fp()); JS_ASSERT(fp->script() == script); + JS_ASSERT_IF(!fp->isGeneratorFrame(), cx->regs().pc == script->code); #ifdef JS_METHODJIT_SPEW JMCheckLogging(); #endif + JS_CHECK_RECURSION(cx, return false); + /* FIXME: Once bug 470510 is fixed, make this an assert. */ if (script->compileAndGo) { if (fp->scopeChain().global().isCleared()) { @@ -1567,9 +1570,6 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode) int32_t len; len = 0; - /* Check for too deep of a native thread stack. */ - JS_CHECK_RECURSION(cx, goto error); - DO_NEXT_OP(len); #if JS_THREADED_INTERP @@ -4028,6 +4028,9 @@ END_CASE(JSOP_ARRAYPUSH) JS_ASSERT(&cx->regs() == ®s); JS_ASSERT(uint32_t(regs.pc - script->code) < script->length); + /* When rejoining, we must not err before finishing Interpret's prologue. */ + JS_ASSERT(interpMode != JSINTERP_REJOIN); + if (cx->isExceptionPending()) { /* Restore atoms local in case we will resume. */ atoms = script->atoms; diff --git a/js/src/methodjit/InvokeHelpers.cpp b/js/src/methodjit/InvokeHelpers.cpp index e92929fb32e..e36d7add87b 100644 --- a/js/src/methodjit/InvokeHelpers.cpp +++ b/js/src/methodjit/InvokeHelpers.cpp @@ -367,7 +367,9 @@ UncachedInlineCall(VMFrame &f, InitialFrameFlags initial, regs.fp()->resetInlinePrev(f.fp(), f.regs.pc); } - bool ok = !!Interpret(cx, cx->fp()); + JS_CHECK_RECURSION(cx, return false); + + bool ok = Interpret(cx, cx->fp()); f.cx->stack.popInlineFrame(regs); if (ok)