author | Bill McCloskey <wmccloskey@mozilla.com> |
Mon, 29 Oct 2012 17:34:59 -0700 | |
changeset 111721 | cb997ba8433bf03e4350a294ef7d52f756268d9a |
parent 111720 | 9057eef5920abebc005e088749b57240285266da |
child 111722 | 963873ff3081ca3001cb884903bae0894ef84c2d |
push id | 17221 |
push user | wmccloskey@mozilla.com |
push date | Tue, 30 Oct 2012 00:40:38 +0000 |
treeherder | mozilla-inbound@cb997ba8433b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | terrence |
bugs | 806644, 782072 |
milestone | 19.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
|
js/src/jscntxt.cpp | file | annotate | diff | comparison | revisions | |
js/src/jscompartment.cpp | file | annotate | diff | comparison | revisions |
--- 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