From 1ae3520e0d4d2a5693961919636474de0a4faef6 Mon Sep 17 00:00:00 2001 From: dodji Date: Mon, 17 Oct 2011 10:00:07 +0000 Subject: Reduce memory waste due to non-power-of-2 allocs This patch basically arranges for the allocation size of line_map buffers to be as close as possible to a power of two. This *significantly* decreases peak memory consumption as (macro) maps are numerous and stay live during all the compilation. The patch adds a new ggc_round_alloc_size interface to the ggc allocator. In each of the two main allocator implementations ('page' and 'zone') the function has been extracted from the main allocation function code and returns the actual size of the allocated memory region, thus giving a chance to the caller to maximize the amount of memory it actually uses from the allocated memory region. In the 'none' allocator implementation (that uses xmalloc) the ggc_round_alloc_size just returns the requested allocation size. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180086 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ggc-none.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/ggc-none.c') diff --git a/gcc/ggc-none.c b/gcc/ggc-none.c index 97d25b9b653..e57d61787df 100644 --- a/gcc/ggc-none.c +++ b/gcc/ggc-none.c @@ -39,6 +39,15 @@ ggc_alloc_typed_stat (enum gt_types_enum ARG_UNUSED (gte), size_t size return xmalloc (size); } +/* For a given size of memory requested for allocation, return the + actual size that is going to be allocated. */ + +size_t +ggc_round_alloc_size (size_t requested_size) +{ + return requested_size; +} + void * ggc_internal_alloc_stat (size_t size MEM_STAT_DECL) { -- cgit v1.2.1