Bug 1401099 - Move arena_malloc_large to a method of arena_t. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 19:14:00 +0900
changeset 382279 5e4cc07e9af3dfe71643a0638df846cc4b18a8ac
parent 382278 9aac426a0bb6a60aba6f2907bdf31bf8a988a9dc
child 382280 1f0f2e2553d1cbf14e27e0bb16c223b7126cd13e
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_malloc_large to a method of arena_t. r=njn
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -796,16 +796,18 @@ private:
 
   void* MallocBinHard(arena_bin_t* aBin);
 
   arena_run_t* GetNonFullBinRun(arena_bin_t* aBin);
 
 public:
   inline void* MallocSmall(size_t aSize, bool aZero);
 
+  void* MallocLarge(size_t aSize, bool aZero);
+
   void Purge(bool aAll);
 
   void HardPurge();
 };
 
 /******************************************************************************/
 /*
  * Data.
@@ -3280,55 +3282,56 @@ arena_t::MallocSmall(size_t aSize, bool 
       memset(ret, 0, aSize);
     }
   } else
     memset(ret, 0, aSize);
 
   return ret;
 }
 
-static void *
-arena_malloc_large(arena_t *arena, size_t size, bool zero)
+void*
+arena_t::MallocLarge(size_t aSize, bool aZero)
 {
-	void *ret;
-
-	/* Large allocation. */
-	size = PAGE_CEILING(size);
-	malloc_spin_lock(&arena->mLock);
-	ret = arena->AllocRun(nullptr, size, true, zero);
-	if (!ret) {
-		malloc_spin_unlock(&arena->mLock);
-		return nullptr;
-	}
-	arena->mStats.allocated_large += size;
-	malloc_spin_unlock(&arena->mLock);
-
-	if (zero == false) {
-		if (opt_junk)
-			memset(ret, kAllocJunk, size);
-		else if (opt_zero)
-			memset(ret, 0, size);
-	}
-
-	return (ret);
+  void* ret;
+
+  /* Large allocation. */
+  aSize = PAGE_CEILING(aSize);
+  malloc_spin_lock(&mLock);
+  ret = AllocRun(nullptr, aSize, true, aZero);
+  if (!ret) {
+    malloc_spin_unlock(&mLock);
+    return nullptr;
+  }
+  mStats.allocated_large += aSize;
+  malloc_spin_unlock(&mLock);
+
+  if (aZero == false) {
+    if (opt_junk) {
+      memset(ret, kAllocJunk, aSize);
+    } else if (opt_zero) {
+      memset(ret, 0, aSize);
+    }
+  }
+
+  return (ret);
 }
 
 static inline void *
 arena_malloc(arena_t *arena, size_t size, bool zero)
 {
 
 	MOZ_ASSERT(arena);
 	MOZ_DIAGNOSTIC_ASSERT(arena->mMagic == ARENA_MAGIC);
 	MOZ_ASSERT(size != 0);
 	MOZ_ASSERT(QUANTUM_CEILING(size) <= arena_maxclass);
 
 	if (size <= bin_maxclass) {
 		return arena->MallocSmall(size, zero);
 	} else
-		return (arena_malloc_large(arena, size, zero));
+		return arena->MallocLarge(size, zero);
 }
 
 static inline void *
 imalloc(size_t size)
 {
 
 	MOZ_ASSERT(size != 0);