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.
--- 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