Bug 912379 - Unwrap before translating StopIteration. r=mrbkap

The current setup means that we have different cache behavior for StopIteration
depending on whether we're wrapping StopIteration itself or a CCW to one. We
need to maintain cache invariants for optimizations now, so this is verboten.
Shuffle some code.
This commit is contained in:
Bobby Holley 2013-09-23 09:29:44 -04:00
parent 7735a60358
commit 40d7271354
2 changed files with 19 additions and 7 deletions

View File

@ -0,0 +1,12 @@
s = newGlobal();
evalcx("\
try { \
throw StopIteration;\
} catch(a) {\
x = a;\
} \
wrap(x);\
", s);
evalcx("\
n = x;\
", s);

View File

@ -285,6 +285,13 @@ JSCompartment::wrap(JSContext *cx, MutableHandleObject obj, HandleObject existin
HandleObject global = cx->global();
JS_ASSERT(global);
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj);
/* Unwrap the object, but don't unwrap outer windows. */
unsigned flags = 0;
obj.set(UncheckedUnwrap(obj, /* stopAtOuter = */ true, &flags));
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj);
@ -297,13 +304,6 @@ JSCompartment::wrap(JSContext *cx, MutableHandleObject obj, HandleObject existin
return true;
}
/* Unwrap the object, but don't unwrap outer windows. */
unsigned flags = 0;
obj.set(UncheckedUnwrap(obj, /* stopAtOuter = */ true, &flags));
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj);
/* Invoke the prewrap callback. We're a bit worried about infinite
* recursion here, so we do a check - see bug 809295. */
JS_CHECK_CHROME_RECURSION(cx, return false);