Compartment mismatch with pending exception (bug 621845, r=lw,jorendorff).

This commit is contained in:
Andreas Gal
2011-01-06 15:15:00 -08:00
parent 251a3efbed
commit 6039557029
18 changed files with 170 additions and 156 deletions

View File

@@ -767,7 +767,7 @@ js_ThrowStopIteration(JSContext *cx)
JS_ASSERT(!JS_IsExceptionPending(cx));
if (js_FindClassObject(cx, NULL, JSProto_StopIteration, &v))
SetPendingException(cx, v);
cx->setPendingException(v);
return JS_FALSE;
}
@@ -1017,12 +1017,10 @@ js_IteratorMore(JSContext *cx, JSObject *iterobj, Value *rval)
return false;
if (!ExternalInvoke(cx, iterobj, *rval, 0, NULL, rval)) {
/* Check for StopIteration. */
if (!cx->throwing || !js_ValueIsStopIteration(cx->exception))
if (!cx->isExceptionPending() || !js_ValueIsStopIteration(cx->getPendingException()))
return false;
/* Inline JS_ClearPendingException(cx). */
cx->throwing = JS_FALSE;
cx->exception.setUndefined();
cx->clearPendingException();
cx->iterValue.setMagic(JS_NO_ITER_VALUE);
rval->setBoolean(false);
return true;
@@ -1286,13 +1284,13 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
break;
case JSGENOP_THROW:
SetPendingException(cx, arg);
cx->setPendingException(arg);
gen->state = JSGEN_RUNNING;
break;
default:
JS_ASSERT(op == JSGENOP_CLOSE);
SetPendingException(cx, MagicValue(JS_GENERATOR_CLOSING));
cx->setPendingException(MagicValue(JS_GENERATOR_CLOSING));
gen->state = JSGEN_CLOSING;
break;
}
@@ -1350,7 +1348,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
if (gen->floatingFrame()->isYielding()) {
/* Yield cannot fail, throw or be called on closing. */
JS_ASSERT(ok);
JS_ASSERT(!cx->throwing);
JS_ASSERT(!cx->isExceptionPending());
JS_ASSERT(gen->state == JSGEN_RUNNING);
JS_ASSERT(op != JSGENOP_CLOSE);
genfp->clearYielding();
@@ -1436,7 +1434,7 @@ generator_op(JSContext *cx, JSGeneratorOp op, Value *vp, uintN argc)
case JSGENOP_SEND:
return js_ThrowStopIteration(cx);
case JSGENOP_THROW:
SetPendingException(cx, argc >= 1 ? vp[2] : UndefinedValue());
cx->setPendingException(argc >= 1 ? vp[2] : UndefinedValue());
return JS_FALSE;
default:
JS_ASSERT(op == JSGENOP_CLOSE);