Bug 898617 - Assert that the error reporter callback does not set an exception; r=billm
authorTerrence Cole <terrence@mozilla.com>
Thu, 25 Jul 2013 14:32:54 -0700
changeset 140244 95cdd796f48126be2f0b275c1e526cd4b973422a
parent 140243 41730f142283fdb7b96c49da4a643d2ce99b8b42
child 140245 2ee2dc1d2bcc0d8210fcf1dfe61e66284cec4026
push id1951
push userryanvm@gmail.com
push dateSun, 28 Jul 2013 01:55:51 +0000
treeherderfx-team@73b69c146ca6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs898617
milestone25.0a1
Bug 898617 - Assert that the error reporter callback does not set an exception; r=billm
js/src/jscntxt.cpp
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -398,16 +398,28 @@ js_ReportOutOfMemory(ThreadSafeContext *
     report.errorNumber = JSMSG_OUT_OF_MEMORY;
     PopulateReportBlame(cx, &report);
 
     /* Report the error. */
     if (JSErrorReporter onError = cx->errorReporter) {
         AutoSuppressGC suppressGC(cx);
         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
+     * does not need wrapping. If no JS code is running, no exception should be
+     * set at all.
+     */
+    JS_ASSERT(!cx->isExceptionPending());
 }
 
 JS_FRIEND_API(void)
 js_ReportOverRecursed(JSContext *maybecx)
 {
 #ifdef JS_MORE_DETERMINISTIC
     /*
      * We cannot make stack depth deterministic across different