Bug 687683: Separate ScriptDebugPrologue add ScriptDebugEpilogue from and ScriptPrologue and ScriptEpilogue. r=jorendorff

At the moment, ScriptDebugPrologue is called (conditionally) from within
ScriptPrologue. For onEnterFrame handlers to be able to return a resumption
value, we need ScriptDebugPrologue to return a JSTrapStatus value, but it
is (non-debug) ScriptPrologue's callers that would need to handle those
values.

It seems strange to have ScriptPrologue return a JSTrapStatus. So this
patch brings ScriptDebugPrologue out of ScriptPrologue (and
ScriptPrologueOrGeneratorResume), and has ScriptPrologue's callers call
ScriptDebugPrologue explicitly.

For symmetry, we do the same with ScriptEpilogue,
ScriptEpilogueOrGeneratorYield, and ScriptDebugEpilogue.

Actually adding and processing the JSTrapStatus values comes in a later
patch. This is just meant to be a behavior-preserving rearrangement.
This commit is contained in:
Jim Blandy 2011-12-06 11:40:27 -08:00
Родитель 95a44bf9bf
Коммит 6cc74f4d30
4 изменённых файлов: 27 добавлений и 12 удалений

Просмотреть файл

@ -1790,6 +1790,8 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode)
JS_ASSERT_IF(!fp->isGeneratorFrame(), regs.pc == script->code);
if (!ScriptPrologueOrGeneratorResume(cx, fp, UseNewTypeAtEntry(cx, fp)))
goto error;
if (cx->compartment->debugMode())
ScriptDebugPrologue(cx, fp);
}
/* The REJOIN mode acts like the normal mode, except the prologue is skipped. */
@ -2031,6 +2033,10 @@ BEGIN_CASE(JSOP_STOP)
inline_return:
{
JS_ASSERT(!IsActiveWithOrBlock(cx, regs.fp()->scopeChain(), 0));
if (cx->compartment->debugMode())
interpReturnOK = ScriptDebugEpilogue(cx, regs.fp(), interpReturnOK);
interpReturnOK = ScriptEpilogue(cx, regs.fp(), interpReturnOK);
/* The JIT inlines ScriptEpilogue. */
@ -3507,6 +3513,9 @@ BEGIN_CASE(JSOP_FUNAPPLY)
if (!ScriptPrologue(cx, regs.fp(), newType))
goto error;
if (cx->compartment->debugMode())
ScriptDebugPrologue(cx, regs.fp());
CHECK_INTERRUPT_HANDLER();
/* Load first op and dispatch it (safe since JSOP_STOP). */
@ -5524,6 +5533,8 @@ END_CASE(JSOP_ARRAYPUSH)
goto inline_return;
exit:
if (cx->compartment->debugMode())
interpReturnOK = ScriptDebugEpilogue(cx, regs.fp(), interpReturnOK);
interpReturnOK = ScriptEpilogueOrGeneratorYield(cx, regs.fp(), interpReturnOK);
regs.fp()->setFinishedInInterpreter();

Просмотреть файл

@ -205,8 +205,6 @@ ScriptPrologue(JSContext *cx, StackFrame *fp, bool newType)
}
Probes::enterJSFun(cx, fp->maybeFun(), fp->script());
if (cx->compartment->debugMode())
ScriptDebugPrologue(cx, fp);
return true;
}
@ -215,8 +213,6 @@ inline bool
ScriptEpilogue(JSContext *cx, StackFrame *fp, bool ok)
{
Probes::exitJSFun(cx, fp->maybeFun(), fp->script());
if (cx->compartment->debugMode())
ok = ScriptDebugEpilogue(cx, fp, ok);
/*
* If inline-constructing, replace primitive rval with the new object
@ -235,8 +231,6 @@ ScriptPrologueOrGeneratorResume(JSContext *cx, StackFrame *fp, bool newType)
{
if (!fp->isGeneratorFrame())
return ScriptPrologue(cx, fp, newType);
if (cx->compartment->debugMode())
ScriptDebugPrologue(cx, fp);
return true;
}
@ -245,8 +239,6 @@ ScriptEpilogueOrGeneratorYield(JSContext *cx, StackFrame *fp, bool ok)
{
if (!fp->isYielding())
return ScriptEpilogue(cx, fp, ok);
if (cx->compartment->debugMode())
return ScriptDebugEpilogue(cx, fp, ok);
return ok;
}

Просмотреть файл

@ -576,6 +576,10 @@ js_InternalThrow(VMFrame &f)
// rely on this property.
JS_ASSERT(!f.fp()->finishedInInterpreter());
UnwindScope(cx, 0, cx->isExceptionPending());
if (cx->compartment->debugMode())
js::ScriptDebugEpilogue(cx, f.fp(), false);
ScriptEpilogue(f.cx, f.fp(), false);
// Don't remove the last frame, this is the responsibility of
@ -915,6 +919,10 @@ js_InternalInterpret(void *returnData, void *returnType, void *returnReg, js::VM
/* Construct the 'this' object for the frame if necessary. */
if (!ScriptPrologueOrGeneratorResume(cx, fp, types::UseNewTypeAtEntry(cx, fp)))
return js_InternalThrow(f);
if (cx->compartment->debugMode())
js::ScriptDebugPrologue(cx, fp);
break;
case REJOIN_CALL_PROLOGUE:

Просмотреть файл

@ -2352,11 +2352,15 @@ void JS_FASTCALL
stubs::AnyFrameEpilogue(VMFrame &f)
{
/*
* On the normal execution path, emitReturn inlines ScriptEpilogue.
* This function implements forced early returns, so it must have the
* same effect.
* On the normal execution path, emitReturn calls ScriptDebugEpilogue
* and inlines ScriptEpilogue. This function implements forced early
* returns, so it must have the same effect.
*/
if (!ScriptEpilogue(f.cx, f.fp(), true))
bool ok = true;
if (f.cx->compartment->debugMode())
ok = js::ScriptDebugEpilogue(f.cx, f.fp(), ok);
ok = ScriptEpilogue(f.cx, f.fp(), ok);
if (!ok)
THROW();
if (f.fp()->isNonEvalFunctionFrame())
f.fp()->functionEpilogue();