Commit 7f5b959a authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

Split functionality of MarkedAllocator::m_currentBlock

https://bugs.webkit.org/show_bug.cgi?id=92550

Reviewed by Filip Pizlo.

MarkedAllocator::m_currentBlock serves two purposes right now; it indicates the block that is currently 
being used for allocation and the beginning of the list of blocks that need to be swept. We should split 
these two functionalities into two separate fields.

* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::tryAllocateHelper): Use m_blocksToSweep instead of m_currentBlock as the 
initializer/reference of the loop. Only change m_currentBlock when we know what the result will be.
(JSC::MarkedAllocator::addBlock): When we add a new block we know that both m_blocksToSweep and 
m_currentBlock are null. In order to preserve the invariant that m_currentBlock <= m_blocksToSweep, 
we assign both of them to point to the new block.
(JSC::MarkedAllocator::removeBlock): We need a separate check to see if the block we're removing is 
m_blocksToSweep and if so, advance it to the next block in the list.
* heap/MarkedAllocator.h:
(MarkedAllocator): Initialize m_blocksToSweep.
(JSC::MarkedAllocator::MarkedAllocator):
(JSC::MarkedAllocator::reset): We set m_blocksToSweep to be the head of our list. This function is called
at the end of a collection, so all of the blocks in our allocator need to be swept. We need to sweep a 
block before we can start allocating, so m_currentBlock is set to null. We also set the freeList to 
the empty FreeList to emphasize the fact that we can't start allocating until we do some sweeping.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9108c4f0
2012-07-27 Mark Hahnenberg <mhahnenberg@apple.com>
Split functionality of MarkedAllocator::m_currentBlock
https://bugs.webkit.org/show_bug.cgi?id=92550
Reviewed by Filip Pizlo.
MarkedAllocator::m_currentBlock serves two purposes right now; it indicates the block that is currently
being used for allocation and the beginning of the list of blocks that need to be swept. We should split
these two functionalities into two separate fields.
* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::tryAllocateHelper): Use m_blocksToSweep instead of m_currentBlock as the
initializer/reference of the loop. Only change m_currentBlock when we know what the result will be.
(JSC::MarkedAllocator::addBlock): When we add a new block we know that both m_blocksToSweep and
m_currentBlock are null. In order to preserve the invariant that m_currentBlock <= m_blocksToSweep,
we assign both of them to point to the new block.
(JSC::MarkedAllocator::removeBlock): We need a separate check to see if the block we're removing is
m_blocksToSweep and if so, advance it to the next block in the list.
* heap/MarkedAllocator.h:
(MarkedAllocator): Initialize m_blocksToSweep.
(JSC::MarkedAllocator::MarkedAllocator):
(JSC::MarkedAllocator::reset): We set m_blocksToSweep to be the head of our list. This function is called
at the end of a collection, so all of the blocks in our allocator need to be swept. We need to sweep a
block before we can start allocating, so m_currentBlock is set to null. We also set the freeList to
the empty FreeList to emphasize the fact that we can't start allocating until we do some sweeping.
2012-07-27 Mark Hahnenberg <mhahnenberg@apple.com>
Increase inline storage for JSFinalObjects by one
......
......@@ -29,15 +29,19 @@ bool MarkedAllocator::isPagedOut(double deadline)
inline void* MarkedAllocator::tryAllocateHelper()
{
if (!m_freeList.head) {
for (MarkedBlock*& block = m_currentBlock; block; block = static_cast<MarkedBlock*>(block->next())) {
for (MarkedBlock*& block = m_blocksToSweep; block; block = static_cast<MarkedBlock*>(block->next())) {
m_freeList = block->sweep(MarkedBlock::SweepToFreeList);
if (m_freeList.head)
if (m_freeList.head) {
m_currentBlock = block;
break;
}
block->didConsumeFreeList();
}
if (!m_freeList.head)
if (!m_freeList.head) {
m_currentBlock = 0;
return 0;
}
}
MarkedBlock::FreeCell* head = m_freeList.head;
......@@ -100,10 +104,11 @@ MarkedBlock* MarkedAllocator::allocateBlock()
void MarkedAllocator::addBlock(MarkedBlock* block)
{
ASSERT(!m_currentBlock);
ASSERT(!m_blocksToSweep);
ASSERT(!m_freeList.head);
m_blockList.append(block);
m_currentBlock = block;
m_blocksToSweep = m_currentBlock = block;
m_freeList = block->sweep(MarkedBlock::SweepToFreeList);
}
......@@ -113,6 +118,8 @@ void MarkedAllocator::removeBlock(MarkedBlock* block)
m_currentBlock = static_cast<MarkedBlock*>(m_currentBlock->next());
m_freeList = MarkedBlock::FreeList();
}
if (m_blocksToSweep == block)
m_blocksToSweep = static_cast<MarkedBlock*>(m_blocksToSweep->next());
m_blockList.remove(block);
}
......
......@@ -46,6 +46,7 @@ private:
MarkedBlock::FreeList m_freeList;
MarkedBlock* m_currentBlock;
MarkedBlock* m_blocksToSweep;
DoublyLinkedList<HeapBlock> m_blockList;
size_t m_cellSize;
bool m_cellsNeedDestruction;
......@@ -56,6 +57,7 @@ private:
inline MarkedAllocator::MarkedAllocator()
: m_currentBlock(0)
, m_blocksToSweep(0)
, m_cellSize(0)
, m_cellsNeedDestruction(true)
, m_onlyContainsStructures(false)
......@@ -86,7 +88,9 @@ inline void* MarkedAllocator::allocate()
inline void MarkedAllocator::reset()
{
m_currentBlock = static_cast<MarkedBlock*>(m_blockList.head());
m_currentBlock = 0;
m_freeList = MarkedBlock::FreeList();
m_blocksToSweep = static_cast<MarkedBlock*>(m_blockList.head());
}
inline void MarkedAllocator::zapFreeList()
......
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