Backed out changeset ddfe7f3ad095 (bug 926678) for perma-orange linux crashtest failures
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 16 Oct 2013 13:56:22 +0200
changeset 165703 205345b505b25279c517610b15a5f51c675e5c4e
parent 165702 33991c16bdb367a1c24b3acb9963379ff9a3adc3
child 165704 b16182c733bb21bf986aab75afac9dd1af737667
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs926678
milestone27.0a1
backs outddfe7f3ad095d5195c81773def0b35bbec4f6796
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
Backed out changeset ddfe7f3ad095 (bug 926678) for perma-orange linux crashtest failures
js/src/gc/Zone.cpp
js/src/gc/Zone.h
js/src/jsgc.cpp
js/src/jsgc.h
js/src/vm/Runtime.cpp
--- a/js/src/gc/Zone.cpp
+++ b/js/src/gc/Zone.cpp
@@ -122,24 +122,17 @@ Zone::setGCMaxMallocBytes(size_t value)
      */
     gcMaxMallocBytes = (ptrdiff_t(value) >= 0) ? value : size_t(-1) >> 1;
     resetGCMallocBytes();
 }
 
 void
 Zone::onTooMuchMalloc()
 {
-    if (TriggerZoneGC(this, gcreason::TOO_MUCH_MALLOC)) {
-        /*
-         * Set gcMallocBytes to stop updateMallocCounter() calling this method
-         * again before the counter is reset by GC.
-         */
-        gcMallocBytes = PTRDIFF_MAX;
-    }
-
+    TriggerZoneGC(this, gcreason::TOO_MUCH_MALLOC);
 }
 
 void
 Zone::sweep(FreeOp *fop, bool releaseTypes)
 {
     /*
      * Periodically release observed types for all scripts. This is safe to
      * do when there are no frames for the zone on the stack.
--- a/js/src/gc/Zone.h
+++ b/js/src/gc/Zone.h
@@ -267,18 +267,20 @@ struct Zone : public JS::shadow::Zone,
 
     void resetGCMallocBytes();
     void setGCMaxMallocBytes(size_t value);
     void updateMallocCounter(size_t nbytes) {
         /*
          * Note: this code may be run from worker threads.  We
          * tolerate any thread races when updating gcMallocBytes.
          */
-        gcMallocBytes -= ptrdiff_t(nbytes);
-        if (JS_UNLIKELY(isTooMuchMalloc()))
+        ptrdiff_t oldCount = gcMallocBytes;
+        ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
+        gcMallocBytes = newCount;
+        if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
             onTooMuchMalloc();
     }
 
     bool isTooMuchMalloc() const {
         return gcMallocBytes <= 0;
      }
 
     void onTooMuchMalloc();
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1925,80 +1925,76 @@ TriggerOperationCallback(JSRuntime *rt, 
     if (rt->gcIsNeeded)
         return;
 
     rt->gcIsNeeded = true;
     rt->gcTriggerReason = reason;
     rt->triggerOperationCallback(JSRuntime::TriggerCallbackMainThread);
 }
 
-bool
+void
 js::TriggerGC(JSRuntime *rt, JS::gcreason::Reason reason)
 {
     /* Wait till end of parallel section to trigger GC. */
     if (InParallelSection()) {
         ForkJoinSlice::Current()->requestGC(reason);
-        return true;
+        return;
     }
 
     /* Don't trigger GCs when allocating under the operation callback lock. */
     if (rt->currentThreadOwnsOperationCallbackLock())
-        return false;
+        return;
 
     JS_ASSERT(CurrentThreadCanAccessRuntime(rt));
 
-    /* GC is already running. */
-    if (rt->isHeapCollecting())
-        return true;
+    if (rt->isHeapBusy())
+        return;
 
     JS::PrepareForFullGC(rt);
     TriggerOperationCallback(rt, reason);
-    return true;
-}
-
-bool
+}
+
+void
 js::TriggerZoneGC(Zone *zone, JS::gcreason::Reason reason)
 {
     /*
      * If parallel threads are running, wait till they
      * are stopped to trigger GC.
      */
     if (InParallelSection()) {
         ForkJoinSlice::Current()->requestZoneGC(zone, reason);
-        return true;
+        return;
     }
 
     /* Zones in use by a thread with an exclusive context can't be collected. */
     if (zone->usedByExclusiveThread)
-        return false;
+        return;
 
     JSRuntime *rt = zone->runtimeFromMainThread();
 
     /* Don't trigger GCs when allocating under the operation callback lock. */
     if (rt->currentThreadOwnsOperationCallbackLock())
-        return false;
-
-    /* GC is already running. */
-    if (rt->isHeapCollecting())
-        return true;
+        return;
+
+    if (rt->isHeapBusy())
+        return;
 
     if (rt->gcZeal() == ZealAllocValue) {
         TriggerGC(rt, reason);
-        return true;
+        return;
     }
 
     if (rt->isAtomsZone(zone)) {
         /* We can't do a zone GC of the atoms compartment. */
         TriggerGC(rt, reason);
-        return true;
+        return;
     }
 
     PrepareZoneForGC(zone);
     TriggerOperationCallback(rt, reason);
-    return true;
 }
 
 void
 js::MaybeGC(JSContext *cx)
 {
     JSRuntime *rt = cx->runtime();
     JS_ASSERT(CurrentThreadCanAccessRuntime(rt));
 
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -682,21 +682,21 @@ class StackFrame;
 
 extern void
 MarkCompartmentActive(js::StackFrame *fp);
 
 extern void
 TraceRuntime(JSTracer *trc);
 
 /* Must be called with GC lock taken. */
-extern bool
+extern void
 TriggerGC(JSRuntime *rt, JS::gcreason::Reason reason);
 
 /* Must be called with GC lock taken. */
-extern bool
+extern void
 TriggerZoneGC(Zone *zone, JS::gcreason::Reason reason);
 
 extern void
 MaybeGC(JSContext *cx);
 
 extern void
 ReleaseAllJITCode(FreeOp *op);
 
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -719,36 +719,30 @@ JSRuntime::updateMallocCounter(size_t nb
 {
     updateMallocCounter(nullptr, nbytes);
 }
 
 void
 JSRuntime::updateMallocCounter(JS::Zone *zone, size_t nbytes)
 {
     /* We tolerate any thread races when updating gcMallocBytes. */
-    gcMallocBytes -= ptrdiff_t(nbytes);
-    if (JS_UNLIKELY(gcMallocBytes <= 0))
+    ptrdiff_t oldCount = gcMallocBytes;
+    ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
+    gcMallocBytes = newCount;
+    if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
         onTooMuchMalloc();
     else if (zone)
         zone->updateMallocCounter(nbytes);
 }
 
 JS_FRIEND_API(void)
 JSRuntime::onTooMuchMalloc()
 {
-    if (!CurrentThreadCanAccessRuntime(this))
-        return;
-
-    if (TriggerGC(this, JS::gcreason::TOO_MUCH_MALLOC)) {
-        /*
-         * Set gcMallocBytes to stop updateMallocCounter() calling this method
-         * again before the counter is reset by GC.
-         */
-        gcMallocBytes = PTRDIFF_MAX;
-    }
+    if (CurrentThreadCanAccessRuntime(this))
+        TriggerGC(this, JS::gcreason::TOO_MUCH_MALLOC);
 }
 
 JS_FRIEND_API(void *)
 JSRuntime::onOutOfMemory(void *p, size_t nbytes)
 {
     return onOutOfMemory(p, nbytes, nullptr);
 }