diff options
author | Jan Hubicka <jh@suse.cz> | 2019-11-20 16:04:34 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2019-11-20 15:04:34 +0000 |
commit | 516fd7cedb025b09000563cdba6214461621400d (patch) | |
tree | 61c772013cc91032ba6dcdcaffd99445d40bd10b /gcc/fibonacci_heap.c | |
parent | f6fbdc385ae9fd3f07b2f5fe8b7fe2a134622be7 (diff) | |
download | gcc-516fd7cedb025b09000563cdba6214461621400d.zip gcc-516fd7cedb025b09000563cdba6214461621400d.tar.gz gcc-516fd7cedb025b09000563cdba6214461621400d.tar.bz2 |
Add pool_allocator for fibonaci heaps.
* fibonacci_heap.h (fibonacci_heap<K,V>::fibonacci_heap):
Add allocator parameter.
(fibonacci_heap<K,V>::~fibonacci_heap): Optimize destruction.
(fibonacci_heap<K,V>::m_allocator): New.
(fibonacci_heap<K,V>::m_own_allocator): New.
(fibonacci_heap<K,V>::insert): Use allocator.
(fibonacci_heap<K,V>::extract_min): Likewise.
(fibonacci_heap<K,V>::union_with): Assert that both heaps share
allocator.
(fibonacci_heap<K,V>::consolidate): Allocate constant sized vector
on stack.
* fibonacci_heap.c: Include alloc-pool
(test_empty_heap): Initialize allocator.
(test_union): Likewise.
* bb-reorder.c: Include alloc-pool.h.
* tracer.c: Inlclude alloc-pool.h.
From-SVN: r278501
Diffstat (limited to 'gcc/fibonacci_heap.c')
-rw-r--r-- | gcc/fibonacci_heap.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/fibonacci_heap.c b/gcc/fibonacci_heap.c index bddd047..2470715 100644 --- a/gcc/fibonacci_heap.c +++ b/gcc/fibonacci_heap.c @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" +#include "alloc-pool.h" #include "fibonacci_heap.h" #include "selftest.h" @@ -38,13 +39,14 @@ typedef fibonacci_heap <int, int> int_heap_t; static void test_empty_heap () { - int_heap_t *h1 = new int_heap_t (INT_MIN); + pool_allocator allocator ("fibheap test", sizeof (int_heap_node_t)); + int_heap_t *h1 = new int_heap_t (INT_MIN, &allocator); ASSERT_TRUE (h1->empty ()); ASSERT_EQ (0, h1->nodes ()); ASSERT_EQ (NULL, h1->min ()); - int_heap_t *h2 = new int_heap_t (INT_MIN); + int_heap_t *h2 = new int_heap_t (INT_MIN, &allocator); int_heap_t *r = h1->union_with (h2); ASSERT_TRUE (r->empty ()); @@ -169,12 +171,13 @@ static void test_union () { int value = 777; + pool_allocator allocator ("fibheap test", sizeof (int_heap_node_t)); - int_heap_t *heap1 = new int_heap_t (INT_MIN); + int_heap_t *heap1 = new int_heap_t (INT_MIN, &allocator); for (unsigned i = 0; i < 2 * TEST_HEAP_N; i++) heap1->insert (i, &value); - int_heap_t *heap2 = new int_heap_t (INT_MIN); + int_heap_t *heap2 = new int_heap_t (INT_MIN, &allocator); for (unsigned i = 2 * TEST_HEAP_N; i < 3 * TEST_HEAP_N; i++) heap2->insert (i, &value); @@ -196,12 +199,13 @@ static void test_union_of_equal_heaps () { int value = 777; + pool_allocator allocator ("fibheap test", sizeof (int_heap_node_t)); - int_heap_t *heap1 = new int_heap_t (INT_MIN); + int_heap_t *heap1 = new int_heap_t (INT_MIN, &allocator); for (unsigned i = 0; i < TEST_HEAP_N; i++) heap1->insert (i, &value); - int_heap_t *heap2 = new int_heap_t (INT_MIN); + int_heap_t *heap2 = new int_heap_t (INT_MIN, &allocator); for (unsigned i = 0; i < TEST_HEAP_N; i++) heap2->insert (i, &value); |