From cd5d974e643ecb0907f150e060e909cc5fc52cbc Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Fri, 10 Feb 2012 18:32:25 -0800 Subject: [PATCH] Bug 721579 - Remove rt->gcTriggerBytes and rt->gcLastBytes (r=igor) --- js/src/jsapi.cpp | 2 -- js/src/jscntxt.h | 5 ----- js/src/jsgc.cpp | 39 +++------------------------------------ 3 files changed, 3 insertions(+), 43 deletions(-) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 0ea7bf884609..4a019656b41e 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -720,8 +720,6 @@ JSRuntime::JSRuntime() gcUserAvailableChunkListHead(NULL), gcKeepAtoms(0), gcBytes(0), - gcTriggerBytes(0), - gcLastBytes(0), gcMaxBytes(0), gcMaxMallocBytes(0), gcNumArenasFreeCommitted(0), diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index a518a93998cd..886387d506dc 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -284,8 +284,6 @@ struct JSRuntime : js::RuntimeFriendFields js::GCLocks gcLocksHash; jsrefcount gcKeepAtoms; size_t gcBytes; - size_t gcTriggerBytes; - size_t gcLastBytes; size_t gcMaxBytes; size_t gcMaxMallocBytes; @@ -540,9 +538,6 @@ struct JSRuntime : js::RuntimeFriendFields JSRuntime *thisFromCtor() { return this; } - void setGCLastBytes(size_t lastBytes, JSGCInvocationKind gckind); - void reduceGCTriggerBytes(size_t amount); - /* * Call the system malloc while checking for GC memory pressure and * reporting OOM error when cx is not null. We will not GC from here. diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index e6acb0f6450c..7ba2f74547f7 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -784,10 +784,8 @@ Chunk::releaseArena(ArenaHeader *aheader) JS_ASSERT(rt->gcBytes >= ArenaSize); JS_ASSERT(comp->gcBytes >= ArenaSize); #ifdef JS_THREADSAFE - if (rt->gcHelperThread.sweeping()) { - rt->reduceGCTriggerBytes(GC_HEAP_GROWTH_FACTOR * ArenaSize); + if (rt->gcHelperThread.sweeping()) comp->reduceGCTriggerBytes(GC_HEAP_GROWTH_FACTOR * ArenaSize); - } #endif rt->gcBytes -= ArenaSize; comp->gcBytes -= ArenaSize; @@ -893,12 +891,6 @@ js_InitGC(JSRuntime *rt, uint32_t maxbytes) rt->gcMaxBytes = maxbytes; rt->setGCMaxMallocBytes(maxbytes); - /* - * The assigned value prevents GC from running when GC memory is too low - * (during JS engine start). - */ - rt->setGCLastBytes(8192, GC_NORMAL); - rt->gcJitReleaseTime = PRMJ_Now() + JIT_SCRIPT_RELEASE_TYPES_INTERVAL; return true; } @@ -1355,25 +1347,6 @@ js_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data) return ct; } -void -JSRuntime::setGCLastBytes(size_t lastBytes, JSGCInvocationKind gckind) -{ - gcLastBytes = lastBytes; - - size_t base = gckind == GC_SHRINK ? lastBytes : Max(lastBytes, GC_ALLOCATION_THRESHOLD); - float trigger = float(base) * GC_HEAP_GROWTH_FACTOR; - gcTriggerBytes = size_t(Min(float(gcMaxBytes), trigger)); -} - -void -JSRuntime::reduceGCTriggerBytes(size_t amount) { - JS_ASSERT(amount > 0); - JS_ASSERT(gcTriggerBytes - amount >= 0); - if (gcTriggerBytes - amount < GC_ALLOCATION_THRESHOLD * GC_HEAP_GROWTH_FACTOR) - return; - gcTriggerBytes -= amount; -} - void JSCompartment::setGCLastBytes(size_t lastBytes, JSGCInvocationKind gckind) { @@ -1385,7 +1358,8 @@ JSCompartment::setGCLastBytes(size_t lastBytes, JSGCInvocationKind gckind) } void -JSCompartment::reduceGCTriggerBytes(size_t amount) { +JSCompartment::reduceGCTriggerBytes(size_t amount) +{ JS_ASSERT(amount > 0); JS_ASSERT(gcTriggerBytes - amount >= 0); if (gcTriggerBytes - amount < GC_ALLOCATION_THRESHOLD * GC_HEAP_GROWTH_FACTOR) @@ -2153,12 +2127,6 @@ TriggerCompartmentGC(JSCompartment *comp, gcreason::Reason reason) return; } - if (rt->gcBytes > 8192 && rt->gcBytes >= 3 * (rt->gcTriggerBytes / 2)) { - /* If we're using significantly more than our quota, do a full GC. */ - TriggerGC(rt, reason); - return; - } - /* * Trigger the GC when it is safe to call an operation callback on any * thread. @@ -2946,7 +2914,6 @@ GCCycle(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind) #endif rt->gcMarkAndSweep = false; - rt->setGCLastBytes(rt->gcBytes, gckind); rt->gcCurrentCompartment = NULL; for (CompartmentsIter c(rt); !c.done(); c.next())