зеркало из https://github.com/mozilla/pjs.git
reuse etci pool, r+sr=sicking
--HG-- extra : rebase_source : 698eae6de79ab094c978cf06f938dd2240a31bc8
This commit is contained in:
Родитель
fe93cc2a50
Коммит
ad1b3f2aef
|
@ -81,6 +81,7 @@ public:
|
|||
nsEventTargetChainItem* parent = item->mParent;
|
||||
item->~nsEventTargetChainItem();
|
||||
aAllocator->Free(item, sizeof(nsEventTargetChainItem));
|
||||
--sCurrentEtciCount;
|
||||
item = parent;
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +166,13 @@ public:
|
|||
*/
|
||||
nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
|
||||
static PRUint32 MaxEtciCount() { return sMaxEtciCount; }
|
||||
|
||||
static void ResetMaxEtciCount()
|
||||
{
|
||||
NS_ASSERTION(!sCurrentEtciCount, "Wrong time to call ResetMaxEtciCount()!");
|
||||
sMaxEtciCount = 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMEventTarget> mTarget;
|
||||
nsEventTargetChainItem* mChild;
|
||||
|
@ -176,8 +184,14 @@ public:
|
|||
nsCOMPtr<nsPIDOMEventTarget> mNewTarget;
|
||||
// Cache mTarget's event listener manager.
|
||||
nsCOMPtr<nsIEventListenerManager> mManager;
|
||||
|
||||
static PRUint32 sMaxEtciCount;
|
||||
static PRUint32 sCurrentEtciCount;
|
||||
};
|
||||
|
||||
PRUint32 nsEventTargetChainItem::sMaxEtciCount = 0;
|
||||
PRUint32 nsEventTargetChainItem::sCurrentEtciCount = 0;
|
||||
|
||||
nsEventTargetChainItem::nsEventTargetChainItem(nsPIDOMEventTarget* aTarget,
|
||||
nsEventTargetChainItem* aChild)
|
||||
: mChild(aChild), mParent(nsnull), mFlags(0), mItemFlags(0)
|
||||
|
@ -186,6 +200,10 @@ nsEventTargetChainItem::nsEventTargetChainItem(nsPIDOMEventTarget* aTarget,
|
|||
if (mChild) {
|
||||
mChild->mParent = this;
|
||||
}
|
||||
|
||||
if (++sCurrentEtciCount > sMaxEtciCount) {
|
||||
sMaxEtciCount = sCurrentEtciCount;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -347,6 +365,8 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#define NS_CHAIN_POOL_SIZE 128
|
||||
|
||||
class ChainItemPool {
|
||||
public:
|
||||
ChainItemPool() {
|
||||
|
@ -356,7 +376,7 @@ public:
|
|||
static const size_t kBucketSizes[] = { sizeof(nsEventTargetChainItem) };
|
||||
static const PRInt32 kNumBuckets = sizeof(kBucketSizes) / sizeof(size_t);
|
||||
static const PRInt32 kInitialPoolSize =
|
||||
NS_SIZE_IN_HEAP(sizeof(nsEventTargetChainItem)) * 128;
|
||||
NS_SIZE_IN_HEAP(sizeof(nsEventTargetChainItem)) * NS_CHAIN_POOL_SIZE;
|
||||
nsresult rv = sEtciPool->Init("EventTargetChainItem Pool", kBucketSizes,
|
||||
kNumBuckets, kInitialPoolSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -374,9 +394,21 @@ public:
|
|||
if (sEtciPool) {
|
||||
--sEtciPoolUsers;
|
||||
}
|
||||
if (!sEtciPoolUsers) {
|
||||
if (nsEventTargetChainItem::MaxEtciCount() > NS_CHAIN_POOL_SIZE) {
|
||||
delete sEtciPool;
|
||||
sEtciPool = nsnull;
|
||||
nsEventTargetChainItem::ResetMaxEtciCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Shutdown()
|
||||
{
|
||||
if (!sEtciPoolUsers) {
|
||||
delete sEtciPool;
|
||||
sEtciPool = nsnull;
|
||||
nsEventTargetChainItem::ResetMaxEtciCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,6 +421,8 @@ public:
|
|||
nsFixedSizeAllocator* ChainItemPool::sEtciPool = nsnull;
|
||||
PRInt32 ChainItemPool::sEtciPoolUsers = 0;
|
||||
|
||||
void NS_ShutdownChainItemPool() { ChainItemPool::Shutdown(); }
|
||||
|
||||
/* static */ nsresult
|
||||
nsEventDispatcher::Dispatch(nsISupports* aTarget,
|
||||
nsPresContext* aPresContext,
|
||||
|
|
|
@ -126,6 +126,8 @@ PRBool NS_SVGEnabled();
|
|||
#include "nsCycleCollector.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
|
||||
extern void NS_ShutdownChainItemPool();
|
||||
|
||||
static nsrefcnt sLayoutStaticRefcnt;
|
||||
|
||||
nsresult
|
||||
|
@ -361,6 +363,8 @@ nsLayoutStatics::Shutdown()
|
|||
#endif
|
||||
|
||||
nsXMLHttpRequest::ShutdownACCache();
|
||||
|
||||
NS_ShutdownChainItemPool();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче