Bug 853498 - GC: Make sure wrapped things are not marked gray r=billm

--HG--
extra : rebase_source : 252c8f915af6852f1df09caec0775920b0483003
This commit is contained in:
Jon Coppeard 2013-03-19 18:50:57 +00:00
parent 147ffd50b2
commit c116ea99a5
2 changed files with 11 additions and 2 deletions

View File

@ -1518,6 +1518,8 @@ JS_WrapObject(JSContext *cx, JSObject **objp)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (*objp)
JS::ExposeGCThingToActiveJS(*objp, JSTRACE_OBJECT);
return cx->compartment->wrap(cx, objp);
}
@ -1526,6 +1528,8 @@ JS_WrapValue(JSContext *cx, jsval *vp)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (vp)
JS::ExposeValueToActiveJS(*vp);
RootedValue value(cx, *vp);
bool ok = cx->compartment->wrap(cx, &value);
*vp = value.get();
@ -1537,6 +1541,13 @@ JS_WrapId(JSContext *cx, jsid *idp)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (idp) {
jsid id = *idp;
if (JSID_IS_STRING(id))
JS::ExposeGCThingToActiveJS(JSID_TO_STRING(id), JSTRACE_STRING);
else if (JSID_IS_OBJECT(id))
JS::ExposeGCThingToActiveJS(JSID_TO_OBJECT(id), JSTRACE_OBJECT);
}
return cx->compartment->wrapId(cx, idp);
}

View File

@ -199,8 +199,6 @@ JSCompartment::putWrapper(const CrossCompartmentKey &wrapped, const js::Value &w
JS_ASSERT(!IsPoisonedPtr(wrapper.toGCThing()));
JS_ASSERT_IF(wrapped.kind == CrossCompartmentKey::StringWrapper, wrapper.isString());
JS_ASSERT_IF(wrapped.kind != CrossCompartmentKey::StringWrapper, wrapper.isObject());
// todo: uncomment when bug 815999 is fixed:
// JS_ASSERT(!wrapped.wrapped->isMarked(gc::GRAY));
return crossCompartmentWrappers.put(wrapped, wrapper);
}