Bug 1110928, part 1 - Hoist the LOAD_END PokeGC out of nsJSContext::LoadEnd. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Mon, 23 Jan 2017 19:20:54 +0200
changeset 469637 551a93b7b47186cf638770337545345d8cd3b720
parent 469636 ca140640db896900dd2eb62f30a822a92af7c469
child 469638 b39457b9fe3bffc6d05a4e118273beae2a772aeb
push id43793
push userdmitchell@mozilla.com
push dateThu, 02 Feb 2017 14:41:57 +0000
reviewerssmaug
bugs1110928
milestone54.0a1
Bug 1110928, part 1 - Hoist the LOAD_END PokeGC out of nsJSContext::LoadEnd. r=smaug nsDocumentViewer knows which document is involved which will help us later. Also, fix a typo in the comment.
dom/base/nsJSEnvironment.cpp
layout/base/nsDocumentViewer.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1845,19 +1845,17 @@ nsJSContext::LoadEnd()
 
   // sPendingLoadCount is not a well managed load counter (and doesn't
   // need to be), so make sure we don't make it wrap backwards here.
   if (sPendingLoadCount > 0) {
     --sPendingLoadCount;
     return;
   }
 
-  // Its probably a good idea to GC soon since we have finished loading.
   sLoadingInProgress = false;
-  PokeGC(JS::gcreason::LOAD_END);
 }
 
 // Only trigger expensive timers when they have been checked a number of times.
 static bool
 ReadyToTriggerExpensiveCollectorTimer()
 {
   bool ready = kPokesBetweenExpensiveCollectorTriggers < ++sExpensiveCollectorPokes;
   if (ready) {
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1080,16 +1080,19 @@ nsDocumentViewer::LoadComplete(nsresult 
       if (mPresShell) {
         mPresShell->LoadComplete();
       }
     }
   }
 
   nsJSContext::LoadEnd();
 
+  // It's probably a good idea to GC soon since we have finished loading.
+  PokeGC(JS::gcreason::LOAD_END);
+
 #ifdef NS_PRINTING
   // Check to see if someone tried to print during the load
   if (mPrintIsPending) {
     mPrintIsPending        = false;
     mPrintDocIsFullyLoaded = true;
     Print(mCachedPrintSettings, mCachedPrintWebProgressListner);
     mCachedPrintSettings           = nullptr;
     mCachedPrintWebProgressListner = nullptr;