bug 566141 r=brendan

This commit is contained in:
Igor Bukanov 2010-05-25 12:54:55 +02:00
parent f17d997577
commit e496ace8f3
2 changed files with 35 additions and 27 deletions

View File

@ -2248,6 +2248,11 @@ class AutoValueRooter : private AutoGCRooter
JS_GUARD_OBJECT_NOTIFIER_INIT; JS_GUARD_OBJECT_NOTIFIER_INIT;
} }
void set(jsval v) {
JS_ASSERT(tag == JSVAL);
val = v;
}
void setObject(JSObject *obj) { void setObject(JSObject *obj) {
JS_ASSERT(tag == JSVAL); JS_ASSERT(tag == JSVAL);
val = OBJECT_TO_JSVAL(obj); val = OBJECT_TO_JSVAL(obj);

View File

@ -248,8 +248,6 @@ MarkSharpObjects(JSContext *cx, JSObject *obj, JSIdArray **idap)
jsid id; jsid id;
JSObject *obj2; JSObject *obj2;
JSProperty *prop; JSProperty *prop;
uintN attrs;
jsval val;
JS_CHECK_RECURSION(cx, return NULL); JS_CHECK_RECURSION(cx, return NULL);
@ -279,32 +277,37 @@ MarkSharpObjects(JSContext *cx, JSObject *obj, JSIdArray **idap)
break; break;
if (!prop) if (!prop)
continue; continue;
ok = obj2->getAttributes(cx, id, prop, &attrs); bool hasGetter, hasSetter;
if (ok) { AutoValueRooter v(cx, JSVAL_VOID);
if (obj2->isNative() && AutoValueRooter setter(cx, JSVAL_VOID);
(attrs & (JSPROP_GETTER | JSPROP_SETTER))) { if (obj->isNative()) {
JSScopeProperty *sprop = (JSScopeProperty *) prop; JSScopeProperty *sprop = (JSScopeProperty *) prop;
val = JSVAL_VOID; hasGetter = sprop->hasGetterValue();
if (attrs & JSPROP_GETTER) hasSetter = sprop->hasSetterValue();
val = sprop->getterValue(); if (hasGetter)
if (attrs & JSPROP_SETTER) { v.set(sprop->getterValue());
if (val != JSVAL_VOID) { if (hasSetter)
/* Mark the getter, then set val to setter. */ setter.set(sprop->setterValue());
ok = (MarkSharpObjects(cx, JSVAL_TO_OBJECT(val), JS_UNLOCK_OBJ(cx, obj2);
NULL) } else {
!= NULL); obj->dropProperty(cx, prop);
} hasGetter = hasSetter = false;
val = sprop->setterValue();
}
} else {
ok = obj->getProperty(cx, id, &val);
}
} }
obj2->dropProperty(cx, prop); if (hasSetter) {
if (!ok) /* Mark the getter, then set val to setter. */
break; if (hasGetter && !JSVAL_IS_PRIMITIVE(v.value())) {
if (!JSVAL_IS_PRIMITIVE(val) && ok = !!MarkSharpObjects(cx, JSVAL_TO_OBJECT(v.value()), NULL);
!MarkSharpObjects(cx, JSVAL_TO_OBJECT(val), NULL)) { if (!ok)
break;
}
v.set(setter.value());
} else if (!hasGetter) {
ok = obj->getProperty(cx, id, v.addr());
if (!ok)
break;
}
if (!JSVAL_IS_PRIMITIVE(v.value()) &&
!MarkSharpObjects(cx, JSVAL_TO_OBJECT(v.value()), NULL)) {
ok = JS_FALSE; ok = JS_FALSE;
break; break;
} }