Bug 981198 - Internally move the JSErrorReporter to the JSRuntime. r=terrence
authorBobby Holley <bobbyholley@gmail.com>
Tue, 09 Sep 2014 16:02:10 -0700
changeset 204342 3d78fa27054f81bb21f7c212940ba0dc987551e7
parent 204341 cf5b1e58fbb9ddd8f7232b0fa67178e8662878e6
child 204343 0eaa239b3bfd05c88aca67b2421e0770cffeb4e6
push id48900
push userbobbyholley@gmail.com
push dateTue, 09 Sep 2014 23:06:32 +0000
treeherdermozilla-inbound@0eaa239b3bfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs981198
milestone35.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 981198 - Internally move the JSErrorReporter to the JSRuntime. r=terrence
js/src/jsapi.cpp
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -5764,26 +5764,26 @@ JS_PUBLIC_API(void)
 JS_ReportAllocationOverflow(JSContext *cx)
 {
     js_ReportAllocationOverflow(cx);
 }
 
 JS_PUBLIC_API(JSErrorReporter)
 JS_GetErrorReporter(JSContext *cx)
 {
-    return cx->errorReporter;
+    return cx->runtime()->errorReporter;
 }
 
 JS_PUBLIC_API(JSErrorReporter)
 JS_SetErrorReporter(JSContext *cx, JSErrorReporter er)
 {
     JSErrorReporter older;
 
-    older = cx->errorReporter;
-    cx->errorReporter = er;
+    older = cx->runtime()->errorReporter;
+    cx->runtime()->errorReporter = er;
     return older;
 }
 
 /************************************************************************/
 
 /*
  * Dates.
  */
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -382,17 +382,17 @@ js_ReportOutOfMemory(ThreadSafeContext *
     /* Fill out the report, but don't do anything that requires allocation. */
     JSErrorReport report;
     PodZero(&report);
     report.flags = JSREPORT_ERROR;
     report.errorNumber = JSMSG_OUT_OF_MEMORY;
     PopulateReportBlame(cx, &report);
 
     /* Report the error. */
-    if (JSErrorReporter onError = cx->errorReporter) {
+    if (JSErrorReporter onError = cx->runtime()->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
@@ -872,17 +872,17 @@ js_ReportErrorNumberUCArray(JSContext *c
 }
 
 void
 js::CallErrorReporter(JSContext *cx, const char *message, JSErrorReport *reportp)
 {
     JS_ASSERT(message);
     JS_ASSERT(reportp);
 
-    if (JSErrorReporter onError = cx->errorReporter)
+    if (JSErrorReporter onError = cx->runtime()->errorReporter)
         onError(cx, message, reportp);
 }
 
 void
 js_ReportIsNotDefined(JSContext *cx, const char *name)
 {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, name);
 }
@@ -1103,17 +1103,16 @@ JSContext::JSContext(JSRuntime *rt)
     unwrappedException_(UndefinedValue()),
     options_(),
     propagatingForcedReturn_(false),
     reportGranularity(JS_DEFAULT_JITREPORT_GRANULARITY),
     resolvingList(nullptr),
     generatingError(false),
     savedFrameChains_(),
     cycleDetectorSet(MOZ_THIS_IN_INITIALIZER_LIST()),
-    errorReporter(nullptr),
     data(nullptr),
     data2(nullptr),
     outstandingRequests(0),
     iterValue(MagicValue(JS_NO_ITER_VALUE)),
     jitIsBroken(false),
 #ifdef MOZ_TRACE_JSCALLS
     functionCallback(nullptr),
 #endif
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -455,19 +455,16 @@ struct JSContext : public js::ExclusiveC
   public:
     bool saveFrameChain();
     void restoreFrameChain();
 
   public:
     /* State for object and array toSource conversion. */
     js::ObjectSet       cycleDetectorSet;
 
-    /* Per-context optional error reporter. */
-    JSErrorReporter     errorReporter;
-
     /* Client opaque pointers. */
     void                *data;
     void                *data2;
 
   public:
 
     /*
      * Return:
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -185,16 +185,17 @@ JSRuntime::JSRuntime(JSRuntime *parentRu
     canUseSignalHandlers_(false),
     defaultFreeOp_(thisFromCtor()),
     debuggerMutations(0),
     securityCallbacks(const_cast<JSSecurityCallbacks *>(&NullSecurityCallbacks)),
     DOMcallbacks(nullptr),
     destroyPrincipals(nullptr),
     structuredCloneCallbacks(nullptr),
     telemetryCallback(nullptr),
+    errorReporter(nullptr),
     propertyRemovals(0),
 #if !EXPOSE_INTL_API
     thousandsSeparator(0),
     decimalSeparator(0),
     numGrouping(0),
 #endif
     mathCache_(nullptr),
     activeCompilations_(0),
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -1090,16 +1090,19 @@ struct JSRuntime : public JS::shadow::Ru
     JSDestroyPrincipalsOp destroyPrincipals;
 
     /* Structured data callbacks are runtime-wide. */
     const JSStructuredCloneCallbacks *structuredCloneCallbacks;
 
     /* Call this to accumulate telemetry data. */
     JSAccumulateTelemetryDataCallback telemetryCallback;
 
+    /* Optional error reporter. */
+    JSErrorReporter     errorReporter;
+
     /* AsmJSCache callbacks are runtime-wide. */
     JS::AsmJSCacheOps asmJSCacheOps;
 
     /*
      * The propertyRemovals counter is incremented for every JSObject::clear,
      * and for each JSObject::remove method call that frees a slot in the given
      * object. See js_NativeGet and js_NativeSet in jsobj.cpp.
      */