Commit c1f5ce48 by Martin Liska Committed by Martin Liska

Change use to type-based pool allocator in asan.c.

	* asan.c (asan_mem_ref_get_alloc_pool):Use new type-based pool allocator.
	(asan_mem_ref_new) Likewise.
	(free_mem_ref_resources) Likewise.

From-SVN: r223948
parent 7e46899d
2015-06-01 Martin Liska <mliska@suse.cz> 2015-06-01 Martin Liska <mliska@suse.cz>
* asan.c (asan_mem_ref_get_alloc_pool):Use new type-based pool allocator.
(asan_mem_ref_new) Likewise.
(free_mem_ref_resources) Likewise.
2015-06-01 Martin Liska <mliska@suse.cz>
* var-tracking.c (variable_htab_free):Use new type-based pool allocator. * var-tracking.c (variable_htab_free):Use new type-based pool allocator.
(attrs_list_clear) Likewise. (attrs_list_clear) Likewise.
(attrs_list_insert) Likewise. (attrs_list_insert) Likewise.
......
...@@ -176,7 +176,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -176,7 +176,7 @@ along with GCC; see the file COPYING3. If not see
where '(...){n}' means the content inside the parenthesis occurs 'n' where '(...){n}' means the content inside the parenthesis occurs 'n'
times, with 'n' being the number of variables on the stack. times, with 'n' being the number of variables on the stack.
3/ The following 8 bytes contain the PC of the current function which 3/ The following 8 bytes contain the PC of the current function which
will be used by the run-time library to print an error message. will be used by the run-time library to print an error message.
...@@ -281,7 +281,7 @@ bool ...@@ -281,7 +281,7 @@ bool
set_asan_shadow_offset (const char *val) set_asan_shadow_offset (const char *val)
{ {
char *endp; char *endp;
errno = 0; errno = 0;
#ifdef HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
asan_shadow_offset_value = strtoull (val, &endp, 0); asan_shadow_offset_value = strtoull (val, &endp, 0);
...@@ -372,23 +372,24 @@ struct asan_mem_ref ...@@ -372,23 +372,24 @@ struct asan_mem_ref
/* The size of the access. */ /* The size of the access. */
HOST_WIDE_INT access_size; HOST_WIDE_INT access_size;
};
static alloc_pool asan_mem_ref_alloc_pool; /* Pool allocation new operator. */
inline void *operator new (size_t)
{
return pool.allocate ();
}
/* This creates the alloc pool used to store the instances of /* Delete operator utilizing pool allocation. */
asan_mem_ref that are stored in the hash table asan_mem_ref_ht. */ inline void operator delete (void *ptr)
{
pool.remove ((asan_mem_ref *) ptr);
}
static alloc_pool /* Memory allocation pool. */
asan_mem_ref_get_alloc_pool () static pool_allocator<asan_mem_ref> pool;
{ };
if (asan_mem_ref_alloc_pool == NULL)
asan_mem_ref_alloc_pool = create_alloc_pool ("asan_mem_ref", pool_allocator<asan_mem_ref> asan_mem_ref::pool ("asan_mem_ref", 10);
sizeof (asan_mem_ref),
10);
return asan_mem_ref_alloc_pool;
}
/* Initializes an instance of asan_mem_ref. */ /* Initializes an instance of asan_mem_ref. */
...@@ -408,8 +409,7 @@ asan_mem_ref_init (asan_mem_ref *ref, tree start, HOST_WIDE_INT access_size) ...@@ -408,8 +409,7 @@ asan_mem_ref_init (asan_mem_ref *ref, tree start, HOST_WIDE_INT access_size)
static asan_mem_ref* static asan_mem_ref*
asan_mem_ref_new (tree start, HOST_WIDE_INT access_size) asan_mem_ref_new (tree start, HOST_WIDE_INT access_size)
{ {
asan_mem_ref *ref = asan_mem_ref *ref = new asan_mem_ref;
(asan_mem_ref *) pool_alloc (asan_mem_ref_get_alloc_pool ());
asan_mem_ref_init (ref, start, access_size); asan_mem_ref_init (ref, start, access_size);
return ref; return ref;
...@@ -501,11 +501,7 @@ free_mem_ref_resources () ...@@ -501,11 +501,7 @@ free_mem_ref_resources ()
delete asan_mem_ref_ht; delete asan_mem_ref_ht;
asan_mem_ref_ht = NULL; asan_mem_ref_ht = NULL;
if (asan_mem_ref_alloc_pool) asan_mem_ref::pool.release ();
{
free_alloc_pool (asan_mem_ref_alloc_pool);
asan_mem_ref_alloc_pool = NULL;
}
} }
/* Return true iff the memory reference REF has been instrumented. */ /* Return true iff the memory reference REF has been instrumented. */
...@@ -2035,7 +2031,7 @@ maybe_instrument_assignment (gimple_stmt_iterator *iter) ...@@ -2035,7 +2031,7 @@ maybe_instrument_assignment (gimple_stmt_iterator *iter)
is_store); is_store);
is_instrumented = true; is_instrumented = true;
} }
if (gimple_assign_load_p (s)) if (gimple_assign_load_p (s))
{ {
ref_expr = gimple_assign_rhs1 (s); ref_expr = gimple_assign_rhs1 (s);
......
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