mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 15:15:23 +00:00
Bug 782315 - GC: Cut out unnecessary work when not collecting atoms r=billm
This commit is contained in:
parent
be7fa3cf51
commit
ca7c98775e
@ -204,27 +204,19 @@ js::FinishCommonAtoms(JSRuntime *rt)
|
||||
}
|
||||
|
||||
void
|
||||
js::MarkAtomState(JSTracer *trc, bool markAll)
|
||||
js::MarkAtomState(JSTracer *trc)
|
||||
{
|
||||
JSRuntime *rt = trc->runtime;
|
||||
JSAtomState *state = &rt->atomState;
|
||||
|
||||
if (markAll) {
|
||||
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
||||
JSAtom *tmp = r.front().asPtr();
|
||||
MarkStringRoot(trc, &tmp, "locked_atom");
|
||||
JS_ASSERT(tmp == r.front().asPtr());
|
||||
}
|
||||
} else {
|
||||
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
||||
AtomStateEntry entry = r.front();
|
||||
if (!entry.isTagged())
|
||||
continue;
|
||||
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
||||
AtomStateEntry entry = r.front();
|
||||
if (!entry.isTagged())
|
||||
continue;
|
||||
|
||||
JSAtom *tmp = entry.asPtr();
|
||||
MarkStringRoot(trc, &tmp, "interned_atom");
|
||||
JS_ASSERT(tmp == entry.asPtr());
|
||||
}
|
||||
JSAtom *tmp = entry.asPtr();
|
||||
MarkStringRoot(trc, &tmp, "interned_atom");
|
||||
JS_ASSERT(tmp == entry.asPtr());
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,8 +235,6 @@ js::SweepAtomState(JSRuntime *rt)
|
||||
|
||||
if (!isMarked)
|
||||
e.removeFront();
|
||||
else
|
||||
e.rekeyFront(AtomHasher::Lookup(atom), AtomStateEntry(atom, entry.isTagged()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ FinishAtomState(JSRuntime *rt);
|
||||
* Atom tracing and garbage collection hooks.
|
||||
*/
|
||||
extern void
|
||||
MarkAtomState(JSTracer *trc, bool markAll);
|
||||
MarkAtomState(JSTracer *trc);
|
||||
|
||||
extern void
|
||||
SweepAtomState(JSRuntime *rt);
|
||||
|
@ -2501,13 +2501,8 @@ MarkRuntime(JSTracer *trc, bool useSavedRoots = false)
|
||||
MarkScriptRoot(trc, &vec[i].script, "scriptAndCountsVector");
|
||||
}
|
||||
|
||||
/*
|
||||
* Atoms are not in the cross-compartment map. So if there are any
|
||||
* compartments that are not being collected, we are not allowed to collect
|
||||
* atoms. Otherwise, the non-collected compartments could contain pointers
|
||||
* to atoms that we would miss.
|
||||
*/
|
||||
MarkAtomState(trc, rt->gcKeepAtoms || (IS_GC_MARKING_TRACER(trc) && !rt->gcIsFull));
|
||||
if (!IS_GC_MARKING_TRACER(trc) || rt->atomsCompartment->isCollecting())
|
||||
MarkAtomState(trc);
|
||||
rt->staticStrings.trace(trc);
|
||||
|
||||
for (ContextIter acx(rt); !acx.done(); acx.next())
|
||||
@ -3487,6 +3482,7 @@ BeginSweepPhase(JSRuntime *rt)
|
||||
if (!c->isCollecting())
|
||||
isFull = false;
|
||||
}
|
||||
JS_ASSERT_IF(isFull, rt->gcIsFull);
|
||||
|
||||
rt->gcSweepOnBackgroundThread =
|
||||
(rt->hasContexts() && rt->gcHelperThread.prepareForBackgroundSweep());
|
||||
@ -3507,7 +3503,7 @@ BeginSweepPhase(JSRuntime *rt)
|
||||
WeakMapBase::sweepAll(&rt->gcMarker);
|
||||
rt->debugScopes->sweep();
|
||||
|
||||
{
|
||||
if (rt->atomsCompartment->wasGCStarted()) {
|
||||
gcstats::AutoPhase ap2(rt->gcStats, gcstats::PHASE_SWEEP_ATOMS);
|
||||
SweepAtomState(rt);
|
||||
}
|
||||
@ -3703,15 +3699,27 @@ AutoTraceSession::~AutoTraceSession()
|
||||
AutoGCSession::AutoGCSession(JSRuntime *rt)
|
||||
: AutoTraceSession(rt, JSRuntime::Collecting)
|
||||
{
|
||||
bool all = true;
|
||||
DebugOnly<bool> any = false;
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
if (c->isGCScheduled()) {
|
||||
c->setCollecting(true);
|
||||
any = true;
|
||||
} else {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
JS_ASSERT(any);
|
||||
|
||||
/*
|
||||
* Atoms are not in the cross-compartment map. So if there are any
|
||||
* compartments that are not being collected, we are not allowed to collect
|
||||
* atoms. Otherwise, the non-collected compartments could contain pointers
|
||||
* to atoms that we would miss.
|
||||
*/
|
||||
if (rt->gcKeepAtoms || !all)
|
||||
rt->atomsCompartment->setCollecting(false);
|
||||
|
||||
runtime->gcIsNeeded = false;
|
||||
runtime->gcInterFrameGC = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user