Bug 1382722 - Trigger debugger GC notification once at the end of GC r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 21 Jul 2017 10:01:14 +0100
changeset 418907 07888792204bdac76dea9f16afd04613edc6633d
parent 418906 d9d10df4a1354f5a9ce2f69a52c2064423489dd2
child 418908 217ad633fbf7ea7b334c1da31c96248424f1d1dd
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1382722
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382722 - Trigger debugger GC notification once at the end of GC r=sfink
js/src/gc/Zone.h
js/src/jsgc.cpp
--- a/js/src/gc/Zone.h
+++ b/js/src/gc/Zone.h
@@ -211,25 +211,21 @@ struct Zone : public JS::shadow::Zone,
     void unscheduleGC() { gcScheduled_ = false; }
     bool isGCScheduled() { return gcScheduled_ && canCollect(); }
 
     void setPreservingCode(bool preserving) { gcPreserveCode_ = preserving; }
     bool isPreservingCode() const { return gcPreserveCode_; }
 
     bool canCollect();
 
-    void notifyObservingDebuggers();
-
     void changeGCState(GCState prev, GCState next) {
         MOZ_ASSERT(CurrentThreadIsHeapBusy());
         MOZ_ASSERT(gcState() == prev);
         MOZ_ASSERT_IF(next != NoGC, canCollect());
         gcState_ = next;
-        if (isGCFinished())
-            notifyObservingDebuggers();
     }
 
     bool isCollecting() const {
         MOZ_ASSERT(CurrentThreadCanAccessRuntime(runtimeFromActiveCooperatingThread()));
         return isCollectingFromAnyThread();
     }
 
     bool isCollectingFromAnyThread() const {
@@ -298,16 +294,18 @@ struct Zone : public JS::shadow::Zone,
 
     js::gc::UniqueIdMap& uniqueIds() { return uniqueIds_.ref(); }
 
   public:
     bool hasDebuggers() const { return debuggers && debuggers->length(); }
     DebuggerVector* getDebuggers() const { return debuggers; }
     DebuggerVector* getOrCreateDebuggers(JSContext* cx);
 
+    void notifyObservingDebuggers();
+
     void clearTables();
 
     /*
      * When true, skip calling the metadata callback. We use this:
      * - to avoid invoking the callback recursively;
      * - to avoid observing lazy prototype setup (which confuses callbacks that
      *   want to use the types being set up!);
      * - to avoid attaching allocation stacks to allocation stack nodes, which
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -6132,16 +6132,17 @@ GCRuntime::finishCollection(JS::gcreason
     MemProfiler::SweepTenured(rt);
 
     uint64_t currentTime = PRMJ_Now();
     schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables);
 
     for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
         if (zone->isCollecting()) {
             zone->changeGCState(Zone::Finished, Zone::NoGC);
+            zone->notifyObservingDebuggers();
         }
 
         MOZ_ASSERT(!zone->isCollectingFromAnyThread());
         MOZ_ASSERT(!zone->wasGCStarted());
     }
 
     MOZ_ASSERT(zonesToMaybeCompact.ref().isEmpty());