#415: M1376936 M1375331

This commit is contained in:
Cameron Kaiser 2017-07-09 17:49:10 -07:00
parent ec23e34e98
commit 33344c6445
3 changed files with 28 additions and 3 deletions

View File

@ -92,7 +92,8 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsBaseContentList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsBaseContentList)
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(nsBaseContentList,
LastRelease())
NS_IMETHODIMP
@ -612,6 +613,17 @@ nsContentList::NodeWillBeDestroyed(const nsINode* aNode)
SetDirty();
}
void
nsContentList::LastRelease()
{
RemoveFromCaches();
if (mRootNode) {
mRootNode->RemoveMutationObserver(this);
mRootNode = nullptr;
}
SetDirty();
}
NS_IMETHODIMP
nsContentList::GetLength(uint32_t* aLength)
{

View File

@ -95,6 +95,9 @@ public:
{
mElements.SetCapacity(aCapacity);
}
virtual void LastRelease() {}
protected:
virtual ~nsBaseContentList();
@ -348,6 +351,8 @@ public:
Reset();
}
virtual void LastRelease() override;
protected:
/**
* Returns whether the element matches our criterion

View File

@ -131,9 +131,17 @@ nsPresArena::Allocate(uint32_t aCode, size_t aSize)
void* result;
if (len > 0) {
// LIFO behavior for best cache utilization
// Remove from the end of the mEntries array to avoid memmoving entries,
// and use SetLengthAndRetainStorage to avoid a lot of malloc/free
// from ShrinkCapacity on smaller sizes. 500 pointers means the malloc size
// for the array is 4096 bytes or more on a 64-bit system. The next smaller
// size is 2048 (with jemalloc), which we consider not worth compacting.
result = list->mEntries.ElementAt(len - 1);
list->mEntries.RemoveElementAt(len - 1);
if (list->mEntries.Capacity() > 500) {
list->mEntries.RemoveElementAt(len - 1);
} else {
list->mEntries.SetLengthAndRetainStorage(len - 1);
}
#if defined(DEBUG)
{
MOZ_MAKE_MEM_DEFINED(result, list->mEntrySize);