From 5f16c54e36c0eec497672a16988fd872b241dd25 Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Mon, 22 Sep 2014 13:22:30 -0700 Subject: [PATCH] Bug 1064578 - Part 6: make zone sweeping fine-grained too; r=jonco --HG-- extra : rebase_source : 002d5e61254440f939e5f35bb35937481189f046 --- js/src/gc/Zone.cpp | 34 ++++++++++++++++++---------------- js/src/gc/Zone.h | 2 +- js/src/jsgc.cpp | 29 ++++++++++++++--------------- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index d310354ca86..50b6999e023 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -104,33 +104,35 @@ Zone::onTooMuchMalloc() } 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 - * do when there are no frames for the zone on the stack. - */ + // Periodically release observed types for all scripts. This is safe to + // do when there are no frames for the zone on the stack. if (active) releaseTypes = false; - GCRuntime &gc = fop->runtime()->gc; + bool oom = false; + types.sweep(fop, releaseTypes, &oom); - { - gcstats::MaybeAutoPhase ap(gc.stats, !gc.isHeapCompacting(), - gcstats::PHASE_DISCARD_ANALYSIS); - types.sweep(fop, releaseTypes, oom); - } - - if (!fop->runtime()->debuggerList.isEmpty()) { - gcstats::MaybeAutoPhase ap2(gc.stats, !gc.isHeapCompacting(), - gcstats::PHASE_SWEEP_BREAKPOINT); - sweepBreakpoints(fop); + // If there was an OOM while sweeping types, the type information needs to + // be deoptimized so that it will 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. + if (oom) { + setPreservingCode(false); + discardJitCode(fop); + types.clearAllNewScriptsOnOOM(); } } void 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 * to iterate over the scripts belonging to a single compartment in a zone. diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index 2e3a624a005..92005c4fe4d 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -157,7 +157,7 @@ struct Zone : public JS::shadow::Zone, } void reportAllocationOverflow() { js_ReportAllocationOverflow(nullptr); } - void sweep(js::FreeOp *fop, bool releaseTypes, bool *oom); + void sweepAnalysis(js::FreeOp *fop, bool releaseTypes); bool hasMarkedCompartments(); diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 676afbfa3db..010f2c4ad0a 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -4705,12 +4705,15 @@ GCRuntime::beginSweepingZoneGroup() c->sweepSavedStacks(); c->sweepGlobalObject(&fop); c->sweepSelfHostingScriptSource(); - c->sweepJitCompartment(&fop); c->sweepDebugScopes(); + c->sweepJitCompartment(&fop); c->sweepWeakMaps(); 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. WatchpointMap::sweepAll(rt); @@ -4726,22 +4729,18 @@ GCRuntime::beginSweepingZoneGroup() } { + gcstats::MaybeAutoPhase ap(stats, !isHeapCompacting(), + gcstats::PHASE_DISCARD_ANALYSIS); for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) { - // If there is an OOM while sweeping types, the type information - // 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); + zone->sweepAnalysis(&fop, releaseObservedTypes && !zone->isPreservingCode()); + } + } - 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); } } }