Bug 800862 - Unwind bailouts exception with the interpreter. r=dvander

This commit is contained in:
Nicolas B. Pierron 2012-12-11 20:34:15 -08:00
parent da0dd35279
commit d8fe3007ea
3 changed files with 18 additions and 6 deletions

View File

@ -596,9 +596,10 @@ ion::ThunkToInterpreter(Value *vp)
JSContext *cx = GetIonContext()->cx;
IonActivation *activation = cx->runtime->ionActivation;
BailoutClosure *br = activation->takeBailout();
InterpMode resumeMode = JSINTERP_BAILOUT;
if (!EnsureHasScopeObjects(cx, cx->fp()))
return Interpret_Error;
resumeMode = JSINTERP_RETHROW;
// By default we set the forbidOsr flag on the ion script, but if a GC
// happens just after we re-enter the interpreter, the ion script get
@ -631,8 +632,10 @@ ion::ThunkToInterpreter(Value *vp)
// object yet.
JS_ASSERT(!fp->hasArgsObj());
ArgumentsObject *argsobj = ArgumentsObject::createExpected(cx, fp);
if (!argsobj)
return Interpret_Error;
if (!argsobj) {
resumeMode = JSINTERP_RETHROW;
break;
}
InternalBindingsHandle bindings(script, &script->bindings);
const unsigned var = Bindings::argumentsVarIndex(cx, bindings);
// The arguments is a local binding and needsArgsObj does not
@ -653,10 +656,11 @@ ion::ThunkToInterpreter(Value *vp)
// original Interpret activation.
vp->setMagic(JS_ION_BAILOUT);
js_delete(br);
return Interpret_Ok;
return resumeMode == JSINTERP_RETHROW ? Interpret_Error : Interpret_Ok;
}
InterpretStatus status = Interpret(cx, br->entryfp(), JSINTERP_BAILOUT);
InterpretStatus status = Interpret(cx, br->entryfp(), resumeMode);
JS_ASSERT_IF(resumeMode == JSINTERP_RETHROW, status == Interpret_Error);
if (status == Interpret_OSR) {
// The interpreter currently does not ask to perform inline OSR, so

View File

@ -1228,6 +1228,13 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode)
if (interpMode == JSINTERP_REJOIN)
interpMode = JSINTERP_NORMAL;
/*
* The RETHROW mode acts like a bailout mode, except that it resume an
* exception instead of resuming the script.
*/
if (interpMode == JSINTERP_RETHROW)
goto error;
/*
* It is important that "op" be initialized before calling DO_OP because
* it is possible for "op" to be specially assigned during the normal

View File

@ -172,7 +172,8 @@ enum InterpMode
JSINTERP_NORMAL = 0, /* interpreter is running normally */
JSINTERP_REJOIN = 1, /* as normal, but the frame has already started */
JSINTERP_SKIP_TRAP = 2, /* as REJOIN, but skip trap at first opcode */
JSINTERP_BAILOUT = 3 /* interpreter is running from an Ion bailout */
JSINTERP_BAILOUT = 3, /* interpreter is running from an Ion bailout */
JSINTERP_RETHROW = 4 /* as BAILOUT, but unwind all frames */
};
enum InterpretStatus