Commit 7d50111b by Martin Liska Committed by Martin Liska

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
parent 32d48af5
2015-06-01 Martin Liska <mliska@suse.cz>
* 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.
2015-06-01 James Greenhalgh <james.greenhalgh@arm.com>
* sched-deps.c (sched_analyze_2): Replace fuseable with fusible
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment