Bug 1360772 - Indicate to chunk_recycle callers that pages_commit has zeroed the chunk. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 06 Jul 2017 16:58:18 +0900
changeset 368194 9f73e5f2dc3cd7544a9c95ad65841025815242f4
parent 368193 9c930946021994fcac8affd794d18c1dcf728bd1
child 368195 094ae2ae92c5fcebc8a41f4349ba82a4d95a98aa
push id32158
push usercbook@mozilla.com
push dateTue, 11 Jul 2017 10:48:59 +0000
treeherdermozilla-central@5e2692f8a367 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1360772
milestone56.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 1360772 - Indicate to chunk_recycle callers that pages_commit has zeroed the chunk. r=njn Before returning a chunk, chunk_recycle calls pages_commit (when MALLOC_DECOMMIT is enabled), which is guaranteed to zero the chunk. The code further zeroing the chunk afterwards, which is now moved out to chunk_alloc callers, never took advantage of that fact, duplicating the effort of zeroing the chunk on Windows. By indicating to the callers that the chunk has already been zeroed, we allow callers to skip zeroing on their own.
memory/mozjemalloc/mozjemalloc.cpp
--- a/memory/mozjemalloc/mozjemalloc.cpp
+++ b/memory/mozjemalloc/mozjemalloc.cpp
@@ -2055,16 +2055,20 @@ chunk_recycle(extent_tree_t *chunks_szad
 	recycled_size -= size;
 
 	malloc_mutex_unlock(&chunks_mtx);
 
 	if (node)
 		base_node_dealloc(node);
 #ifdef MALLOC_DECOMMIT
 	pages_commit(ret, size);
+	// pages_commit is guaranteed to zero the chunk.
+	if (zeroed) {
+		*zeroed = true;
+	}
 #endif
 	return (ret);
 }
 
 #ifdef MOZ_MEMORY_WINDOWS
 /*
  * On Windows, calls to VirtualAlloc and VirtualFree must be matched, making it
  * awkward to recycle allocations of varying sizes. Therefore we only allow