Bug 1401099 - Move arena_bin_malloc_hard to a method of arena_t. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 18:20:11 +0900
changeset 382276 05baed504ac57514ff3d835c1604bcde0b59fd9f
parent 382275 44b578a65ada7813eacc67e0812f8f3b53506367
child 382277 ded028a534520fa050edc76a8e7c02f35bf8c043
push id51825
push usermh@glandium.org
push dateThu, 21 Sep 2017 20:59:59 +0000
treeherderautoland@526fae334c8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1401099
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1401099 - Move arena_bin_malloc_hard to a method of arena_t. r=njn
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -788,16 +788,18 @@ public:
   void SplitRun(arena_run_t* aRun, size_t aSize, bool aLarge, bool aZero);
 
   void TrimRunHead(arena_chunk_t* aChunk, arena_run_t* aRun, size_t aOldSize, size_t aNewSize);
 
   void TrimRunTail(arena_chunk_t* aChunk, arena_run_t* aRun, size_t aOldSize, size_t aNewSize, bool dirty);
 
   inline void* MallocBinEasy(arena_bin_t* aBin, arena_run_t* aRun);
 
+  void* MallocBinHard(arena_bin_t* aBin);
+
   void Purge(bool aAll);
 
   void HardPurge();
 };
 
 /******************************************************************************/
 /*
  * Data.
@@ -3116,28 +3118,28 @@ arena_t::MallocBinEasy(arena_bin_t* aBin
 
   ret = arena_run_reg_alloc(aRun, aBin);
   MOZ_DIAGNOSTIC_ASSERT(ret);
   aRun->nfree--;
 
   return ret;
 }
 
-/* Re-fill bin->runcur, then call arena_t::MallocBinEasy(). */
-static void *
-arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin)
+/* Re-fill aBin->runcur, then call arena_t::MallocBinEasy(). */
+void*
+arena_t::MallocBinHard(arena_bin_t* aBin)
 {
-
-	bin->runcur = arena_bin_nonfull_run_get(arena, bin);
-	if (!bin->runcur)
-		return nullptr;
-	MOZ_DIAGNOSTIC_ASSERT(bin->runcur->magic == ARENA_RUN_MAGIC);
-	MOZ_DIAGNOSTIC_ASSERT(bin->runcur->nfree > 0);
-
-	return arena->MallocBinEasy(bin, bin->runcur);
+  aBin->runcur = arena_bin_nonfull_run_get(this, aBin);
+  if (!aBin->runcur) {
+    return nullptr;
+  }
+  MOZ_DIAGNOSTIC_ASSERT(aBin->runcur->magic == ARENA_RUN_MAGIC);
+  MOZ_DIAGNOSTIC_ASSERT(aBin->runcur->nfree > 0);
+
+  return MallocBinEasy(aBin, aBin->runcur);
 }
 
 /*
  * Calculate bin->run_size such that it meets the following constraints:
  *
  *   *) bin->run_size >= min_run_size
  *   *) bin->run_size <= arena_maxclass
  *   *) bin->run_size <= RUN_MAX_SMALL
@@ -3248,17 +3250,17 @@ arena_malloc_small(arena_t *arena, size_
 		    + (ffs((int)(size >> opt_small_max_2pow)) - 2)];
 	}
 	MOZ_DIAGNOSTIC_ASSERT(size == bin->reg_size);
 
 	malloc_spin_lock(&arena->mLock);
 	if ((run = bin->runcur) && run->nfree > 0)
 		ret = arena->MallocBinEasy(bin, run);
 	else
-		ret = arena_bin_malloc_hard(arena, bin);
+		ret = arena->MallocBinHard(bin);
 
 	if (!ret) {
 		malloc_spin_unlock(&arena->mLock);
 		return nullptr;
 	}
 
 	arena->mStats.allocated_small += size;
 	malloc_spin_unlock(&arena->mLock);