Bug 813419. Add a non-null-checking version of xpc_UnmarkGrayObject. r=mccr8

This commit is contained in:
Boris Zbarsky 2012-11-20 11:36:06 -05:00
parent 0dc548ff6f
commit 4479610b88
2 changed files with 19 additions and 9 deletions

View File

@ -478,10 +478,13 @@ template <class T>
inline bool
WrapNewBindingObject(JSContext* cx, JSObject* scope, T* value, JS::Value* vp)
{
JSObject* obj = value->GetWrapper();
if (obj && js::GetObjectCompartment(obj) == js::GetObjectCompartment(scope)) {
*vp = JS::ObjectValue(*obj);
return true;
JSObject* obj = value->GetWrapperPreserveColor();
if (obj) {
xpc_UnmarkNonNullGrayObject(obj);
if (js::GetObjectCompartment(obj) == js::GetObjectCompartment(scope)) {
*vp = JS::ObjectValue(*obj);
return true;
}
}
if (!obj) {

View File

@ -140,16 +140,23 @@ xpc_GCThingIsGrayCCThing(void *thing);
extern void
xpc_UnmarkGrayGCThingRecursive(void *thing, JSGCTraceKind kind);
// Unmark gray for known-nonnull cases
MOZ_ALWAYS_INLINE void
xpc_UnmarkNonNullGrayObject(JSObject *obj)
{
if (xpc_IsGrayGCThing(obj))
xpc_UnmarkGrayGCThingRecursive(obj, JSTRACE_OBJECT);
else if (JS::IsIncrementalBarrierNeededOnGCThing(obj))
js::IncrementalReferenceBarrier(obj);
}
// Remove the gray color from the given JSObject and any other objects that can
// be reached through it.
inline JSObject *
MOZ_ALWAYS_INLINE JSObject *
xpc_UnmarkGrayObject(JSObject *obj)
{
if (obj) {
if (xpc_IsGrayGCThing(obj))
xpc_UnmarkGrayGCThingRecursive(obj, JSTRACE_OBJECT);
else if (JS::IsIncrementalBarrierNeededOnGCThing(obj))
js::IncrementalReferenceBarrier(obj);
xpc_UnmarkNonNullGrayObject(obj);
}
return obj;
}