Bug 823482 part 1 - Refactor JSOP_EXCEPTION implementation in the interpreter. r=djvj

--HG--
extra : rebase_source : ec8f44feae0e8c74245347b1763f0275867764f5
This commit is contained in:
Jan de Mooij 2012-12-26 15:57:26 +01:00
parent 40c5a12a40
commit 21795a7536
2 changed files with 22 additions and 3 deletions

View File

@ -3109,9 +3109,12 @@ END_VARLEN_CASE
}
BEGIN_CASE(JSOP_EXCEPTION)
PUSH_COPY(cx->getPendingException());
cx->clearPendingException();
CHECK_BRANCH();
{
PUSH_NULL();
MutableHandleValue res = MutableHandleValue::fromMarkedLocation(&regs.sp[-1]);
if (!GetAndClearException(cx, res))
goto error;
}
END_CASE(JSOP_EXCEPTION)
BEGIN_CASE(JSOP_FINALLY)
@ -3910,6 +3913,19 @@ js::DefFunOperation(JSContext *cx, HandleScript script, HandleObject scopeChain,
return JSObject::setProperty(cx, parent, parent, name, &rval, script->strict);
}
bool
js::GetAndClearException(JSContext *cx, MutableHandleValue res)
{
// Check the interrupt flag to allow interrupting deeply nested exception
// handling.
if (cx->runtime->interrupt && !js_HandleExecutionInterrupt(cx))
return false;
res.set(cx->getPendingException());
cx->clearPendingException();
return true;
}
template <bool strict>
bool
js::SetProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &value)

View File

@ -384,6 +384,9 @@ DeleteProperty(JSContext *ctx, HandleValue val, HandlePropertyName name, JSBool
bool
DefFunOperation(JSContext *cx, HandleScript script, HandleObject scopeChain, HandleFunction funArg);
bool
GetAndClearException(JSContext *cx, MutableHandleValue res);
} /* namespace js */
#endif /* jsinterp_h___ */