From 3597968453904b07652aa1f9abe9d66e04818bf3 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 25 Jun 2016 00:09:52 +0300 Subject: [PATCH] Michael's allocator - small improvements --- cds/memory/michael/allocator.h | 58 ++++++++++------------------------ 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/cds/memory/michael/allocator.h b/cds/memory/michael/allocator.h index 3521e014..d98fc974 100644 --- a/cds/memory/michael/allocator.h +++ b/cds/memory/michael/allocator.h @@ -1517,46 +1517,26 @@ namespace michael { void free_processor_heap( processor_heap * pProcHeap ) { - if ( pProcHeap->nPageIdx == processor_heap::c_nPageSelfAllocation ) { - superblock_desc * pDesc; + assert( pProcHeap->nPageIdx != processor_heap::c_nPageSelfAllocation ); - for ( pDesc = pProcHeap->partialList.pop(); pDesc; pDesc = pProcHeap->partialList.pop()) { - free( pDesc->pSB ); - m_AlignedHeap.free( pDesc ); - } - - superblock_desc * pPartial = pProcHeap->pPartial.load(atomics::memory_order_relaxed); - if ( pPartial ) { - free( pPartial->pSB ); - m_AlignedHeap.free( pPartial ); - } + page_heap& pageHeap = pProcHeap->pProcDesc->pageHeaps[pProcHeap->nPageIdx]; + superblock_desc * pDesc; - pDesc = pProcHeap->active.load(atomics::memory_order_relaxed).ptr(); - if ( pDesc ) { - free( pDesc->pSB ); - m_AlignedHeap.free( pDesc ); - } + for ( pDesc = pProcHeap->partialList.pop(); pDesc; pDesc = pProcHeap->partialList.pop()) { + pageHeap.free( pDesc->pSB ); + m_AlignedHeap.free( pDesc ); } - else { - page_heap& pageHeap = pProcHeap->pProcDesc->pageHeaps[pProcHeap->nPageIdx]; - superblock_desc * pDesc; - for ( pDesc = pProcHeap->partialList.pop(); pDesc; pDesc = pProcHeap->partialList.pop()) { - pageHeap.free( pDesc->pSB ); - m_AlignedHeap.free( pDesc ); - } - - superblock_desc * pPartial = pProcHeap->pPartial.load(atomics::memory_order_relaxed); - if ( pPartial ) { - pageHeap.free( pPartial->pSB ); - m_AlignedHeap.free( pPartial ); - } + superblock_desc * pPartial = pProcHeap->pPartial.load(atomics::memory_order_relaxed); + if ( pPartial ) { + pageHeap.free( pPartial->pSB ); + m_AlignedHeap.free( pPartial ); + } - pDesc = pProcHeap->active.load(atomics::memory_order_relaxed).ptr(); - if ( pDesc ) { - pageHeap.free( pDesc->pSB ); - m_AlignedHeap.free( pDesc ); - } + pDesc = pProcHeap->active.load(atomics::memory_order_relaxed).ptr(); + if ( pDesc ) { + pageHeap.free( pDesc->pSB ); + m_AlignedHeap.free( pDesc ); } } @@ -1568,13 +1548,7 @@ namespace michael { { processor_heap * const pProcHeapEnd = pDesc->arrProcHeap + m_SizeClassSelector.size(); - // In first, free small blocks - for ( processor_heap * pProcHeap = pDesc->arrProcHeap; pProcHeap < pProcHeapEnd; ++pProcHeap ) { - if ( pProcHeap->nPageIdx == processor_heap::c_nPageSelfAllocation ) - free_processor_heap( pProcHeap ); - } - - // free large blocks + // free large blocks only for ( processor_heap * pProcHeap = pDesc->arrProcHeap; pProcHeap < pProcHeapEnd; ++pProcHeap ) { if ( pProcHeap->nPageIdx != processor_heap::c_nPageSelfAllocation ) free_processor_heap( pProcHeap ); -- 2.34.1