diff options
author | Martin Liska <mliska@suse.cz> | 2015-06-01 14:29:12 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2015-06-01 12:29:12 +0000 |
commit | 7d50111bc5df13eab9a7bfe2474d259624abe5d3 (patch) | |
tree | 5e5b7af70400998f92983d09f4c721873f8f42be /gcc/alloc-pool.c | |
parent | 32d48af55ed76de590977ef9fc32f392523ff4d9 (diff) | |
download | gcc-7d50111bc5df13eab9a7bfe2474d259624abe5d3.zip gcc-7d50111bc5df13eab9a7bfe2474d259624abe5d3.tar.gz gcc-7d50111bc5df13eab9a7bfe2474d259624abe5d3.tar.bz2 |
Introduce new type-based pool allocator.
* alloc-pool.c (struct alloc_pool_descriptor): Move definition
to header file.
* alloc-pool.h (pool_allocator::pool_allocator): New function.
(pool_allocator::release): Likewise.
(inline pool_allocator::release_if_empty): Likewise.
(inline pool_allocator::~pool_allocator): Likewise.
(pool_allocator::allocate): Likewise.
(pool_allocator::remove): Likewise.
From-SVN: r223942
Diffstat (limited to 'gcc/alloc-pool.c')
-rw-r--r-- | gcc/alloc-pool.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c index e34acdb..829556f 100644 --- a/gcc/alloc-pool.c +++ b/gcc/alloc-pool.c @@ -25,6 +25,8 @@ along with GCC; see the file COPYING3. If not see #include "hash-table.h" #include "hash-map.h" +ALLOC_POOL_ID_TYPE last_id; + #define align_eight(x) (((x+7) >> 3) << 3) /* The internal allocation object. */ @@ -58,36 +60,10 @@ typedef struct allocation_object_def #define USER_PTR_FROM_ALLOCATION_OBJECT_PTR(X) \ ((void *) (((allocation_object *) (X))->u.data)) -#ifdef ENABLE_CHECKING -/* Last used ID. */ -static ALLOC_POOL_ID_TYPE last_id; -#endif - -/* Store information about each particular alloc_pool. Note that this - will underestimate the amount the amount of storage used by a small amount: - 1) The overhead in a pool is not accounted for. - 2) The unallocated elements in a block are not accounted for. Note - that this can at worst case be one element smaller that the block - size for that pool. */ -struct alloc_pool_descriptor -{ - /* Number of pools allocated. */ - unsigned long created; - /* Gross allocated storage. */ - unsigned long allocated; - /* Amount of currently active storage. */ - unsigned long current; - /* Peak amount of storage used. */ - unsigned long peak; - /* Size of element in the pool. */ - int elt_size; -}; - /* Hashtable mapping alloc_pool names to descriptors. */ -static hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash; +hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash; -/* For given name, return descriptor, create new if needed. */ -static struct alloc_pool_descriptor * +struct alloc_pool_descriptor * allocate_pool_descriptor (const char *name) { if (!alloc_pool_hash) @@ -98,6 +74,7 @@ allocate_pool_descriptor (const char *name) return &alloc_pool_hash->get_or_insert (name); } + /* Create a pool of things of size SIZE, with NUM in each block we allocate. */ |