Bug 806644 - Back out 782072 (r=terrence)
authorBill McCloskey <wmccloskey@mozilla.com>
Mon, 29 Oct 2012 17:34:59 -0700
changeset 111721 cb997ba8433bf03e4350a294ef7d52f756268d9a
parent 111720 9057eef5920abebc005e088749b57240285266da
child 111722 963873ff3081ca3001cb884903bae0894ef84c2d
push id17221
push userwmccloskey@mozilla.com
push dateTue, 30 Oct 2012 00:40:38 +0000
treeherdermozilla-inbound@cb997ba8433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs806644, 782072
milestone19.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 806644 - Back out 782072 (r=terrence)
js/src/jscntxt.cpp
js/src/jscompartment.cpp
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -1405,25 +1405,24 @@ JSRuntime::setGCMaxMallocBytes(size_t va
     gcMaxMallocBytes = (ptrdiff_t(value) >= 0) ? value : size_t(-1) >> 1;
     for (CompartmentsIter c(this); !c.done(); c.next())
         c->setGCMaxMallocBytes(value);
 }
 
 void
 JSRuntime::updateMallocCounter(JSContext *cx, size_t nbytes)
 {
-    if (cx && cx->compartment) {
+    /* We tolerate any thread races when updating gcMallocBytes. */
+    ptrdiff_t oldCount = gcMallocBytes;
+    ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
+    gcMallocBytes = newCount;
+    if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
+        onTooMuchMalloc();
+    else if (cx && cx->compartment)
         cx->compartment->updateMallocCounter(nbytes);
-    } else {
-        ptrdiff_t oldCount = gcMallocBytes;
-        ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
-        gcMallocBytes = newCount;
-        if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
-            onTooMuchMalloc();
-    }
 }
 
 JS_FRIEND_API(void)
 JSRuntime::onTooMuchMalloc()
 {
     TriggerGC(this, gcreason::TOO_MUCH_MALLOC);
 }
 
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -71,17 +71,17 @@ JSCompartment::JSCompartment(JSRuntime *
     debugModeBits(rt->debugMode ? DebugFromC : 0),
     watchpointMap(NULL),
     scriptCountsMap(NULL),
     debugScriptMap(NULL)
 #ifdef JS_ION
     , ionCompartment_(NULL)
 #endif
 {
-    setGCMaxMallocBytes(rt->gcMaxMallocBytes);
+    setGCMaxMallocBytes(rt->gcMaxMallocBytes * 0.9);
 }
 
 JSCompartment::~JSCompartment()
 {
 #ifdef JS_ION
     js_delete(ionCompartment_);
 #endif