Bug 577155 - fix silly error in the fatvalification of Reify

This commit is contained in:
Luke Wagner 2010-07-07 23:39:50 -07:00
parent 94d4737738
commit 9fbd3ed3ef
6 changed files with 29 additions and 28 deletions

View File

@ -2905,7 +2905,7 @@ END_CASE(JSOP_MOREITER)
BEGIN_CASE(JSOP_ENDITER)
{
JS_ASSERT(regs.sp - 1 >= fp->base());
bool ok = !!js_CloseIterator(cx, regs.sp[-1]);
bool ok = !!js_CloseIterator(cx, &regs.sp[-1].toObject());
regs.sp--;
if (!ok)
goto error;
@ -6955,7 +6955,7 @@ END_CASE(JSOP_ARRAYPUSH)
JS_ASSERT(js_GetOpcode(cx, fp->script, regs.pc) == JSOP_ENDITER);
AutoValueRooter tvr(cx, cx->exception);
cx->throwing = false;
ok = js_CloseIterator(cx, regs.sp[-1]);
ok = js_CloseIterator(cx, &regs.sp[-1].toObject());
regs.sp -= 1;
if (!ok)
goto error;

View File

@ -785,14 +785,11 @@ CloseGenerator(JSContext *cx, JSObject *genobj);
#endif
JS_FRIEND_API(JSBool)
js_CloseIterator(JSContext *cx, const Value &v)
js_CloseIterator(JSContext *cx, JSObject *obj)
{
cx->iterValue.setMagic(JS_NO_ITER_VALUE);
JS_ASSERT(v.isObject());
JSObject *obj = &v.toObject();
Class *clasp = obj->getClass();
if (clasp == &js_IteratorClass.base) {
/* Remove enumerators from the active list, which is a stack. */
NativeIterator *ni = obj->getNativeIterator();

View File

@ -160,7 +160,7 @@ extern JS_FRIEND_API(JSBool)
js_ValueToIterator(JSContext *cx, uintN flags, js::Value *vp);
extern JS_FRIEND_API(JSBool)
js_CloseIterator(JSContext *cx, const js::Value &v);
js_CloseIterator(JSContext *cx, JSObject *iterObj);
bool
js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id);

View File

@ -14252,7 +14252,7 @@ TraceRecorder::record_JSOP_MOREITER()
static JSBool FASTCALL
CloseIterator(JSContext *cx, JSObject *iterobj)
{
if (!js_CloseIterator(cx, ObjectValue(*iterobj))) {
if (!js_CloseIterator(cx, iterobj)) {
SetBuiltinError(cx);
return false;
}

View File

@ -697,7 +697,12 @@ Reify(JSContext *cx, JSCompartment *origin, Value *vp)
if (!origin->wrap(cx, &obj))
return false;
/* Wrap the elements in the iterator's snapshot. */
/*
* Wrap the elements in the iterator's snapshot.
* N.B. the order of closing/creating iterators is important due to the
* implicit cx->enumerators state.
*/
if (ni->isKeyIter()) {
size_t length = ni->numKeys();
AutoIdVector keys(cx);
@ -711,27 +716,25 @@ Reify(JSContext *cx, JSCompartment *origin, Value *vp)
}
}
if (!VectorToKeyIterator(cx, obj, ni->flags, keys, vp))
return false;
} else {
size_t length = ni->numValues();
AutoValueVector vals(cx);
if (length > 0) {
if (!vals.resize(length))
return false;
for (size_t i = 0; i < length; ++i) {
vals[i] = ni->beginValue()[i];
if (!origin->wrap(cx, &vals[i]))
return false;
}
}
if (!VectorToValueIterator(cx, obj, ni->flags, vals, vp))
return false;
return js_CloseIterator(cx, iterObj) &&
VectorToKeyIterator(cx, obj, ni->flags, keys, vp);
}
return js_CloseIterator(cx, *vp);
size_t length = ni->numValues();
AutoValueVector vals(cx);
if (length > 0) {
if (!vals.resize(length))
return false;
for (size_t i = 0; i < length; ++i) {
vals[i] = ni->beginValue()[i];
if (!origin->wrap(cx, &vals[i]))
return false;
}
}
return js_CloseIterator(cx, iterObj) &&
VectorToValueIterator(cx, obj, ni->flags, vals, vp);
}
bool

View File

@ -0,0 +1 @@
for (b in evalcx('')) {}