Bug 1547310 - Cap the number of SharedScriptData leaks logged. r=jonco
authorAndrew McCreight <continuation@gmail.com>
Mon, 29 Apr 2019 09:28:12 +0000
changeset 471751 0e93a381964bd65bf2785c7856b3d9806094f13e
parent 471750 d8aabb74946258bdaa6964e7e41fdd409604ae73
child 471752 87be514024ac53ab6362ffc26610c063d50abe07
push id35934
push usershindli@mozilla.com
push dateMon, 29 Apr 2019 21:53:38 +0000
treeherdermozilla-central@f6766ba4ac77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1547310
milestone68.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 1547310 - Cap the number of SharedScriptData leaks logged. r=jonco Also, reduce the number logged for other tracekinds to 5. Differential Revision: https://phabricator.services.mozilla.com/D29041
js/src/gc/GC.cpp
js/src/vm/JSScript.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -3930,17 +3930,17 @@ static const char* AllocKindToAscii(Allo
 #endif  // DEBUG
 
 bool ArenaLists::checkEmptyArenaList(AllocKind kind) {
   bool isEmpty = true;
 #ifdef DEBUG
   size_t numLive = 0;
   if (!arenaLists(kind).isEmpty()) {
     isEmpty = false;
-    size_t maxCells = 20;
+    size_t maxCells = 5;
     char* env = getenv("JS_GC_MAX_LIVE_CELLS");
     if (env && *env) {
       maxCells = atol(env);
     }
     for (Arena* current = arenaLists(kind).head(); current;
          current = current->next) {
       for (ArenaCellIterUnderGC i(current); !i.done(); i.next()) {
         TenuredCell* t = i.getCell();
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -3303,27 +3303,44 @@ void js::SweepScriptData(JSRuntime* rt) 
 void js::FreeScriptData(JSRuntime* rt) {
   AutoLockScriptData lock(rt);
 
   ScriptDataTable& table = rt->scriptDataTable(lock);
 
   // The table should be empty unless the embedding leaked GC things.
   MOZ_ASSERT_IF(rt->gc.shutdownCollectedEverything(), table.empty());
 
+#ifdef DEBUG
+  size_t numLive = 0;
+  size_t maxCells = 5;
+  char* env = getenv("JS_GC_MAX_LIVE_CELLS");
+  if (env && *env) {
+    maxCells = atol(env);
+  }
+#endif
+
   for (ScriptDataTable::Enum e(table); !e.empty(); e.popFront()) {
 #ifdef DEBUG
-    SharedScriptData* scriptData = e.front();
-    fprintf(stderr,
-            "ERROR: GC found live SharedScriptData %p with ref count %d at "
-            "shutdown\n",
-            scriptData, scriptData->refCount());
+    if (++numLive <= maxCells) {
+      SharedScriptData* scriptData = e.front();
+      fprintf(stderr,
+              "ERROR: GC found live SharedScriptData %p with ref count %d at "
+              "shutdown\n",
+              scriptData, scriptData->refCount());
+    }
 #endif
     js_free(e.front());
   }
 
+#ifdef DEBUG
+  if (numLive > 0) {
+    fprintf(stderr, "ERROR: GC found %zu live SharedScriptData at shutdown\n", numLive);
+  }
+#endif
+
   table.clear();
 }
 
 /* static */
 size_t PrivateScriptData::AllocationSize(uint32_t nscopes, uint32_t nconsts,
                                          uint32_t nobjects, uint32_t ntrynotes,
                                          uint32_t nscopenotes,
                                          uint32_t nresumeoffsets) {