mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 844313 - Call GC more likely when there are lots of Events to collect, r=mccr8
--HG-- extra : rebase_source : 675ad0e5b5e22b3ccc1ec2bddac7048df57f522a
This commit is contained in:
parent
24c7035d29
commit
ceab0ac5ce
@ -22,6 +22,7 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScriptError.h"
|
||||
@ -76,6 +77,7 @@ nsDOMEvent::nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent)
|
||||
}
|
||||
|
||||
InitPresContextData(aPresContext);
|
||||
nsJSContext::LikelyShortLivingObjectCreated();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -138,6 +138,7 @@ nsDOMTouch::Equals(nsIDOMTouch* aTouch)
|
||||
nsDOMTouchList::nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches)
|
||||
{
|
||||
mPoints.AppendElements(aTouches);
|
||||
nsJSContext::LikelyShortLivingObjectCreated();
|
||||
}
|
||||
|
||||
DOMCI_DATA(TouchList, nsDOMTouchList)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
|
||||
class nsDOMTouch MOZ_FINAL : public nsIDOMTouch
|
||||
{
|
||||
@ -41,6 +42,7 @@ public:
|
||||
|
||||
mChanged = false;
|
||||
mMessage = 0;
|
||||
nsJSContext::LikelyShortLivingObjectCreated();
|
||||
}
|
||||
nsDOMTouch(int32_t aIdentifier,
|
||||
nsIntPoint aPoint,
|
||||
@ -60,6 +62,7 @@ public:
|
||||
|
||||
mChanged = false;
|
||||
mMessage = 0;
|
||||
nsJSContext::LikelyShortLivingObjectCreated();
|
||||
}
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouch)
|
||||
@ -104,7 +107,10 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouchList)
|
||||
NS_DECL_NSIDOMTOUCHLIST
|
||||
|
||||
nsDOMTouchList() { }
|
||||
nsDOMTouchList()
|
||||
{
|
||||
nsJSContext::LikelyShortLivingObjectCreated();
|
||||
}
|
||||
nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches);
|
||||
|
||||
void Append(nsIDOMTouch* aPoint)
|
||||
|
@ -164,6 +164,7 @@ static uint32_t sPendingLoadCount;
|
||||
static bool sLoadingInProgress;
|
||||
|
||||
static uint32_t sCCollectedWaitingForGC;
|
||||
static uint32_t sLikelyShortLivingObjectsNeedingGC;
|
||||
static bool sPostGCEventsToConsole;
|
||||
static bool sPostGCEventsToObserver;
|
||||
static bool sDisableExplicitCompartmentGC;
|
||||
@ -2771,7 +2772,8 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
|
||||
|
||||
// If we collected a substantial amount of cycles, poke the GC since more objects
|
||||
// might be unreachable now.
|
||||
if (sCCollectedWaitingForGC > 250) {
|
||||
if (sCCollectedWaitingForGC > 250 ||
|
||||
sLikelyShortLivingObjectsNeedingGC > 2500) {
|
||||
PokeGC(JS::gcreason::CC_WAITING);
|
||||
}
|
||||
|
||||
@ -2810,14 +2812,15 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
|
||||
}
|
||||
|
||||
NS_NAMED_MULTILINE_LITERAL_STRING(kFmt,
|
||||
NS_LL("CC(T+%.1f) duration: %lums, suspected: %lu, visited: %lu RCed and %lu%s GCed, collected: %lu RCed and %lu GCed (%lu waiting for GC)%s\n")
|
||||
NS_LL("CC(T+%.1f) duration: %lums, suspected: %lu, visited: %lu RCed and %lu%s GCed, collected: %lu RCed and %lu GCed (%lu|%lu waiting for GC)%s\n")
|
||||
NS_LL("ForgetSkippable %lu times before CC, min: %lu ms, max: %lu ms, avg: %lu ms, total: %lu ms, sync: %lu ms, removed: %lu"));
|
||||
nsString msg;
|
||||
msg.Adopt(nsTextFormatter::smprintf(kFmt.get(), double(delta) / PR_USEC_PER_SEC,
|
||||
ccNowDuration, suspected,
|
||||
ccResults.mVisitedRefCounted, ccResults.mVisitedGCed, mergeMsg.get(),
|
||||
ccResults.mFreedRefCounted, ccResults.mFreedGCed,
|
||||
sCCollectedWaitingForGC, gcMsg.get(),
|
||||
sCCollectedWaitingForGC, sLikelyShortLivingObjectsNeedingGC,
|
||||
gcMsg.get(),
|
||||
sForgetSkippableBeforeCC,
|
||||
minForgetSkippableTime / PR_USEC_PER_MSEC,
|
||||
sMaxForgetSkippableTime / PR_USEC_PER_MSEC,
|
||||
@ -2846,6 +2849,7 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
|
||||
NS_LL("\"RCed\": %lu, ")
|
||||
NS_LL("\"GCed\": %lu }, ")
|
||||
NS_LL("\"waiting_for_gc\": %lu, ")
|
||||
NS_LL("\"short_living_objects_waiting_for_gc\": %lu, ")
|
||||
NS_LL("\"forced_gc\": %d, ")
|
||||
NS_LL("\"forget_skippable\": { ")
|
||||
NS_LL("\"times_before_cc\": %lu, ")
|
||||
@ -2862,6 +2866,7 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
|
||||
ccResults.mVisitedRefCounted, ccResults.mVisitedGCed,
|
||||
ccResults.mFreedRefCounted, ccResults.mFreedGCed,
|
||||
sCCollectedWaitingForGC,
|
||||
sLikelyShortLivingObjectsNeedingGC,
|
||||
ccResults.mForcedGC,
|
||||
sForgetSkippableBeforeCC,
|
||||
minForgetSkippableTime / PR_USEC_PER_MSEC,
|
||||
@ -3234,6 +3239,7 @@ DOMGCSliceCallback(JSRuntime *aRt, JS::GCProgress aProgress, const JS::GCDescrip
|
||||
nsJSContext::KillInterSliceGCTimer();
|
||||
|
||||
sCCollectedWaitingForGC = 0;
|
||||
sLikelyShortLivingObjectsNeedingGC = 0;
|
||||
sCleanupsSinceLastGC = 0;
|
||||
sNeedsFullCC = true;
|
||||
sHasRunGC = true;
|
||||
@ -3325,6 +3331,12 @@ nsJSContext::ReportPendingException()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsJSContext::LikelyShortLivingObjectCreated()
|
||||
{
|
||||
++sLikelyShortLivingObjectsNeedingGC;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* nsJSRuntime implementation
|
||||
*********************************************************************/
|
||||
@ -3360,6 +3372,7 @@ nsJSRuntime::Startup()
|
||||
sPendingLoadCount = 0;
|
||||
sLoadingInProgress = false;
|
||||
sCCollectedWaitingForGC = 0;
|
||||
sLikelyShortLivingObjectsNeedingGC = 0;
|
||||
sPostGCEventsToConsole = false;
|
||||
sDisableExplicitCompartmentGC = false;
|
||||
sNeedsFullCC = false;
|
||||
|
@ -148,6 +148,9 @@ public:
|
||||
static void KillFullGCTimer();
|
||||
static void KillInterSliceGCTimer();
|
||||
|
||||
// Calling LikelyShortLivingObjectCreated() makes a GC more likely.
|
||||
static void LikelyShortLivingObjectCreated();
|
||||
|
||||
virtual void GC(JS::gcreason::Reason aReason);
|
||||
|
||||
static uint32_t CleanupsSinceLastGC();
|
||||
|
Loading…
Reference in New Issue
Block a user