Bug 770121: GC: Make GC more deterministic when JS_MORE_DETERMINISTIC is defined r=billm

This commit is contained in:
Jon Coppeard 2012-07-04 12:17:49 +01:00
parent 920262360f
commit 00bb145d73

View File

@ -828,7 +828,9 @@ js_InitGC(JSRuntime *rt, uint32_t maxbytes)
rt->gcMaxBytes = maxbytes; rt->gcMaxBytes = maxbytes;
rt->setGCMaxMallocBytes(maxbytes); rt->setGCMaxMallocBytes(maxbytes);
#ifndef JS_MORE_DETERMINISTIC
rt->gcJitReleaseTime = PRMJ_Now() + JIT_SCRIPT_RELEASE_TYPES_INTERVAL; rt->gcJitReleaseTime = PRMJ_Now() + JIT_SCRIPT_RELEASE_TYPES_INTERVAL;
#endif
return true; return true;
} }
@ -2495,6 +2497,7 @@ MaybeGC(JSContext *cx)
return; return;
} }
#ifndef JS_MORE_DETERMINISTIC
/* /*
* Access to the counters and, on 32 bit, setting gcNextFullGCTime below * Access to the counters and, on 32 bit, setting gcNextFullGCTime below
* is not atomic and a race condition could trigger or suppress the GC. We * is not atomic and a race condition could trigger or suppress the GC. We
@ -2511,6 +2514,7 @@ MaybeGC(JSContext *cx)
rt->gcNextFullGCTime = now + GC_IDLE_FULL_SPAN; rt->gcNextFullGCTime = now + GC_IDLE_FULL_SPAN;
} }
} }
#endif
} }
static void static void
@ -2944,12 +2948,15 @@ GCHelperThread::doSweep()
static bool static bool
ReleaseObservedTypes(JSRuntime *rt) ReleaseObservedTypes(JSRuntime *rt)
{ {
bool releaseTypes = false; bool releaseTypes = rt->gcZeal() != 0;
#ifndef JS_MORE_DETERMINISTIC
int64_t now = PRMJ_Now(); int64_t now = PRMJ_Now();
if (rt->gcZeal() || now >= rt->gcJitReleaseTime) { if (now >= rt->gcJitReleaseTime)
releaseTypes = true; releaseTypes = true;
if (releaseTypes)
rt->gcJitReleaseTime = now + JIT_SCRIPT_RELEASE_TYPES_INTERVAL; rt->gcJitReleaseTime = now + JIT_SCRIPT_RELEASE_TYPES_INTERVAL;
} #endif
return releaseTypes; return releaseTypes;
} }
@ -3473,7 +3480,10 @@ AutoGCSession::~AutoGCSession()
for (GCCompartmentsIter c(runtime); !c.done(); c.next()) for (GCCompartmentsIter c(runtime); !c.done(); c.next())
c->setCollecting(false); c->setCollecting(false);
#ifndef JS_MORE_DETERMINISTIC
runtime->gcNextFullGCTime = PRMJ_Now() + GC_IDLE_FULL_SPAN; runtime->gcNextFullGCTime = PRMJ_Now() + GC_IDLE_FULL_SPAN;
#endif
runtime->gcChunkAllocationSinceLastGC = false; runtime->gcChunkAllocationSinceLastGC = false;
#ifdef JS_GC_ZEAL #ifdef JS_GC_ZEAL