зеркало из https://github.com/mozilla/gecko-dev.git
Bug 778993 - Separate runtime's gcMallocBytes from compartment's gcMallocBytes (r=gwagner,till)
This commit is contained in:
Родитель
df298d2dd6
Коммит
4f41a975bf
|
@ -1410,14 +1410,15 @@ JSRuntime::setGCMaxMallocBytes(size_t value)
|
|||
void
|
||||
JSRuntime::updateMallocCounter(JSContext *cx, size_t nbytes)
|
||||
{
|
||||
/* We tolerate any thread races when updating gcMallocBytes. */
|
||||
ptrdiff_t oldCount = gcMallocBytes;
|
||||
ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
|
||||
gcMallocBytes = newCount;
|
||||
if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
|
||||
onTooMuchMalloc();
|
||||
else if (cx && cx->compartment)
|
||||
if (cx && cx->compartment) {
|
||||
cx->compartment->updateMallocCounter(nbytes);
|
||||
} else {
|
||||
ptrdiff_t oldCount = gcMallocBytes;
|
||||
ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
|
||||
gcMallocBytes = newCount;
|
||||
if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
|
||||
onTooMuchMalloc();
|
||||
}
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
|
|
|
@ -77,7 +77,7 @@ JSCompartment::JSCompartment(JSRuntime *rt)
|
|||
, ionCompartment_(NULL)
|
||||
#endif
|
||||
{
|
||||
setGCMaxMallocBytes(rt->gcMaxMallocBytes * 0.9);
|
||||
setGCMaxMallocBytes(rt->gcMaxMallocBytes / 2);
|
||||
}
|
||||
|
||||
JSCompartment::~JSCompartment()
|
||||
|
|
|
@ -3274,6 +3274,8 @@ BeginMarkPhase(JSRuntime *rt)
|
|||
any = true;
|
||||
if (c != rt->atomsCompartment)
|
||||
c->setGCState(JSCompartment::Mark);
|
||||
|
||||
c->resetGCMallocBytes();
|
||||
} else {
|
||||
rt->gcIsFull = false;
|
||||
}
|
||||
|
@ -3281,6 +3283,9 @@ BeginMarkPhase(JSRuntime *rt)
|
|||
c->setPreservingCode(ShouldPreserveJITCode(c, currentTime));
|
||||
}
|
||||
|
||||
if (rt->gcIsFull)
|
||||
rt->resetGCMallocBytes();
|
||||
|
||||
/* Check that at least one compartment is scheduled for collection. */
|
||||
JS_ASSERT(any);
|
||||
|
||||
|
@ -4036,13 +4041,8 @@ AutoGCSession::~AutoGCSession()
|
|||
runtime->gcSelectedForMarking.clearAndFree();
|
||||
#endif
|
||||
|
||||
/* Clear gcMallocBytes for all compartments */
|
||||
for (CompartmentsIter c(runtime); !c.done(); c.next()) {
|
||||
c->resetGCMallocBytes();
|
||||
for (CompartmentsIter c(runtime); !c.done(); c.next())
|
||||
c->unscheduleGC();
|
||||
}
|
||||
|
||||
runtime->resetGCMallocBytes();
|
||||
}
|
||||
|
||||
class AutoCopyFreeListToArenas {
|
||||
|
|
Загрузка…
Ссылка в новой задаче