Bug 1467483 - Assert that PresArena is only used on the main thread. r=mattwoodrow
authorMats Palmgren <mats@mozilla.com>
Thu, 07 Jun 2018 22:39:11 +0200
changeset 805579 7b4cd53cbfb8dbc6207d34e549516b84ffe3601c
parent 805578 9a56f487daae272c8f49d3df8af2576cb729efe6
child 805580 17b140524c6ee9e1263175212dec5231bfe3059f
push id112702
push userbmo:mh+mozilla@glandium.org
push dateFri, 08 Jun 2018 01:32:47 +0000
reviewersmattwoodrow
bugs1467483
milestone62.0a1
Bug 1467483 - Assert that PresArena is only used on the main thread. r=mattwoodrow
layout/base/nsPresArena.cpp
--- a/layout/base/nsPresArena.cpp
+++ b/layout/base/nsPresArena.cpp
@@ -81,16 +81,17 @@ nsPresArena::ClearArenaRefPtrs(ArenaObje
       iter.Remove();
     }
   }
 }
 
 void*
 nsPresArena::Allocate(uint32_t aCode, size_t aSize)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aSize > 0, "PresArena cannot allocate zero bytes");
   MOZ_ASSERT(aCode < ArrayLength(mFreeLists));
 
   // We only hand out aligned sizes
   aSize = mPool.AlignedSize(aSize);
 
   FreeList* list = &mFreeLists[aCode];
 
@@ -145,16 +146,17 @@ nsPresArena::Allocate(uint32_t aCode, si
   // Allocate a new chunk from the arena
   list->mEntriesEverAllocated++;
   return mPool.Allocate(aSize);
 }
 
 void
 nsPresArena::Free(uint32_t aCode, void* aPtr)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aCode < ArrayLength(mFreeLists));
 
   // Try to recycle this entry.
   FreeList* list = &mFreeLists[aCode];
   MOZ_ASSERT(list->mEntrySize > 0, "object of this type was never allocated");
 
   mozWritePoison(aPtr, list->mEntrySize);