Bug 1401099 - Move arena_bin_malloc_easy to a method of arena_t. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 18:18:11 +0900
changeset 382260 44b578a65ada7813eacc67e0812f8f3b53506367
parent 382259 c6985d5f90ca4b0f4f28902be59d5e91dd5fffc0
child 382261 05baed504ac57514ff3d835c1604bcde0b59fd9f
push id32551
push userkwierso@gmail.com
push dateThu, 21 Sep 2017 23:29:53 +0000
treeherdermozilla-central@d6d6fd889f7b [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_easy to a method of arena_t. r=njn
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -786,16 +786,18 @@ public:
   void DallocRun(arena_run_t* aRun, bool aDirty);
 
   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 Purge(bool aAll);
 
   void HardPurge();
 };
 
 /******************************************************************************/
 /*
  * Data.
@@ -3099,43 +3101,43 @@ arena_bin_nonfull_run_get(arena_t *arena
 	run->magic = ARENA_RUN_MAGIC;
 #endif
 
 	bin->stats.curruns++;
 	return (run);
 }
 
 /* bin->runcur must have space available before this function is called. */
-static inline void *
-arena_bin_malloc_easy(arena_t *arena, arena_bin_t *bin, arena_run_t *run)
+void*
+arena_t::MallocBinEasy(arena_bin_t* aBin, arena_run_t* aRun)
 {
-	void *ret;
-
-	MOZ_DIAGNOSTIC_ASSERT(run->magic == ARENA_RUN_MAGIC);
-	MOZ_DIAGNOSTIC_ASSERT(run->nfree > 0);
-
-	ret = arena_run_reg_alloc(run, bin);
-	MOZ_DIAGNOSTIC_ASSERT(ret);
-	run->nfree--;
-
-	return (ret);
+  void* ret;
+
+  MOZ_DIAGNOSTIC_ASSERT(aRun->magic == ARENA_RUN_MAGIC);
+  MOZ_DIAGNOSTIC_ASSERT(aRun->nfree > 0);
+
+  ret = arena_run_reg_alloc(aRun, aBin);
+  MOZ_DIAGNOSTIC_ASSERT(ret);
+  aRun->nfree--;
+
+  return ret;
 }
 
-/* Re-fill bin->runcur, then call arena_bin_malloc_easy(). */
+/* Re-fill bin->runcur, then call arena_t::MallocBinEasy(). */
 static void *
 arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin)
 {
 
 	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_bin_malloc_easy(arena, bin, bin->runcur));
+	return arena->MallocBinEasy(bin, bin->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
@@ -3244,17 +3246,17 @@ arena_malloc_small(arena_t *arena, size_
 		size = pow2_ceil(size);
 		bin = &arena->mBins[ntbins + nqbins
 		    + (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_bin_malloc_easy(arena, bin, run);
+		ret = arena->MallocBinEasy(bin, run);
 	else
 		ret = arena_bin_malloc_hard(arena, bin);
 
 	if (!ret) {
 		malloc_spin_unlock(&arena->mLock);
 		return nullptr;
 	}