Bug 1249183 - Suppress GC harder, r=terrence, a=lizzard
authorSteve Fink <sfink@mozilla.com>
Wed, 17 Feb 2016 17:42:12 -0800
changeset 304216 a6621cd9929e1b7337f85a8b8a237918c15436ed
parent 304215 10be70b85cb105bd93340c95dd4dc8a8fbe8ea86
child 304217 91fc367595158ff5e400ad96320cdb7b530c7850
push id9134
push usercbook@mozilla.com
push dateThu, 25 Feb 2016 08:34:47 +0000
treeherdermozilla-aurora@a6621cd9929e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence, lizzard
bugs1249183
milestone46.0a2
Bug 1249183 - Suppress GC harder, r=terrence, a=lizzard
js/src/jscntxt.cpp
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -289,22 +289,21 @@ js::ReportOutOfMemory(ExclusiveContext* 
     fprintf(stderr, "ReportOutOfMemory called\n");
 #endif
 
     if (!cxArg->isJSContext())
         return cxArg->addPendingOutOfMemory();
 
     JSContext* cx = cxArg->asJSContext();
     cx->runtime()->hadOutOfMemory = true;
+    AutoSuppressGC suppressGC(cx);
 
     /* Report the oom. */
-    if (JS::OutOfMemoryCallback oomCallback = cx->runtime()->oomCallback) {
-        AutoSuppressGC suppressGC(cx);
+    if (JS::OutOfMemoryCallback oomCallback = cx->runtime()->oomCallback)
         oomCallback(cx, cx->runtime()->oomCallbackData);
-    }
 
     if (JS_IsRunning(cx)) {
         cx->setPendingException(StringValue(cx->names().outOfMemory));
         return;
     }
 
     /* Get the message for this error, but we don't expand any arguments. */
     const JSErrorFormatString* efs = GetErrorMessage(nullptr, JSMSG_OUT_OF_MEMORY);
@@ -312,20 +311,18 @@ js::ReportOutOfMemory(ExclusiveContext* 
 
     /* Fill out the report, but don't do anything that requires allocation. */
     JSErrorReport report;
     report.flags = JSREPORT_ERROR;
     report.errorNumber = JSMSG_OUT_OF_MEMORY;
     PopulateReportBlame(cx, &report);
 
     /* Report the error. */
-    if (JSErrorReporter onError = cx->runtime()->errorReporter) {
-        AutoSuppressGC suppressGC(cx);
+    if (JSErrorReporter onError = cx->runtime()->errorReporter)
         onError(cx, msg, &report);
-    }
 
     /*
      * We would like to enforce the invariant that any exception reported
      * during an OOM situation does not require wrapping. Besides avoiding
      * allocation when memory is low, this reduces the number of places where
      * we might need to GC.
      *
      * When JS code is running, we set the pending exception to an atom, which