Changeset 123931 in webkit
- Timestamp:
- Jul 27, 2012 3:59:14 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r123905 r123931 1 2012-07-27 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 Split functionality of MarkedAllocator::m_currentBlock 4 https://bugs.webkit.org/show_bug.cgi?id=92550 5 6 Reviewed by Filip Pizlo. 7 8 MarkedAllocator::m_currentBlock serves two purposes right now; it indicates the block that is currently 9 being used for allocation and the beginning of the list of blocks that need to be swept. We should split 10 these two functionalities into two separate fields. 11 12 * heap/MarkedAllocator.cpp: 13 (JSC::MarkedAllocator::tryAllocateHelper): Use m_blocksToSweep instead of m_currentBlock as the 14 initializer/reference of the loop. Only change m_currentBlock when we know what the result will be. 15 (JSC::MarkedAllocator::addBlock): When we add a new block we know that both m_blocksToSweep and 16 m_currentBlock are null. In order to preserve the invariant that m_currentBlock <= m_blocksToSweep, 17 we assign both of them to point to the new block. 18 (JSC::MarkedAllocator::removeBlock): We need a separate check to see if the block we're removing is 19 m_blocksToSweep and if so, advance it to the next block in the list. 20 * heap/MarkedAllocator.h: 21 (MarkedAllocator): Initialize m_blocksToSweep. 22 (JSC::MarkedAllocator::MarkedAllocator): 23 (JSC::MarkedAllocator::reset): We set m_blocksToSweep to be the head of our list. This function is called 24 at the end of a collection, so all of the blocks in our allocator need to be swept. We need to sweep a 25 block before we can start allocating, so m_currentBlock is set to null. We also set the freeList to 26 the empty FreeList to emphasize the fact that we can't start allocating until we do some sweeping. 27 1 28 2012-07-27 Mark Hahnenberg <mhahnenberg@apple.com> 2 29 -
trunk/Source/JavaScriptCore/heap/MarkedAllocator.cpp
r123813 r123931 30 30 { 31 31 if (!m_freeList.head) { 32 for (MarkedBlock*& block = m_ currentBlock; block; block = static_cast<MarkedBlock*>(block->next())) {32 for (MarkedBlock*& block = m_blocksToSweep; block; block = static_cast<MarkedBlock*>(block->next())) { 33 33 m_freeList = block->sweep(MarkedBlock::SweepToFreeList); 34 if (m_freeList.head) 34 if (m_freeList.head) { 35 m_currentBlock = block; 35 36 break; 37 } 36 38 block->didConsumeFreeList(); 37 39 } 38 40 39 if (!m_freeList.head) 41 if (!m_freeList.head) { 42 m_currentBlock = 0; 40 43 return 0; 44 } 41 45 } 42 46 … … 101 105 { 102 106 ASSERT(!m_currentBlock); 107 ASSERT(!m_blocksToSweep); 103 108 ASSERT(!m_freeList.head); 104 109 105 110 m_blockList.append(block); 106 m_ currentBlock = block;111 m_blocksToSweep = m_currentBlock = block; 107 112 m_freeList = block->sweep(MarkedBlock::SweepToFreeList); 108 113 } … … 114 119 m_freeList = MarkedBlock::FreeList(); 115 120 } 121 if (m_blocksToSweep == block) 122 m_blocksToSweep = static_cast<MarkedBlock*>(m_blocksToSweep->next()); 116 123 m_blockList.remove(block); 117 124 } -
trunk/Source/JavaScriptCore/heap/MarkedAllocator.h
r123813 r123931 47 47 MarkedBlock::FreeList m_freeList; 48 48 MarkedBlock* m_currentBlock; 49 MarkedBlock* m_blocksToSweep; 49 50 DoublyLinkedList<HeapBlock> m_blockList; 50 51 size_t m_cellSize; … … 57 58 inline MarkedAllocator::MarkedAllocator() 58 59 : m_currentBlock(0) 60 , m_blocksToSweep(0) 59 61 , m_cellSize(0) 60 62 , m_cellsNeedDestruction(true) … … 87 89 inline void MarkedAllocator::reset() 88 90 { 89 m_currentBlock = static_cast<MarkedBlock*>(m_blockList.head()); 91 m_currentBlock = 0; 92 m_freeList = MarkedBlock::FreeList(); 93 m_blocksToSweep = static_cast<MarkedBlock*>(m_blockList.head()); 90 94 } 91 95
Note: See TracChangeset
for help on using the changeset viewer.