summaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-17 10:00:07 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-17 10:00:07 +0000
commit1ae3520e0d4d2a5693961919636474de0a4faef6 (patch)
tree0b0e309c095d0459230339edc0343cafe8f0c4c8 /libcpp/include
parente77b8253aa187580c9e185461ed28c207e693126 (diff)
downloadgcc-1ae3520e0d4d2a5693961919636474de0a4faef6.tar.gz
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
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/line-map.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 572e330a1bd..1e2a148e17b 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -53,6 +53,10 @@ typedef unsigned int source_location;
/* Memory allocation function typedef. Works like xrealloc. */
typedef void *(*line_map_realloc) (void *, size_t);
+/* Memory allocator function that returns the actual allocated size,
+ for a given requested allocation. */
+typedef size_t (*line_map_round_alloc_size_func) (size_t);
+
/* An ordinary line map encodes physical source locations. Those
physical source locations are called "spelling locations".
@@ -281,6 +285,10 @@ struct GTY(()) line_maps {
/* If non-null, the allocator to use when resizing 'maps'. If null,
xrealloc is used. */
line_map_realloc reallocator;
+
+ /* The allocators' function used to know the actual size it
+ allocated, for a certain allocation size requested. */
+ line_map_round_alloc_size_func round_alloc_size;
};
/* Returns the pointer to the memory region where information about