Bug 1382431 - Only record malloc trigger stats if a GC was triggered r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 24 Jul 2017 10:42:48 +0100
changeset 421683 2b4d38213053a91f845b5b9ccd890fb8ab3be1b0
parent 421682 90f689c00a293d4a2fac7c5e8bf3a91b56b4e0b6
child 421684 451efff6cf90982653a0d469256b1b86281eed94
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1382431
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 1382431 - Only record malloc trigger stats if a GC was triggered r=sfink
js/src/gc/GCRuntime.h
js/src/jit-test/tests/gc/bug-1382431.js
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -799,19 +799,26 @@ class GCRuntime
 
     static bool initializeSweepActions();
 
     void setGrayRootsTracer(JSTraceDataOp traceOp, void* data);
     MOZ_MUST_USE bool addBlackRootsTracer(JSTraceDataOp traceOp, void* data);
     void removeBlackRootsTracer(JSTraceDataOp traceOp, void* data);
 
     bool triggerGCForTooMuchMalloc() {
+        if (!triggerGC(JS::gcreason::TOO_MUCH_MALLOC))
+            return false;
+
+        // Even though this method may be called off the main thread it is safe
+        // to access mallocCounter here since triggerGC() will return false in
+        // that case.
         stats().recordTrigger(mallocCounter.bytes(), mallocCounter.maxBytes());
-        return triggerGC(JS::gcreason::TOO_MUCH_MALLOC);
+        return true;
     }
+
     int32_t getMallocBytes() const { return mallocCounter.bytes(); }
     size_t maxMallocBytesAllocated() const { return mallocCounter.maxBytes(); }
     bool isTooMuchMalloc() const { return mallocCounter.isTooMuchMalloc(); }
     void resetMallocBytes() { mallocCounter.reset(); }
     void setMaxMallocBytes(size_t value);
     void updateMallocCounter(JS::Zone* zone, size_t nbytes);
 
     void setGCCallback(JSGCCallback callback, void* data);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug-1382431.js
@@ -0,0 +1,6 @@
+if (helperThreadCount() === 0)
+   quit();
+
+var fe = "vv";
+for (i = 0; i < 24; i++) fe += fe;
+offThreadCompileScript(fe, {});