Bug 1064578 - Part 6: make zone sweeping fine-grained too; r=jonco

--HG--
extra : rebase_source : 002d5e61254440f939e5f35bb35937481189f046
This commit is contained in:
Terrence Cole 2014-09-22 13:22:30 -07:00
parent e32d33eaf2
commit 5f16c54e36
3 changed files with 33 additions and 32 deletions

View File

@ -104,33 +104,35 @@ Zone::onTooMuchMalloc()
} }
void void
Zone::sweep(FreeOp *fop, bool releaseTypes, bool *oom) Zone::sweepAnalysis(FreeOp *fop, bool releaseTypes)
{ {
/* // Periodically release observed types for all scripts. This is safe to
* Periodically release observed types for all scripts. This is safe to // do when there are no frames for the zone on the stack.
* do when there are no frames for the zone on the stack.
*/
if (active) if (active)
releaseTypes = false; releaseTypes = false;
GCRuntime &gc = fop->runtime()->gc; bool oom = false;
types.sweep(fop, releaseTypes, &oom);
{ // If there was an OOM while sweeping types, the type information needs to
gcstats::MaybeAutoPhase ap(gc.stats, !gc.isHeapCompacting(), // be deoptimized so that it will still correct (i.e. overapproximates the
gcstats::PHASE_DISCARD_ANALYSIS); // possible types in the zone), but the constraints might not have been
types.sweep(fop, releaseTypes, oom); // triggered on the deoptimization or even copied over completely. In this
} // case, destroy all JIT code and new script information in the zone, the
// only things whose correctness depends on the type constraints.
if (!fop->runtime()->debuggerList.isEmpty()) { if (oom) {
gcstats::MaybeAutoPhase ap2(gc.stats, !gc.isHeapCompacting(), setPreservingCode(false);
gcstats::PHASE_SWEEP_BREAKPOINT); discardJitCode(fop);
sweepBreakpoints(fop); types.clearAllNewScriptsOnOOM();
} }
} }
void void
Zone::sweepBreakpoints(FreeOp *fop) Zone::sweepBreakpoints(FreeOp *fop)
{ {
if (fop->runtime()->debuggerList.isEmpty())
return;
/* /*
* Sweep all compartments in a zone at the same time, since there is no way * Sweep all compartments in a zone at the same time, since there is no way
* to iterate over the scripts belonging to a single compartment in a zone. * to iterate over the scripts belonging to a single compartment in a zone.

View File

@ -157,7 +157,7 @@ struct Zone : public JS::shadow::Zone,
} }
void reportAllocationOverflow() { js_ReportAllocationOverflow(nullptr); } void reportAllocationOverflow() { js_ReportAllocationOverflow(nullptr); }
void sweep(js::FreeOp *fop, bool releaseTypes, bool *oom); void sweepAnalysis(js::FreeOp *fop, bool releaseTypes);
bool hasMarkedCompartments(); bool hasMarkedCompartments();

View File

@ -4705,12 +4705,15 @@ GCRuntime::beginSweepingZoneGroup()
c->sweepSavedStacks(); c->sweepSavedStacks();
c->sweepGlobalObject(&fop); c->sweepGlobalObject(&fop);
c->sweepSelfHostingScriptSource(); c->sweepSelfHostingScriptSource();
c->sweepJitCompartment(&fop);
c->sweepDebugScopes(); c->sweepDebugScopes();
c->sweepJitCompartment(&fop);
c->sweepWeakMaps(); c->sweepWeakMaps();
c->sweepNativeIterators(); c->sweepNativeIterators();
} }
// Bug 1071218: the following two methods have not yet been
// refactored to work on a single zone-group at once.
// Collect watch points associated with unreachable objects. // Collect watch points associated with unreachable objects.
WatchpointMap::sweepAll(rt); WatchpointMap::sweepAll(rt);
@ -4726,23 +4729,19 @@ GCRuntime::beginSweepingZoneGroup()
} }
{ {
gcstats::MaybeAutoPhase ap(stats, !isHeapCompacting(),
gcstats::PHASE_DISCARD_ANALYSIS);
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) { for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
// If there is an OOM while sweeping types, the type information zone->sweepAnalysis(&fop, releaseObservedTypes && !zone->isPreservingCode());
// will be deoptimized so that it is still correct (i.e.
// overapproximates the possible types in the zone), but the
// constraints might not have been triggered on the deoptimization
// or even copied over completely. In this case, destroy all JIT
// code and new script information in the zone, the only things
// whose correctness depends on the type constraints.
bool oom = false;
zone->sweep(&fop, releaseObservedTypes && !zone->isPreservingCode(), &oom);
if (oom) {
zone->setPreservingCode(false);
zone->discardJitCode(&fop);
zone->types.clearAllNewScriptsOnOOM();
} }
} }
{
gcstats::MaybeAutoPhase ap(stats, !isHeapCompacting(),
gcstats::PHASE_SWEEP_BREAKPOINT);
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
zone->sweepBreakpoints(&fop);
}
} }
} }