Commit 6c4d6cef authored by ggaren@apple.com's avatar ggaren@apple.com
Browse files

2011-02-23 Geoffrey Garen <ggaren@apple.com>

        Reviewed by Oliver Hunt.

        Moved the "nextAtom" allocation pointer into MarkedBlock for better encapsulation
        https://bugs.webkit.org/show_bug.cgi?id=55079
        
        SunSpider reports no change.

        * runtime/Heap.cpp:
        (JSC::Heap::reset): Moved Zombie sweeping here, up from MarkedSpace,
        since we want Heap to logically control MarkedSpace. MarkedSpace should
        never choose to sweep itself.

        * runtime/JSCell.h:
        (JSC::JSCell::MarkedBlock::allocate): Updated for nextAtom becoming a
        member of MarkedBlock. No need to reset nextAtom to firstAtom() when
        we reach the end of a block, since there's now an explicit reset pass
        during GC.

        * runtime/MarkedBlock.cpp:
        (JSC::MarkedBlock::MarkedBlock):
        * runtime/MarkedBlock.h:
        (JSC::MarkedBlock::reset): Added the nextAtom data member, and reordered
        some data members to improve cache locality.

        * runtime/MarkedSpace.cpp:
        (JSC::MarkedSpace::MarkedSpace):
        (JSC::MarkedSpace::allocate):
        (JSC::MarkedSpace::reset):
        * runtime/MarkedSpace.h:
        (JSC::CollectorHeap::CollectorHeap): Removed nextAtom, and added an
        explicit reset pass.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79492 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bed8d396
2011-02-23 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
Moved the "nextAtom" allocation pointer into MarkedBlock for better encapsulation
https://bugs.webkit.org/show_bug.cgi?id=55079
SunSpider reports no change.
* runtime/Heap.cpp:
(JSC::Heap::reset): Moved Zombie sweeping here, up from MarkedSpace,
since we want Heap to logically control MarkedSpace. MarkedSpace should
never choose to sweep itself.
* runtime/JSCell.h:
(JSC::JSCell::MarkedBlock::allocate): Updated for nextAtom becoming a
member of MarkedBlock. No need to reset nextAtom to firstAtom() when
we reach the end of a block, since there's now an explicit reset pass
during GC.
* runtime/MarkedBlock.cpp:
(JSC::MarkedBlock::MarkedBlock):
* runtime/MarkedBlock.h:
(JSC::MarkedBlock::reset): Added the nextAtom data member, and reordered
some data members to improve cache locality.
* runtime/MarkedSpace.cpp:
(JSC::MarkedSpace::MarkedSpace):
(JSC::MarkedSpace::allocate):
(JSC::MarkedSpace::reset):
* runtime/MarkedSpace.h:
(JSC::CollectorHeap::CollectorHeap): Removed nextAtom, and added an
explicit reset pass.
2011-02-23 James Robinson <jamesr@chromium.org>
Unreviewed, rolling out r79428.
......
......@@ -376,6 +376,10 @@ void Heap::reset(SweepToggle sweepToggle)
m_markedSpace.reset();
m_extraCost = 0;
#if ENABLE(JSC_ZOMBIES)
sweep();
#endif
if (sweepToggle == DoSweep) {
m_markedSpace.sweep();
m_markedSpace.shrink();
......
......@@ -402,19 +402,18 @@ namespace JSC {
}
#endif
inline void* MarkedBlock::allocate(size_t& nextAtom)
inline void* MarkedBlock::allocate()
{
while (nextAtom < m_endAtom) {
if (!m_marks.testAndSet(nextAtom)) {
JSCell* cell = reinterpret_cast<JSCell*>(&atoms()[nextAtom]);
nextAtom += m_atomsPerCell;
while (m_nextAtom < m_endAtom) {
if (!m_marks.testAndSet(m_nextAtom)) {
JSCell* cell = reinterpret_cast<JSCell*>(&atoms()[m_nextAtom]);
m_nextAtom += m_atomsPerCell;
cell->~JSCell();
return cell;
}
nextAtom += m_atomsPerCell;
m_nextAtom += m_atomsPerCell;
}
nextAtom = firstAtom();
return 0;
}
......
......@@ -46,13 +46,15 @@ void MarkedBlock::destroy(MarkedBlock* block)
}
MarkedBlock::MarkedBlock(const PageAllocationAligned& allocation, JSGlobalData* globalData, size_t cellSize)
: m_atomsPerCell((cellSize + atomSize - 1) / atomSize)
, m_endAtom(atomsPerBlock - m_atomsPerCell + 1)
: m_nextAtom(firstAtom())
, m_allocation(allocation)
, m_heap(&globalData->heap)
, m_prev(0)
, m_next(0)
{
m_atomsPerCell = (cellSize + atomSize - 1) / atomSize;
m_endAtom = atomsPerBlock - m_atomsPerCell + 1;
Structure* dummyMarkableCellStructure = globalData->dummyMarkableCellStructure.get();
for (size_t i = firstAtom(); i < m_endAtom; i += m_atomsPerCell)
new (&atoms()[i]) JSCell(dummyMarkableCellStructure);
......
......@@ -60,7 +60,8 @@ namespace JSC {
MarkedBlock* prev() const;
MarkedBlock* next() const;
void* allocate(size_t& nextCell);
void* allocate();
void reset();
void sweep();
bool isEmpty();
......@@ -97,8 +98,9 @@ namespace JSC {
MarkedBlock(const PageAllocationAligned&, JSGlobalData*, size_t cellSize);
Atom* atoms();
size_t m_atomsPerCell;
size_t m_nextAtom;
size_t m_endAtom; // This is a fuzzy end. Always test for < m_endAtom.
size_t m_atomsPerCell;
WTF::Bitmap<blockSize / atomSize> m_marks;
PageAllocationAligned m_allocation;
Heap* m_heap;
......@@ -151,6 +153,11 @@ namespace JSC {
return m_next;
}
inline void MarkedBlock::reset()
{
m_nextAtom = firstAtom();
}
inline bool MarkedBlock::isEmpty()
{
return m_marks.isEmpty();
......
......@@ -34,7 +34,6 @@ MarkedSpace::MarkedSpace(JSGlobalData* globalData)
, m_highWaterMark(0)
, m_globalData(globalData)
{
m_heap.nextAtom = MarkedBlock::firstAtom();
}
void MarkedSpace::destroy()
......@@ -68,7 +67,7 @@ void MarkedSpace::freeBlocks(DoublyLinkedList<MarkedBlock>& blocks)
void* MarkedSpace::allocate(size_t)
{
for ( ; m_heap.nextBlock; m_heap.nextBlock = m_heap.nextBlock->next()) {
if (void* result = m_heap.nextBlock->allocate(m_heap.nextAtom))
if (void* result = m_heap.nextBlock->allocate())
return result;
m_waterMark += m_heap.nextBlock->capacity();
......@@ -76,7 +75,7 @@ void* MarkedSpace::allocate(size_t)
if (m_waterMark < m_highWaterMark) {
m_heap.nextBlock = allocateBlock();
return m_heap.nextBlock->allocate(m_heap.nextAtom);
return m_heap.nextBlock->allocate();
}
return 0;
......@@ -145,11 +144,11 @@ size_t MarkedSpace::capacity() const
void MarkedSpace::reset()
{
m_heap.nextBlock = m_heap.blockList.head();
m_heap.nextAtom = MarkedBlock::firstAtom();
m_waterMark = 0;
#if ENABLE(JSC_ZOMBIES)
sweep();
#endif
BlockIterator end = m_blocks.end();
for (BlockIterator it = m_blocks.begin(); it != end; ++it)
(*it)->reset();
}
} // namespace JSC
......@@ -47,12 +47,10 @@ namespace JSC {
struct CollectorHeap {
CollectorHeap()
: nextBlock(0)
, nextAtom(0)
{
}
MarkedBlock* nextBlock;
size_t nextAtom;
DoublyLinkedList<MarkedBlock> blockList;
};
......
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