зеркало из https://github.com/mozilla/pjs.git
Backout Bug 624549, a=backout
This commit is contained in:
Родитель
d9f6764ff9
Коммит
2a88ce5e61
|
@ -655,9 +655,6 @@ nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener *aListener)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (nsContentUtils::XPConnect()) {
|
||||
nsContentUtils::XPConnect()->GarbageCollect();
|
||||
}
|
||||
nsJSContext::CC(aListener);
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -169,16 +169,14 @@ static PRLogModuleInfo* gJSDiagnostics;
|
|||
#define NS_MIN_CC_INTERVAL 10000 // ms
|
||||
// If previous cycle collection collected more than this number of objects,
|
||||
// the next collection will happen somewhat soon.
|
||||
// Also, if there are more than this number suspected objects, GC will be called
|
||||
// right before CC, if it wasn't called after last CC.
|
||||
#define NS_COLLECTED_OBJECTS_LIMIT 5000
|
||||
// CC will be called if GC has been called at least this number of times and
|
||||
// there are at least NS_MIN_SUSPECT_CHANGES new suspected objects.
|
||||
#define NS_MAX_GC_COUNT 5
|
||||
#define NS_MIN_SUSPECT_CHANGES 100
|
||||
#define NS_MIN_SUSPECT_CHANGES 10
|
||||
// CC will be called if there are at least NS_MAX_SUSPECT_CHANGES new suspected
|
||||
// objects.
|
||||
#define NS_MAX_SUSPECT_CHANGES 1000
|
||||
#define NS_MAX_SUSPECT_CHANGES 100
|
||||
|
||||
// if you add statics here, add them to the list in nsJSRuntime::Startup
|
||||
|
||||
|
@ -273,7 +271,7 @@ nsUserActivityObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
if (sUserIsActive) {
|
||||
sUserIsActive = PR_FALSE;
|
||||
if (!sGCTimer) {
|
||||
nsJSContext::MaybeCC(PR_FALSE);
|
||||
nsJSContext::IntervalCC();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -3612,21 +3610,6 @@ nsJSContext::ScriptExecuted()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static inline uint32
|
||||
GetGCRunsSinceLastCC()
|
||||
{
|
||||
// To avoid crash if nsJSRuntime is not properly initialized.
|
||||
// See the bug 474586
|
||||
if (!nsJSRuntime::sRuntime)
|
||||
return 0;
|
||||
|
||||
// Since JS_GetGCParameter() and sSavedGCCount are unsigned, the following
|
||||
// gives the correct result even when the GC counter wraps around
|
||||
// UINT32_MAX since the last call to JS_GetGCParameter().
|
||||
return JS_GetGCParameter(nsJSRuntime::sRuntime, JSGC_NUMBER) -
|
||||
sSavedGCCount;
|
||||
}
|
||||
|
||||
//static
|
||||
void
|
||||
nsJSContext::CC(nsICycleCollectorListener *aListener)
|
||||
|
@ -3643,9 +3626,7 @@ nsJSContext::CC(nsICycleCollectorListener *aListener)
|
|||
sCCSuspectChanges = 0;
|
||||
// nsCycleCollector_collect() no longer forces a JS garbage collection,
|
||||
// so we have to do it ourselves here.
|
||||
if (nsContentUtils::XPConnect() &&
|
||||
!GetGCRunsSinceLastCC() &&
|
||||
sCCSuspectedCount > NS_COLLECTED_OBJECTS_LIMIT) {
|
||||
if (nsContentUtils::XPConnect()) {
|
||||
nsContentUtils::XPConnect()->GarbageCollect();
|
||||
}
|
||||
sCollectedObjectsCounts = nsCycleCollector_collect(aListener);
|
||||
|
@ -3660,6 +3641,21 @@ nsJSContext::CC(nsICycleCollectorListener *aListener)
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline uint32
|
||||
GetGCRunsSinceLastCC()
|
||||
{
|
||||
// To avoid crash if nsJSRuntime is not properly initialized.
|
||||
// See the bug 474586
|
||||
if (!nsJSRuntime::sRuntime)
|
||||
return 0;
|
||||
|
||||
// Since JS_GetGCParameter() and sSavedGCCount are unsigned, the following
|
||||
// gives the correct result even when the GC counter wraps around
|
||||
// UINT32_MAX since the last call to JS_GetGCParameter().
|
||||
return JS_GetGCParameter(nsJSRuntime::sRuntime, JSGC_NUMBER) -
|
||||
sSavedGCCount;
|
||||
}
|
||||
|
||||
//static
|
||||
PRBool
|
||||
nsJSContext::MaybeCC(PRBool aHigherProbability)
|
||||
|
|
Загрузка…
Ссылка в новой задаче