Bug 1118107 - Convert ThreadSafeContext -> ExclusiveContext and remove PJS paths in error reporting functions. (r=lth)
authorShu-yu Guo <shu@rfrn.org>
Fri, 09 Jan 2015 00:06:03 -0800
changeset 222878 db4f4627bbc19bbf8063af46577c2221a8163c90
parent 222877 dfa1f0425c654d6058be1ef238c9d4a6e605f6ba
child 222879 83490bc3998164157feddc06f63196fb3359e764
push id28074
push usercbook@mozilla.com
push dateFri, 09 Jan 2015 13:00:21 +0000
treeherdermozilla-central@ed280f6c7b39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1118107
milestone37.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 1118107 - Convert ThreadSafeContext -> ExclusiveContext and remove PJS paths in error reporting functions. (r=lth)
js/src/jsalloc.cpp
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jsgcinlines.h
js/src/vm/Runtime.h
--- a/js/src/jsalloc.cpp
+++ b/js/src/jsalloc.cpp
@@ -8,16 +8,16 @@
 
 #include "jscntxt.h"
 
 using namespace js;
 
 void *
 TempAllocPolicy::onOutOfMemory(void *p, size_t nbytes)
 {
-    return static_cast<ThreadSafeContext *>(cx_)->onOutOfMemory(p, nbytes);
+    return static_cast<ExclusiveContext *>(cx_)->onOutOfMemory(p, nbytes);
 }
 
 void
 TempAllocPolicy::reportAllocOverflow() const
 {
-    js_ReportAllocationOverflow(static_cast<ThreadSafeContext *>(cx_));
+    js_ReportAllocationOverflow(static_cast<ExclusiveContext *>(cx_));
 }
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -340,32 +340,27 @@ PopulateReportBlame(JSContext *cx, JSErr
  * allocates an error object, report and callstack. If code is running, simply
  * throw the static atom "out of memory". If code is not running, call the
  * error reporter directly.
  *
  * Furthermore, callers of js_ReportOutOfMemory (viz., malloc) assume a GC does
  * not occur, so GC must be avoided or suppressed.
  */
 void
-js_ReportOutOfMemory(ThreadSafeContext *cxArg)
+js_ReportOutOfMemory(ExclusiveContext *cxArg)
 {
 #ifdef JS_MORE_DETERMINISTIC
     /*
      * OOMs are non-deterministic, especially across different execution modes
      * (e.g. interpreter vs JIT). In more-deterministic builds, print to stderr
      * so that the fuzzers can detect this.
      */
     fprintf(stderr, "js_ReportOutOfMemory called\n");
 #endif
 
-    if (cxArg->isForkJoinContext()) {
-        cxArg->asForkJoinContext()->setPendingAbortFatal(ParallelBailoutOutOfMemory);
-        return;
-    }
-
     if (!cxArg->isJSContext())
         return;
 
     JSContext *cx = cxArg->asJSContext();
     cx->runtime()->hadOutOfMemory = true;
 
     /* Report the oom. */
     if (JS::OutOfMemoryCallback oomCallback = cx->runtime()->oomCallback) {
@@ -423,35 +418,30 @@ js_ReportOverRecursed(JSContext *maybecx
 #endif
     if (maybecx) {
         JS_ReportErrorNumber(maybecx, js_GetErrorMessage, nullptr, JSMSG_OVER_RECURSED);
         maybecx->overRecursed_ = true;
     }
 }
 
 void
-js_ReportOverRecursed(ThreadSafeContext *cx)
+js_ReportOverRecursed(ExclusiveContext *cx)
 {
     if (cx->isJSContext())
         js_ReportOverRecursed(cx->asJSContext());
-    else if (cx->isExclusiveContext())
-        cx->asExclusiveContext()->addPendingOverRecursed();
+    else
+        cx->addPendingOverRecursed();
 }
 
 void
-js_ReportAllocationOverflow(ThreadSafeContext *cxArg)
+js_ReportAllocationOverflow(ExclusiveContext *cxArg)
 {
     if (!cxArg)
         return;
 
-    if (cxArg->isForkJoinContext()) {
-        cxArg->asForkJoinContext()->setPendingAbortFatal(ParallelBailoutOutOfMemory);
-        return;
-    }
-
     if (!cxArg->isJSContext())
         return;
     JSContext *cx = cxArg->asJSContext();
 
     AutoSuppressGC suppressGC(cx);
     JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ALLOC_OVERFLOW);
 }
 
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -16,25 +16,16 @@
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4100) /* Silence unreferenced formal parameter warnings */
 #endif
 
 struct DtoaState;
 
-extern void
-js_ReportOutOfMemory(js::ThreadSafeContext *cx);
-
-extern void
-js_ReportAllocationOverflow(js::ThreadSafeContext *cx);
-
-extern void
-js_ReportOverRecursed(js::ThreadSafeContext *cx);
-
 namespace js {
 
 namespace jit {
 class JitContext;
 class CompileCompartment;
 class DebugModeOSRVolatileJitFrameIterator;
 }
 
@@ -268,17 +259,17 @@ struct ThreadSafeContext : ContextFriend
     void recoverFromOutOfMemory();
 
     inline void updateMallocCounter(size_t nbytes) {
         // Note: this is racy.
         runtime_->updateMallocCounter(zone_, nbytes);
     }
 
     void reportAllocationOverflow() {
-        js_ReportAllocationOverflow(this);
+        js_ReportAllocationOverflow(asExclusiveContext());
     }
 
     // Accessors for immutable runtime data.
     JSAtomState &names() { return *runtime_->commonNames; }
     StaticStrings &staticStrings() { return *runtime_->staticStrings; }
     AtomSet &permanentAtoms() { return *runtime_->permanentAtoms; }
     WellKnownSymbols &wellKnownSymbols() { return *runtime_->wellKnownSymbols; }
     const JS::AsmJSCacheOps &asmJSCacheOps() { return runtime_->asmJSCacheOps; }
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -468,17 +468,17 @@ CheckAllocatorState(ThreadSafeContext *c
 #endif
 
     // Crash if we perform a GC action when it is not safe.
     if (allowGC && !rt->mainThread.suppressGC)
         JS::AutoAssertOnGC::VerifyIsSafeToGC(rt);
 
     // For testing out of memory conditions
     if (!PossiblyFail()) {
-        js_ReportOutOfMemory(cx);
+        js_ReportOutOfMemory(cx->asJSContext());
         return false;
     }
 
     if (allowGC) {
 #ifdef JS_GC_ZEAL
         if (rt->gc.needZealousGC())
             rt->gc.runDebugGC();
 #endif
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -46,37 +46,37 @@
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4100) /* Silence unreferenced formal parameter warnings */
 #endif
 
 namespace js {
 
 class PerThreadData;
-struct ThreadSafeContext;
+class ExclusiveContext;
 class AutoKeepAtoms;
 #ifdef JS_TRACE_LOGGING
 class TraceLoggerThread;
 #endif
 
 /* Thread Local Storage slot for storing the runtime for a thread. */
 extern mozilla::ThreadLocal<PerThreadData*> TlsPerThreadData;
 
 } // namespace js
 
 struct DtoaState;
 
 extern void
-js_ReportOutOfMemory(js::ThreadSafeContext *cx);
+js_ReportOutOfMemory(js::ExclusiveContext *cx);
 
 extern void
-js_ReportAllocationOverflow(js::ThreadSafeContext *cx);
+js_ReportAllocationOverflow(js::ExclusiveContext *maybecx);
 
 extern void
-js_ReportOverRecursed(js::ThreadSafeContext *cx);
+js_ReportOverRecursed(js::ExclusiveContext *cx);
 
 namespace js {
 
 class Activation;
 class ActivationIterator;
 class AsmJSActivation;
 class AsmJSModule;
 class MathCache;