Bug 951282 - Wrap the pending exception lazily; r=luke

This commit is contained in:
Terrence Cole
2013-12-17 13:01:05 -08:00
parent 1155fe7c0e
commit 9230cdbfd1
11 changed files with 79 additions and 71 deletions

View File

@@ -978,7 +978,8 @@ js::CloseIterator(JSContext *cx, HandleObject obj)
bool
js::UnwindIteratorForException(JSContext *cx, HandleObject obj)
{
RootedValue v(cx, cx->getPendingException());
RootedValue v(cx);
cx->getPendingException(&v);
cx->clearPendingException();
if (!CloseIterator(cx, obj))
return false;
@@ -1195,7 +1196,12 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, MutableHandleValue rval)
return false;
if (!Invoke(cx, ObjectValue(*iterobj), rval, 0, nullptr, rval)) {
/* Check for StopIteration. */
if (!cx->isExceptionPending() || !JS_IsStopIteration(cx->getPendingException()))
if (!cx->isExceptionPending())
return false;
RootedValue exception(cx);
if (!cx->getPendingException(&exception))
return false;
if (!JS_IsStopIteration(exception))
return false;
cx->clearPendingException();