Refactor/fix ph.

Refactor ph to support configurable comparison functions.  Use a cpp
macro code generation form equivalent to the rb macros so that pairing
heaps can be used for both run heaps and chunk heaps.

Remove per node parent pointers, and instead use leftmost siblings' prev
pointers to track parents.

Fix multi-pass sibling merging to iterate over intermediate results
using a FIFO, rather than a LIFO.  Use this fixed sibling merging
implementation for both merge phases of the auxiliary twopass algorithm
(first merging the aux list, then replacing the root with its merged
children).  This fixes both degenerate merge behavior and the potential
for deep recursion.

This regression was introduced by
6bafa6678f (Pairing heap).

This resolves #371.
This commit is contained in:
Jason Evans
2016-03-26 17:30:37 -07:00
parent 2ee2f1ec57
commit c6a2c39404
8 changed files with 613 additions and 335 deletions

View File

@@ -82,7 +82,6 @@ arena_nthreads_dec
arena_nthreads_get
arena_nthreads_inc
arena_palloc
arena_ph_to_miscelm
arena_postfork_child
arena_postfork_parent
arena_prefork
@@ -101,6 +100,12 @@ arena_ralloc_junk_large
arena_ralloc_no_move
arena_rd_to_miscelm
arena_redzone_corruption
arena_run_heap_empty
arena_run_heap_first
arena_run_heap_insert
arena_run_heap_new
arena_run_heap_remove_first
arena_run_heap_remove
arena_run_regind
arena_run_to_miscelm
arena_salloc
@@ -381,15 +386,6 @@ pages_map
pages_purge
pages_trim
pages_unmap
ph_first
ph_insert
ph_merge
ph_merge_aux_list
ph_merge_ordered
ph_merge_pairs
ph_new
ph_remove_first
ph_remove
pow2_ceil_u32
pow2_ceil_u64
pow2_ceil_zu