summaryrefslogtreecommitdiff
path: root/gcc/alloc-pool.c
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-01 12:29:12 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-01 12:29:12 +0000
commit419f2d6236f6a4d83ccaf82a14610bfe532065e6 (patch)
tree5e5b7af70400998f92983d09f4c721873f8f42be /gcc/alloc-pool.c
parent6da3491c596e84a6b288f91fd7c22782fa158704 (diff)
downloadgcc-419f2d6236f6a4d83ccaf82a14610bfe532065e6.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223942 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/alloc-pool.c')
-rw-r--r--gcc/alloc-pool.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
index e34acdb3500..829556fe25a 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. */