зеркало из https://github.com/mozilla/gecko-dev.git
Bug 699279 - Run GC_SHRINK collection cycle when under memory pressure; r=mrbkap
GC_SHRINK is a fairly new type of GC that does more aggressive cleanups than a normal GC. This patch makes the browser run the GC in this mode when under memory pressure, or when the user pushes the Minimize Memory Usage button when on the about:memory page. --HG-- extra : rebase_source : abdd11ee5fa5eb0e3d58122d3d72e98328d47668
This commit is contained in:
Родитель
65233c5237
Коммит
b08432d55e
|
@ -194,7 +194,7 @@ nsMemoryPressureObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
const PRUnichar* aData)
|
||||
{
|
||||
if (sGCOnMemoryPressure) {
|
||||
nsJSContext::GarbageCollectNow();
|
||||
nsJSContext::GarbageCollectNow(true);
|
||||
nsJSContext::CycleCollectNow();
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -3187,7 +3187,7 @@ nsJSContext::ScriptExecuted()
|
|||
|
||||
//static
|
||||
void
|
||||
nsJSContext::GarbageCollectNow()
|
||||
nsJSContext::GarbageCollectNow(bool shrinkingGC)
|
||||
{
|
||||
NS_TIME_FUNCTION_MIN(1.0);
|
||||
|
||||
|
@ -3203,7 +3203,7 @@ nsJSContext::GarbageCollectNow()
|
|||
sLoadingInProgress = false;
|
||||
|
||||
if (nsContentUtils::XPConnect()) {
|
||||
nsContentUtils::XPConnect()->GarbageCollect();
|
||||
nsContentUtils::XPConnect()->GarbageCollect(shrinkingGC);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
static void LoadStart();
|
||||
static void LoadEnd();
|
||||
|
||||
static void GarbageCollectNow();
|
||||
static void GarbageCollectNow(bool shrinkingGC = false);
|
||||
static void CycleCollectNow(nsICycleCollectorListener *aListener = nsnull);
|
||||
|
||||
static void PokeGC();
|
||||
|
|
|
@ -132,6 +132,12 @@ JS_ObjectCountDynamicSlots(JSObject *obj)
|
|||
return obj->numDynamicSlots(obj->numSlots());
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ShrinkingGC(JSContext *cx)
|
||||
{
|
||||
js_GC(cx, NULL, GC_SHRINK, gcstats::PUBLIC_API);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSPrincipals *)
|
||||
JS_GetCompartmentPrincipals(JSCompartment *compartment)
|
||||
|
|
|
@ -70,6 +70,9 @@ JS_NewObjectWithUniqueType(JSContext *cx, JSClass *clasp, JSObject *proto, JSObj
|
|||
extern JS_FRIEND_API(uint32)
|
||||
JS_ObjectCountDynamicSlots(JSObject *obj);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
JS_ShrinkingGC(JSContext *cx);
|
||||
|
||||
extern JS_FRIEND_API(size_t)
|
||||
JS_GetE4XObjectsCreated(JSContext *cx);
|
||||
|
||||
|
|
|
@ -392,7 +392,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports
|
|||
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
%}
|
||||
|
||||
[uuid(29b63029-0868-4344-b0ca-d93256ee7c78)]
|
||||
[uuid(07661008-5505-4784-a612-89f7dc2144da)]
|
||||
interface nsIXPConnect : nsISupports
|
||||
{
|
||||
%{ C++
|
||||
|
@ -735,7 +735,7 @@ interface nsIXPConnect : nsISupports
|
|||
/**
|
||||
* Trigger a JS garbage collection.
|
||||
*/
|
||||
void GarbageCollect();
|
||||
void GarbageCollect(in boolean shrinkingGC);
|
||||
|
||||
/**
|
||||
* Define quick stubs on the given object, @a proto.
|
||||
|
|
|
@ -343,7 +343,7 @@ nsXPConnect::NeedCollect()
|
|||
}
|
||||
|
||||
void
|
||||
nsXPConnect::Collect()
|
||||
nsXPConnect::Collect(bool shrinkingGC)
|
||||
{
|
||||
// We're dividing JS objects into 2 categories:
|
||||
//
|
||||
|
@ -406,15 +406,18 @@ nsXPConnect::Collect()
|
|||
JS_ASSERT(!threadData.conservativeGC.requestThreshold);
|
||||
if (threadData.requestDepth == 1)
|
||||
threadData.conservativeGC.requestThreshold = 1;
|
||||
JS_GC(cx);
|
||||
if (shrinkingGC)
|
||||
JS_ShrinkingGC(cx);
|
||||
else
|
||||
JS_GC(cx);
|
||||
if (threadData.requestDepth == 1)
|
||||
threadData.conservativeGC.requestThreshold = 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPConnect::GarbageCollect()
|
||||
nsXPConnect::GarbageCollect(bool shrinkingGC)
|
||||
{
|
||||
Collect();
|
||||
Collect(shrinkingGC);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ public:
|
|||
virtual nsresult FinishCycleCollection();
|
||||
virtual nsCycleCollectionParticipant *ToParticipant(void *p);
|
||||
virtual bool NeedCollect();
|
||||
virtual void Collect();
|
||||
virtual void Collect(bool shrinkingGC=false);
|
||||
#ifdef DEBUG_CC
|
||||
virtual void PrintAllReferencesTo(void *p);
|
||||
#endif
|
||||
|
|
|
@ -92,7 +92,7 @@ struct nsCycleCollectionJSRuntime : public nsCycleCollectionLanguageRuntime
|
|||
/**
|
||||
* Runs the JavaScript GC.
|
||||
*/
|
||||
virtual void Collect() = 0;
|
||||
virtual void Collect(bool shrinkingGC = false) = 0;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
Загрузка…
Ссылка в новой задаче