Bug 774104 - Avoid leaks during JS_TransplantObject (r=mccr8)

This commit is contained in:
Bill McCloskey 2012-07-15 14:36:58 -07:00
parent 010c5317a8
commit 167e14d9a8
2 changed files with 10 additions and 1 deletions

View File

@ -1573,6 +1573,15 @@ JS_TransplantObject(JSContext *cx, JSObject *origobj, JSObject *target)
JS_ASSERT(!IsCrossCompartmentWrapper(origobj));
JS_ASSERT(!IsCrossCompartmentWrapper(target));
/*
* Transplantation typically allocates new wrappers in every compartment. If
* an incremental GC is active, this causes every compartment to be leaked
* for that GC. Hence, we finish any ongoing incremental GC before the
* transplant to avoid leaks.
*/
if (cx->runtime->gcIncrementalState != NO_INCREMENTAL)
FinishIncrementalGC(cx->runtime, gcreason::TRANSPLANT);
JSCompartment *destination = target->compartment();
WrapperMap &map = destination->crossCompartmentWrappers;
Value origv = ObjectValue(*origobj);

View File

@ -611,7 +611,7 @@ SizeOfJSContext();
D(ALLOC_TRIGGER) \
D(DEBUG_GC) \
D(DEBUG_MODE_GC) \
D(UNUSED3) /* was REFILL */ \
D(TRANSPLANT) \
\
/* Reasons from Firefox */ \
D(DOM_WINDOW_UTILS) \