Bug 1340010 - Make ABORT_GC a deterministic GC reason r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 20 Feb 2017 13:00:14 +0000
changeset 372920 58594006a6fa3fadf523b3c0faa28a964c788103
parent 372919 3df9795825556565fa94702e5cc2645fd3bcb565
child 372921 cd05e24fefffc0e409a30a8a720cb7e05f7a0019
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1340010
milestone54.0a1
Bug 1340010 - Make ABORT_GC a deterministic GC reason r=sfink
js/src/jit-test/tests/gc/bug-1340010.js
js/src/jsgc.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug-1340010.js
@@ -0,0 +1,22 @@
+if (helperThreadCount() === 0)
+    quit();
+
+gc();
+function weighted(wa) {
+    var a = [];
+    for (var i = 0; i < 30; ++i) {
+        for (var j = 0; j < 20; ++j) {
+            a.push(0);
+        }
+    }
+    return a;
+}
+var statementMakers = weighted();
+if (typeof oomTest == "function") {
+    statementMakers = statementMakers.concat([function (d, b) {
+        return "oomTest(" + makeFunction(d - 1, b) + ")";
+    }, ]);
+}
+deterministicgc(true);
+startgc(9469, "shrinking");
+offThreadCompileScript("");
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -6321,26 +6321,31 @@ GCRuntime::gcCycle(bool nonincrementalBy
 
     return IncrementalResult::Ok;
 }
 
 #ifdef JS_GC_ZEAL
 static bool
 IsDeterministicGCReason(JS::gcreason::Reason reason)
 {
-    if (reason > JS::gcreason::DEBUG_GC &&
-        reason != JS::gcreason::CC_FORCED && reason != JS::gcreason::SHUTDOWN_CC)
-    {
+    switch (reason) {
+      case JS::gcreason::API:
+      case JS::gcreason::DESTROY_RUNTIME:
+      case JS::gcreason::LAST_DITCH:
+      case JS::gcreason::TOO_MUCH_MALLOC:
+      case JS::gcreason::ALLOC_TRIGGER:
+      case JS::gcreason::DEBUG_GC:
+      case JS::gcreason::CC_FORCED:
+      case JS::gcreason::SHUTDOWN_CC:
+      case JS::gcreason::ABORT_GC:
+        return true;
+
+      default:
         return false;
     }
-
-    if (reason == JS::gcreason::EAGER_ALLOC_TRIGGER)
-        return false;
-
-    return true;
 }
 #endif
 
 gcstats::ZoneGCStats
 GCRuntime::scanZonesBeforeGC()
 {
     gcstats::ZoneGCStats zoneStats;
     for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {