Backout bug 1052793 for exposing bad decommitting behavior for compartmental GCs.
authorAndrew McCreight <amccreight@mozilla.com>
Thu, 08 Jan 2015 09:54:13 -0800
changeset 222802 204c0dfa5e0bcccb26dc5e94c5c0136d70adb12d
parent 222801 95d32869e77fdbf8c9d386097db87c4dd49f984a
child 222803 c1917197e60f12547968bd1ace5097c8defc25d4
push id28073
push userkwierso@gmail.com
push dateFri, 09 Jan 2015 01:08:23 +0000
treeherdermozilla-central@b3f84cf78dc2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1052793
milestone37.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
Backout bug 1052793 for exposing bad decommitting behavior for compartmental GCs.
dom/base/nsJSEnvironment.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/CycleCollectedJSRuntime.h
xpcom/base/nsCycleCollector.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -180,17 +180,16 @@ static int32_t sCCTimerFireCount = 0;
 static uint32_t sMinForgetSkippableTime = UINT32_MAX;
 static uint32_t sMaxForgetSkippableTime = 0;
 static uint32_t sTotalForgetSkippableTime = 0;
 static uint32_t sRemovedPurples = 0;
 static uint32_t sForgetSkippableBeforeCC = 0;
 static uint32_t sPreviousSuspectedCount = 0;
 static uint32_t sCleanupsSinceLastGC = UINT32_MAX;
 static bool sNeedsFullCC = false;
-static bool sNeedsFullGC = false;
 static bool sNeedsGCAfterCC = false;
 static bool sIncrementalCC = false;
 static bool sDidPaintAfterPreviousICCSlice = false;
 
 static nsScriptNameSpaceManager *gNameSpaceManager;
 
 static nsIJSRuntimeService *sRuntimeService;
 
@@ -1280,23 +1279,17 @@ nsJSContext::GarbageCollectNow(JS::gcrea
 
   if (sCCLockedOut && aIncremental == IncrementalGC) {
     // We're in the middle of incremental GC. Do another slice.
     JS::PrepareForIncrementalGC(sRuntime);
     JS::IncrementalGCSlice(sRuntime, aReason, aSliceMillis);
     return;
   }
 
-  if (sNeedsFullGC || aReason != JS::gcreason::CC_WAITING) {
-    sNeedsFullGC = false;
-    JS::PrepareForFullGC(sRuntime);
-  } else {
-    CycleCollectedJSRuntime::Get()->PrepareWaitingZonesForGC();
-  }
-
+  JS::PrepareForFullGC(sRuntime);
   if (aIncremental == IncrementalGC) {
     MOZ_ASSERT(aShrinking == NonShrinkingGC);
     JS::StartIncrementalGC(sRuntime, GC_NORMAL, aReason, aSliceMillis);
   } else {
     JSGCInvocationKind gckind = aShrinking == ShrinkingGC ? GC_SHRINK : GC_NORMAL;
     JS::GCForReason(sRuntime, gckind, aReason);
   }
 }
@@ -1972,18 +1965,16 @@ nsJSContext::RunNextCollectorTimer()
     return;
   }
 }
 
 // static
 void
 nsJSContext::PokeGC(JS::gcreason::Reason aReason, int aDelay)
 {
-  sNeedsFullGC = sNeedsFullGC || aReason != JS::gcreason::CC_WAITING;
-
   if (sGCTimer || sInterSliceGCTimer || sShuttingDown) {
     // There's already a timer for GC'ing, just return
     return;
   }
 
   if (sCCTimer) {
     // Make sure CC is called...
     sNeedsFullCC = true;
@@ -2295,17 +2286,16 @@ mozilla::dom::StartupJSEnvironment()
   sHasRunGC = false;
   sPendingLoadCount = 0;
   sLoadingInProgress = false;
   sCCollectedWaitingForGC = 0;
   sCCollectedZonesWaitingForGC = 0;
   sLikelyShortLivingObjectsNeedingGC = 0;
   sPostGCEventsToConsole = false;
   sNeedsFullCC = false;
-  sNeedsFullGC = false;
   sNeedsGCAfterCC = false;
   gNameSpaceManager = nullptr;
   sRuntimeService = nullptr;
   sRuntime = nullptr;
   sIsInitialized = false;
   sDidShutdown = false;
   sShuttingDown = false;
   sContextCount = 0;
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -1260,17 +1260,16 @@ CycleCollectedJSRuntime::AnnotateAndSetO
 }
 
 void
 CycleCollectedJSRuntime::OnGC(JSGCStatus aStatus)
 {
   switch (aStatus) {
     case JSGC_BEGIN:
       nsCycleCollector_prepareForGarbageCollection();
-      mZonesWaitingForGC.Clear();
       break;
     case JSGC_END: {
 #ifdef MOZ_CRASHREPORTER
       if (mOutOfMemoryState == OOMState::Reported) {
         AnnotateAndSetOutOfMemory(&mOutOfMemoryState, OOMState::Recovered);
       }
       if (mLargeAllocationFailureState == OOMState::Reported) {
         AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Recovered);
@@ -1299,26 +1298,8 @@ CycleCollectedJSRuntime::OnOutOfMemory()
 
 void
 CycleCollectedJSRuntime::OnLargeAllocationFailure()
 {
   AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Reporting);
   CustomLargeAllocationFailureCallback();
   AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Reported);
 }
-
-static PLDHashOperator
-PrepareWaitingZoneForGC(nsPtrHashKey<JS::Zone>* aZoneEntry, void*)
-{
-  JS::PrepareZoneForGC(aZoneEntry->GetKey());
-  return PL_DHASH_NEXT;
-}
-
-void
-CycleCollectedJSRuntime::PrepareWaitingZonesForGC()
-{
-  if (mZonesWaitingForGC.Count() == 0) {
-    JS::PrepareForFullGC(Runtime());
-  } else {
-    mZonesWaitingForGC.EnumerateEntries(PrepareWaitingZoneForGC, nullptr);
-    mZonesWaitingForGC.Clear();
-  }
-}
--- a/xpcom/base/CycleCollectedJSRuntime.h
+++ b/xpcom/base/CycleCollectedJSRuntime.h
@@ -10,17 +10,16 @@
 #include "mozilla/MemoryReporting.h"
 #include "jsapi.h"
 
 #include "nsCycleCollector.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
-#include "nsTHashtable.h"
 
 class nsCycleCollectionNoteRootCallback;
 class nsIException;
 class nsIRunnable;
 
 namespace js {
 struct Class;
 }
@@ -287,28 +286,16 @@ public:
     MOZ_ASSERT(mJSRuntime);
     return mJSRuntime;
   }
 
   // Get the current thread's CycleCollectedJSRuntime.  Returns null if there
   // isn't one.
   static CycleCollectedJSRuntime* Get();
 
-  // Add aZone to the set of zones waiting for a GC.
-  void AddZoneWaitingForGC(JS::Zone* aZone)
-  {
-    mZonesWaitingForGC.PutEntry(aZone);
-  }
-
-  // Prepare any zones for GC that have been passed to AddZoneWaitingForGC()
-  // since the last GC or since the last call to PrepareWaitingZonesForGC(),
-  // whichever was most recent. If there were no such zones, prepare for a
-  // full GC.
-  void PrepareWaitingZonesForGC();
-
 private:
   JSGCThingParticipant mGCThingCycleCollectorGlobal;
 
   JSZoneParticipant mJSZoneCycleCollectorGlobal;
 
   JSRuntime* mJSRuntime;
 
   nsDataHashtable<nsPtrHashKey<void>, nsScriptObjectTracer*> mJSHolders;
@@ -321,18 +308,16 @@ private:
   nsRefPtr<IncrementalFinalizeRunnable> mFinalizeRunnable;
 
   nsCOMPtr<nsIException> mPendingException;
 
   nsTArray<nsRefPtr<nsIRunnable>> mPromiseMicroTaskQueue;
 
   OOMState mOutOfMemoryState;
   OOMState mLargeAllocationFailureState;
-
-  nsTHashtable<nsPtrHashKey<JS::Zone>> mZonesWaitingForGC;
 };
 
 MOZ_FINISH_NESTED_ENUM_CLASS(CycleCollectedJSRuntime::OOMState)
 
 void TraceScriptHolder(nsISupports* aHolder, JSTracer* aTracer);
 
 // Returns true if the JSGCTraceKind is one the cycle collector cares about.
 inline bool AddToCCKind(JSGCTraceKind aKind)
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3270,24 +3270,19 @@ nsCycleCollector::CollectWhite()
     hasJSRuntime ? mJSRuntime->ZoneParticipant() : nullptr;
 
   NodePool::Enumerator etor(mGraph.mNodes);
   while (!etor.IsDone()) {
     PtrInfo* pinfo = etor.GetNext();
     if (pinfo->mColor == white && pinfo->mParticipant) {
       if (pinfo->IsGrayJS()) {
         ++numWhiteGCed;
-        JS::Zone* zone;
         if (MOZ_UNLIKELY(pinfo->mParticipant == zoneParticipant)) {
           ++numWhiteJSZones;
-          zone = static_cast<JS::Zone*>(pinfo->mPointer);
-        } else {
-          zone = JS::GetTenuredGCThingZone(pinfo->mPointer);
         }
-        mJSRuntime->AddZoneWaitingForGC(zone);
       } else {
         whiteNodes.InfallibleAppend(pinfo);
         pinfo->mParticipant->Root(pinfo->mPointer);
         ++numWhiteNodes;
       }
     }
   }