Bug 1401099 - Move arena_dalloc_large to a method of arena_t. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 20:40:36 +0900
changeset 667419 836553a9d0c4b97b37ec32f5d17a6603b20855c0
parent 667418 cf797a006c8114db087e1d2dc8535acc8f46bec7
child 667420 2a0f6ab0526c867c10f55a2b8b1bbcb844632628
push id80694
push userbmo:mh+mozilla@glandium.org
push dateWed, 20 Sep 2017 02:07:21 +0000
reviewersnjn
bugs1401099
milestone57.0a1
Bug 1401099 - Move arena_dalloc_large to a method of arena_t. r?njn
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -777,19 +777,19 @@ public:
 
 private:
   void InitChunk(arena_chunk_t* aChunk, bool aZeroed);
 
   void DeallocChunk(arena_chunk_t* aChunk);
 
   arena_run_t* AllocRun(arena_bin_t* aBin, size_t aSize, bool aLarge, bool aZero);
 
+  void DallocRun(arena_run_t* aRun, bool aDirty);
+
 public:
-  void DallocRun(arena_run_t* aRun, bool aDirty);
-
   void SplitRun(arena_run_t* aRun, size_t aSize, bool aLarge, bool aZero);
 
 private:
   void TrimRunHead(arena_chunk_t* aChunk, arena_run_t* aRun, size_t aOldSize, size_t aNewSize);
 
 public:
   void TrimRunTail(arena_chunk_t* aChunk, arena_run_t* aRun, size_t aOldSize, size_t aNewSize, bool dirty);
 
@@ -806,16 +806,18 @@ private:
 
 public:
   inline void* Malloc(size_t aSize, bool aZero);
 
   void* Palloc(size_t aAlignment, size_t aSize, size_t aAllocSize);
 
   inline void DallocSmall(arena_chunk_t* aChunk, void* aPtr, arena_chunk_map_t *aMapElm);
 
+  void DallocLarge(arena_chunk_t* aChunk, void* aPtr);
+
   void Purge(bool aAll);
 
   void HardPurge();
 };
 
 /******************************************************************************/
 /*
  * Data.
@@ -3800,27 +3802,26 @@ arena_t::DallocSmall(arena_chunk_t* aChu
 
       MOZ_DIAGNOSTIC_ASSERT(arena_run_tree_search(&bin->runs, run_mapelm) == nullptr);
       arena_run_tree_insert(&bin->runs, run_mapelm);
     }
   }
   mStats.allocated_small -= size;
 }
 
-static void
-arena_dalloc_large(arena_t *arena, arena_chunk_t *chunk, void *ptr)
+void
+arena_t::DallocLarge(arena_chunk_t* aChunk, void* aPtr)
 {
-	size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >>
-	    pagesize_2pow;
-	size_t size = chunk->map[pageind].bits & ~pagesize_mask;
-
-	memset(ptr, kAllocPoison, size);
-	arena->mStats.allocated_large -= size;
-
-	arena->DallocRun((arena_run_t*)ptr, true);
+  size_t pageind = (uintptr_t(aPtr) - uintptr_t(aChunk)) >> pagesize_2pow;
+  size_t size = aChunk->map[pageind].bits & ~pagesize_mask;
+
+  memset(aPtr, kAllocPoison, size);
+  mStats.allocated_large -= size;
+
+  DallocRun((arena_run_t*)aPtr, true);
 }
 
 static inline void
 arena_dalloc(void *ptr, size_t offset)
 {
 	arena_chunk_t *chunk;
 	arena_t *arena;
 	size_t pageind;
@@ -3839,17 +3840,17 @@ arena_dalloc(void *ptr, size_t offset)
 	pageind = offset >> pagesize_2pow;
 	mapelm = &chunk->map[pageind];
 	MOZ_DIAGNOSTIC_ASSERT((mapelm->bits & CHUNK_MAP_ALLOCATED) != 0);
 	if ((mapelm->bits & CHUNK_MAP_LARGE) == 0) {
 		/* Small allocation. */
 		arena->DallocSmall(chunk, ptr, mapelm);
 	} else {
 		/* Large allocation. */
-		arena_dalloc_large(arena, chunk, ptr);
+		arena->DallocLarge(chunk, ptr);
 	}
 	malloc_spin_unlock(&arena->mLock);
 }
 
 static inline void
 idalloc(void *ptr)
 {
 	size_t offset;