From 2f97ce9b6a8cf970c123b0b281cdaecc89974b17 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Tue, 31 Jul 2012 18:33:29 -0700 Subject: [PATCH] Bug 778993 - Separate runtime's gcMallocBytes from compartment's gcMallocBytes Bug 778993 - Separate runtime's gcMallocBytes from compartment's gcMallocBytes (r=gwagner) --- js/src/jscntxt.cpp | 15 ++++++++------- js/src/jscompartment.cpp | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index aa8ab62cb25..616b38f583f 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -1161,14 +1161,15 @@ JSRuntime::setGCMaxMallocBytes(size_t value) void JSRuntime::updateMallocCounter(JSContext *cx, size_t nbytes) { - /* 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) + 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) diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index ffd5dbc46c6..8878173587e 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -70,7 +70,7 @@ JSCompartment::JSCompartment(JSRuntime *rt) sourceMapMap(NULL), debugScriptMap(NULL) { - setGCMaxMallocBytes(rt->gcMaxMallocBytes * 0.9); + setGCMaxMallocBytes(rt->gcMaxMallocBytes); } JSCompartment::~JSCompartment()