Bug 754588 - Set rt->gcPoke when doing xpconnect unrooting (r=mccr8)

This commit is contained in:
Bill McCloskey 2012-05-22 14:06:58 -07:00
Родитель 938e8ce943
Коммит 2b12ff4698
6 изменённых файлов: 27 добавлений и 4 удалений

Просмотреть файл

@ -718,6 +718,7 @@ JSRuntime::JSRuntime()
gcNextFullGCTime(0),
gcJitReleaseTime(0),
gcMode(JSGC_MODE_GLOBAL),
gcShouldCleanUpEverything(false),
gcIsNeeded(0),
gcWeakMapList(NULL),
gcStats(thisFromCtor()),

Просмотреть файл

@ -490,6 +490,9 @@ struct JSRuntime : js::RuntimeFriendFields
int64_t gcJitReleaseTime;
JSGCMode gcMode;
/* During shutdown, the GC needs to clean up every possible object. */
bool gcShouldCleanUpEverything;
/*
* These flags must be kept separate so that a thread requesting a
* compartment GC doesn't cancel another thread's concurrent request for a

Просмотреть файл

@ -785,6 +785,12 @@ IncrementalValueBarrier(const Value &v)
HeapValue::writeBarrierPre(v);
}
extern JS_FRIEND_API(void)
PokeGC(JSRuntime *rt)
{
rt->gcPoke = true;
}
JS_FRIEND_API(JSObject *)
GetTestingFunctions(JSContext *cx)
{

Просмотреть файл

@ -700,6 +700,9 @@ IncrementalReferenceBarrier(void *ptr);
extern JS_FRIEND_API(void)
IncrementalValueBarrier(const Value &v);
extern JS_FRIEND_API(void)
PokeGC(JSRuntime *rt);
class ObjectPtr
{
JSObject *value;

Просмотреть файл

@ -2872,7 +2872,7 @@ PurgeRuntime(JSTracer *trc)
static bool
ShouldPreserveJITCode(JSCompartment *c, int64_t currentTime)
{
if (!c->rt->hasContexts() || !c->types.inferenceEnabled)
if (c->rt->gcShouldCleanUpEverything || !c->types.inferenceEnabled)
return false;
if (c->rt->alwaysPreserveCode)
@ -3628,6 +3628,12 @@ IsDeterministicGCReason(gcreason::Reason reason)
}
#endif
static bool
ShouldCleanUpEverything(JSRuntime *rt, gcreason::Reason reason)
{
return !rt->hasContexts() || reason == gcreason::CC_FORCED;
}
static void
Collect(JSRuntime *rt, bool incremental, int64_t budget,
JSGCInvocationKind gckind, gcreason::Reason reason)
@ -3679,6 +3685,8 @@ Collect(JSRuntime *rt, bool incremental, int64_t budget,
collectedCount++;
}
rt->gcShouldCleanUpEverything = ShouldCleanUpEverything(rt, reason);
gcstats::AutoGCSlice agc(rt->gcStats, collectedCount, compartmentCount, reason);
do {
@ -3702,14 +3710,14 @@ Collect(JSRuntime *rt, bool incremental, int64_t budget,
}
/* Need to re-schedule all compartments for GC. */
if (!rt->hasContexts() && rt->gcPoke)
if (rt->gcPoke && rt->gcShouldCleanUpEverything)
PrepareForFullGC(rt);
/*
* On shutdown, iterate until finalizers or the JSGC_END callback
* stop creating garbage.
*/
} while (!rt->hasContexts() && rt->gcPoke);
} while (rt->gcPoke && rt->gcShouldCleanUpEverything);
}
namespace js {
@ -4578,4 +4586,3 @@ js_NewGCXML(JSContext *cx)
return NewGCThing<JSXML>(cx, js::gc::FINALIZE_XML, sizeof(JSXML));
}
#endif

Просмотреть файл

@ -2270,6 +2270,9 @@ XPCRootSetElem::AddToRootSet(XPCLock *lock, XPCRootSetElem **listHead)
void
XPCRootSetElem::RemoveFromRootSet(XPCLock *lock)
{
if (nsXPConnect *xpc = nsXPConnect::GetXPConnect())
js::PokeGC(xpc->GetRuntime()->GetJSRuntime());
NS_ASSERTION(mSelfp, "Must be linked");
XPCAutoLock autoLock(lock);