mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
backout c18523b51058 (bug 716014) on suspicion of causing Win Debug reftest timeouts.
This commit is contained in:
parent
08f58f2cf5
commit
ec184320f2
@ -817,7 +817,7 @@ nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener *aListener,
|
||||
}
|
||||
#endif
|
||||
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::DOM_UTILS, nsGCNormal, true);
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::DOM_UTILS);
|
||||
nsJSContext::CycleCollectNow(aListener, aExtraForgetSkippableCalls);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -135,8 +135,6 @@ static PRLogModuleInfo* gJSDiagnostics;
|
||||
// doing the first GC.
|
||||
#define NS_FIRST_GC_DELAY 10000 // ms
|
||||
|
||||
#define NS_FULL_GC_DELAY 60000 // ms
|
||||
|
||||
// The amount of time we wait between a request to CC (after GC ran)
|
||||
// and doing the actual CC.
|
||||
#define NS_CC_DELAY 5000 // ms
|
||||
@ -150,7 +148,6 @@ static PRLogModuleInfo* gJSDiagnostics;
|
||||
// if you add statics here, add them to the list in nsJSRuntime::Startup
|
||||
|
||||
static nsITimer *sGCTimer;
|
||||
static nsITimer *sFullGCTimer;
|
||||
static nsITimer *sShrinkGCBuffersTimer;
|
||||
static nsITimer *sCCTimer;
|
||||
|
||||
@ -169,7 +166,6 @@ static bool sLoadingInProgress;
|
||||
|
||||
static PRUint32 sCCollectedWaitingForGC;
|
||||
static bool sPostGCEventsToConsole;
|
||||
static bool sDisableExplicitCompartmentGC;
|
||||
static PRUint32 sCCTimerFireCount = 0;
|
||||
static PRUint32 sMinForgetSkippableTime = PR_UINT32_MAX;
|
||||
static PRUint32 sMaxForgetSkippableTime = 0;
|
||||
@ -177,15 +173,9 @@ static PRUint32 sTotalForgetSkippableTime = 0;
|
||||
static PRUint32 sRemovedPurples = 0;
|
||||
static PRUint32 sForgetSkippableBeforeCC = 0;
|
||||
static PRUint32 sPreviousSuspectedCount = 0;
|
||||
static PRUint32 sCompartmentGCCount = 0;
|
||||
static nsJSContext* sTopEvaluator = nsnull;
|
||||
static bool sContextDeleted = false;
|
||||
static bool sPreviousWasChromeCompGC = false;
|
||||
|
||||
static bool sCleanupSinceLastGC = true;
|
||||
|
||||
PRUint32 nsJSContext::sGlobalGCEpoch = 0;
|
||||
|
||||
nsScriptNameSpaceManager *gNameSpaceManager;
|
||||
|
||||
static nsIJSRuntimeService *sRuntimeService;
|
||||
@ -226,8 +216,7 @@ nsMemoryPressureObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
if (sGCOnMemoryPressure) {
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::MEM_PRESSURE, nsGCShrinking,
|
||||
true);
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::MEM_PRESSURE, nsGCShrinking);
|
||||
nsJSContext::CycleCollectNow();
|
||||
}
|
||||
return NS_OK;
|
||||
@ -949,8 +938,6 @@ static const char js_pccounts_content_str[] = JS_OPTIONS_DOT_STR "pccounts.con
|
||||
static const char js_pccounts_chrome_str[] = JS_OPTIONS_DOT_STR "pccounts.chrome";
|
||||
static const char js_jit_hardening_str[] = JS_OPTIONS_DOT_STR "jit_hardening";
|
||||
static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log";
|
||||
static const char js_disable_explicit_compartment_gc[] =
|
||||
JS_OPTIONS_DOT_STR "disable_explicit_compartment_gc";
|
||||
|
||||
int
|
||||
nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
@ -960,8 +947,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
PRUint32 newDefaultJSOptions = oldDefaultJSOptions;
|
||||
|
||||
sPostGCEventsToConsole = Preferences::GetBool(js_memlog_option_str);
|
||||
sDisableExplicitCompartmentGC =
|
||||
Preferences::GetBool(js_disable_explicit_compartment_gc);
|
||||
|
||||
bool strict = Preferences::GetBool(js_strict_option_str);
|
||||
if (strict)
|
||||
@ -1063,9 +1048,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
|
||||
|
||||
nsJSContext::nsJSContext(JSRuntime *aRuntime)
|
||||
: mGCOnDestruction(true),
|
||||
mChromeComp(false),
|
||||
mGlobalGCEpoch(0),
|
||||
mEvaluationCount(0),
|
||||
mExecuteDepth(0)
|
||||
{
|
||||
|
||||
@ -1116,9 +1098,6 @@ nsJSContext::~nsJSContext()
|
||||
DestroyJSContext();
|
||||
|
||||
--sContextCount;
|
||||
if (sTopEvaluator == this) {
|
||||
sTopEvaluator = nsnull;
|
||||
}
|
||||
|
||||
if (!sContextCount && sDidShutdown) {
|
||||
// The last context is being deleted, and we're already in the
|
||||
@ -1145,7 +1124,6 @@ nsJSContext::DestroyJSContext()
|
||||
js_options_dot_str, this);
|
||||
|
||||
if (mGCOnDestruction) {
|
||||
sContextDeleted = true;
|
||||
PokeGC(js::gcreason::NSJSCONTEXT_DESTROY);
|
||||
}
|
||||
|
||||
@ -2259,7 +2237,6 @@ nsJSContext::CreateNativeGlobalForInner(
|
||||
{
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
PRUint32 flags = aIsChrome? nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT : 0;
|
||||
mChromeComp = aIsChrome;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> systemPrincipal;
|
||||
if (aIsChrome) {
|
||||
@ -3182,12 +3159,6 @@ nsJSContext::ScriptEvaluated(bool aTerminated)
|
||||
if (aTerminated && mExecuteDepth == 0 && !JS_IsRunning(mContext)) {
|
||||
mOperationCallbackTime = 0;
|
||||
mModalStateTime = 0;
|
||||
|
||||
IncreaseEvaluationCount(this);
|
||||
if (EvaluationCount(sTopEvaluator) < EvaluationCount(this) &&
|
||||
(!mChromeComp || !sPreviousWasChromeCompGC)) {
|
||||
sTopEvaluator = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3260,20 +3231,9 @@ nsJSContext::ScriptExecuted()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FullGCTimerFired(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
NS_RELEASE(sFullGCTimer);
|
||||
|
||||
uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
|
||||
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason),
|
||||
nsGCNormal, true);
|
||||
}
|
||||
|
||||
//static
|
||||
void
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::Reason aReason, PRUint32 aGckind,
|
||||
bool aGlobal)
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::Reason reason, PRUint32 gckind)
|
||||
{
|
||||
NS_TIME_FUNCTION_MIN(1.0);
|
||||
SAMPLE_LABEL("GC", "GarbageCollectNow");
|
||||
@ -3290,44 +3250,9 @@ nsJSContext::GarbageCollectNow(js::gcreason::Reason aReason, PRUint32 aGckind,
|
||||
sPendingLoadCount = 0;
|
||||
sLoadingInProgress = false;
|
||||
|
||||
if (!nsContentUtils::XPConnect()) {
|
||||
return;
|
||||
if (nsContentUtils::XPConnect()) {
|
||||
nsContentUtils::XPConnect()->GarbageCollect(reason, gckind);
|
||||
}
|
||||
|
||||
// Use compartment GC when we're not asked to do a shrinking GC nor
|
||||
// global GC and compartment GC has been called less than 10 times after
|
||||
// the previous global GC. If a top level browsing context has been
|
||||
// deleted, we do a global GC.
|
||||
if (!sDisableExplicitCompartmentGC &&
|
||||
aGckind != nsGCShrinking && !aGlobal &&
|
||||
EvaluationCount(sTopEvaluator) > 0 &&
|
||||
!sContextDeleted && sCompartmentGCCount < 10) {
|
||||
nsJSContext* top = sTopEvaluator;
|
||||
sTopEvaluator = nsnull;
|
||||
ResetEvaluationCount(top);
|
||||
JSContext* cx = top->GetNativeContext();
|
||||
if (cx) {
|
||||
JSObject* global = top->GetNativeGlobal();
|
||||
if (global) {
|
||||
if (!sFullGCTimer) {
|
||||
CallCreateInstance("@mozilla.org/timer;1", &sFullGCTimer);
|
||||
}
|
||||
if (sFullGCTimer) {
|
||||
sFullGCTimer->Cancel();
|
||||
js::gcreason::Reason reason = js::gcreason::FULL_GC_TIMER;
|
||||
sFullGCTimer->InitWithFuncCallback(FullGCTimerFired,
|
||||
reinterpret_cast<void *>(reason),
|
||||
NS_FULL_GC_DELAY,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
JSCompartment* comp = js::GetObjectCompartment(global);
|
||||
js::CompartmentGCForReason(cx, comp, aReason);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsContentUtils::XPConnect()->GarbageCollect(aReason, aGckind);
|
||||
}
|
||||
|
||||
//static
|
||||
@ -3431,8 +3356,7 @@ GCTimerFired(nsITimer *aTimer, void *aClosure)
|
||||
NS_RELEASE(sGCTimer);
|
||||
|
||||
uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
|
||||
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason),
|
||||
nsGCNormal, false);
|
||||
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason), nsGCNormal);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3600,16 +3524,6 @@ nsJSContext::KillGCTimer()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsJSContext::KillFullGCTimer()
|
||||
{
|
||||
if (sFullGCTimer) {
|
||||
sFullGCTimer->Cancel();
|
||||
|
||||
NS_RELEASE(sFullGCTimer);
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void
|
||||
nsJSContext::KillShrinkGCBuffersTimer()
|
||||
@ -3638,8 +3552,8 @@ nsJSContext::GC(js::gcreason::Reason aReason)
|
||||
PokeGC(aReason);
|
||||
}
|
||||
|
||||
void
|
||||
nsJSContext::DOMGCFinishedCallback(JSRuntime *rt, JSCompartment *comp, const char *status)
|
||||
static void
|
||||
DOMGCFinishedCallback(JSRuntime *rt, JSCompartment *comp, const char *status)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "GCs must run on the main thread");
|
||||
|
||||
@ -3665,19 +3579,6 @@ nsJSContext::DOMGCFinishedCallback(JSRuntime *rt, JSCompartment *comp, const cha
|
||||
sCCollectedWaitingForGC = 0;
|
||||
sCleanupSinceLastGC = false;
|
||||
|
||||
if (!comp) {
|
||||
sPreviousWasChromeCompGC = false;
|
||||
sContextDeleted = false;
|
||||
sCompartmentGCCount = 0;
|
||||
++sGlobalGCEpoch;
|
||||
KillFullGCTimer();
|
||||
} else {
|
||||
// Only every other compartment GC is allowed to collect a chrome
|
||||
// compartment. Otherwise we'd collect chrome compartment all the time.
|
||||
sPreviousWasChromeCompGC = xpc::AccessCheck::isChrome(comp);
|
||||
++sCompartmentGCCount;
|
||||
}
|
||||
|
||||
if (sGCTimer) {
|
||||
// If we were waiting for a GC to happen, kill the timer.
|
||||
nsJSContext::KillGCTimer();
|
||||
@ -3798,14 +3699,13 @@ void
|
||||
nsJSRuntime::Startup()
|
||||
{
|
||||
// initialize all our statics, so that we can restart XPCOM
|
||||
sGCTimer = sFullGCTimer = sCCTimer = nsnull;
|
||||
sGCTimer = sCCTimer = nsnull;
|
||||
sGCHasRun = false;
|
||||
sLastCCEndTime = 0;
|
||||
sPendingLoadCount = 0;
|
||||
sLoadingInProgress = false;
|
||||
sCCollectedWaitingForGC = 0;
|
||||
sPostGCEventsToConsole = false;
|
||||
sDisableExplicitCompartmentGC = false;
|
||||
gNameSpaceManager = nsnull;
|
||||
sRuntimeService = nsnull;
|
||||
sRuntime = nsnull;
|
||||
@ -3962,7 +3862,7 @@ nsJSRuntime::Init()
|
||||
// Let's make sure that our main thread is the same as the xpcom main thread.
|
||||
NS_ASSERTION(NS_IsMainThread(), "bad");
|
||||
|
||||
::JS_SetGCFinishedCallback(sRuntime, nsJSContext::DOMGCFinishedCallback);
|
||||
::JS_SetGCFinishedCallback(sRuntime, DOMGCFinishedCallback);
|
||||
|
||||
JSSecurityCallbacks *callbacks = JS_GetRuntimeSecurityCallbacks(sRuntime);
|
||||
NS_ASSERTION(callbacks, "SecMan should have set security callbacks!");
|
||||
@ -4047,7 +3947,6 @@ void
|
||||
nsJSRuntime::Shutdown()
|
||||
{
|
||||
nsJSContext::KillGCTimer();
|
||||
nsJSContext::KillFullGCTimer();
|
||||
nsJSContext::KillShrinkGCBuffersTimer();
|
||||
nsJSContext::KillCCTimer();
|
||||
|
||||
|
@ -181,9 +181,7 @@ public:
|
||||
static void LoadStart();
|
||||
static void LoadEnd();
|
||||
|
||||
static void GarbageCollectNow(js::gcreason::Reason aReason,
|
||||
PRUint32 aGckind,
|
||||
bool aGlobal);
|
||||
static void GarbageCollectNow(js::gcreason::Reason reason, PRUint32 gckind = nsGCNormal);
|
||||
static void ShrinkGCBuffersNow();
|
||||
// If aExtraForgetSkippableCalls is -1, forgetSkippable won't be
|
||||
// called even if the previous collection was GC.
|
||||
@ -192,7 +190,6 @@ public:
|
||||
|
||||
static void PokeGC(js::gcreason::Reason aReason);
|
||||
static void KillGCTimer();
|
||||
static void KillFullGCTimer();
|
||||
|
||||
static void PokeShrinkGCBuffers();
|
||||
static void KillShrinkGCBuffersTimer();
|
||||
@ -211,29 +208,6 @@ public:
|
||||
JSObject* global = JS_GetGlobalObject(mContext);
|
||||
return global ? mGlobalObjectRef.get() : nsnull;
|
||||
}
|
||||
|
||||
static PRUint32 EvaluationCount(nsJSContext* aCx)
|
||||
{
|
||||
return aCx && aCx->mGlobalGCEpoch == sGlobalGCEpoch ?
|
||||
aCx->mEvaluationCount : 0;
|
||||
}
|
||||
|
||||
static void IncreaseEvaluationCount(nsJSContext* aCx)
|
||||
{
|
||||
if (aCx->mGlobalGCEpoch != sGlobalGCEpoch) {
|
||||
aCx->mEvaluationCount = 0;
|
||||
aCx->mGlobalGCEpoch = sGlobalGCEpoch;
|
||||
}
|
||||
++(aCx->mEvaluationCount);
|
||||
}
|
||||
|
||||
static void ResetEvaluationCount(nsJSContext* aCx)
|
||||
{
|
||||
aCx->mEvaluationCount = 0;
|
||||
}
|
||||
|
||||
static void DOMGCFinishedCallback(JSRuntime* aRt, JSCompartment* aComp,
|
||||
const char* aStatus);
|
||||
protected:
|
||||
nsresult InitializeExternalClasses();
|
||||
|
||||
@ -322,9 +296,7 @@ private:
|
||||
bool mScriptsEnabled;
|
||||
bool mGCOnDestruction;
|
||||
bool mProcessingScriptTag;
|
||||
bool mChromeComp;
|
||||
PRUint32 mGlobalGCEpoch;
|
||||
PRUint32 mEvaluationCount;
|
||||
|
||||
PRUint32 mExecuteDepth;
|
||||
PRUint32 mDefaultJSOptions;
|
||||
PRTime mOperationCallbackTime;
|
||||
@ -336,8 +308,6 @@ private:
|
||||
// context does. It is eventually collected by the cycle collector.
|
||||
nsCOMPtr<nsIScriptGlobalObject> mGlobalObjectRef;
|
||||
|
||||
static PRUint32 sGlobalGCEpoch;
|
||||
|
||||
static int JSOptionChangedCallback(const char *pref, void *data);
|
||||
|
||||
static JSBool DOMOperationCallback(JSContext *cx);
|
||||
|
@ -800,14 +800,14 @@ ContentChild::GetIndexedDBPath()
|
||||
bool
|
||||
ContentChild::RecvGarbageCollect()
|
||||
{
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC, nsGCNormal, true);
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvCycleCollect()
|
||||
{
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC, nsGCNormal, true);
|
||||
nsJSContext::GarbageCollectNow(js::gcreason::DOM_IPC);
|
||||
nsJSContext::CycleCollectNow();
|
||||
return true;
|
||||
}
|
||||
|
@ -674,8 +674,7 @@ SizeOfJSContext();
|
||||
D(DOM_IPC) \
|
||||
D(DOM_WORKER) \
|
||||
D(INTER_SLICE_GC) \
|
||||
D(REFRESH_FRAME) \
|
||||
D(FULL_GC_TIMER)
|
||||
D(REFRESH_FRAME)
|
||||
|
||||
namespace gcreason {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user