Bug 1023035 - Improve checking for whether we are on the main thread when triggering malloc GCs, r=billm.
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 11 Jun 2014 09:28:50 -0600
changeset 188220 000b317ce64f5352b55f56ced1907382f3bc6844
parent 188219 bb9ca4ddc79ebef154847f722e62f6dfaf4d741d
child 188221 749f66e5319a0def0093ff5fc0f36ed0c5c9ee4b
push id7253
push userkwierso@gmail.com
push dateThu, 12 Jun 2014 01:52:40 +0000
treeherderfx-team@354a7e95abb8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1023035
milestone33.0a1
Bug 1023035 - Improve checking for whether we are on the main thread when triggering malloc GCs, r=billm.
js/src/jsgc.cpp
js/src/vm/Runtime.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -2140,22 +2140,27 @@ bool
 GCRuntime::triggerGC(JS::gcreason::Reason reason)
 {
     /* Wait till end of parallel section to trigger GC. */
     if (InParallelSection()) {
         ForkJoinContext::current()->requestGC(reason);
         return true;
     }
 
+    /*
+     * Don't trigger GCs if this is being called off the main thread from
+     * onTooMuchMalloc().
+     */
+    if (!CurrentThreadCanAccessRuntime(rt))
+        return false;
+
     /* Don't trigger GCs when allocating under the interrupt callback lock. */
     if (rt->currentThreadOwnsInterruptLock())
         return false;
 
-    JS_ASSERT(CurrentThreadCanAccessRuntime(rt));
-
     /* GC is already running. */
     if (rt->isHeapCollecting())
         return false;
 
     JS::PrepareForFullGC(rt);
     requestInterrupt(reason);
     return true;
 }
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -705,18 +705,16 @@ void
 JSRuntime::updateMallocCounter(JS::Zone *zone, size_t nbytes)
 {
     gc.updateMallocCounter(zone, nbytes);
 }
 
 JS_FRIEND_API(void)
 JSRuntime::onTooMuchMalloc()
 {
-    if (!CurrentThreadCanAccessRuntime(this))
-        return;
     gc.onTooMuchMalloc();
 }
 
 JS_FRIEND_API(void *)
 JSRuntime::onOutOfMemory(void *p, size_t nbytes)
 {
     return onOutOfMemory(p, nbytes, nullptr);
 }