Commit 65d47224 authored by ggaren@apple.com's avatar ggaren@apple.com
Browse files

Some MarkedBlock refactoring.

        
Rubber-stamped by Gavin Barraclough.

Made cells private.
        
Renamed cells => m_cells
        marked => m_marks.

* runtime/JSCell.h:
(JSC::JSCell::MarkedBlock::allocate):
* runtime/MarkedBlock.cpp:
(JSC::MarkedBlock::destroy):
(JSC::MarkedBlock::MarkedBlock):
(JSC::MarkedBlock::sweep):
* runtime/MarkedBlock.h:
(JSC::MarkedBlock::isEmpty):
(JSC::MarkedBlock::clearMarks):
(JSC::MarkedBlock::markCount):
(JSC::MarkedBlock::isMarked):
(JSC::MarkedBlock::testAndSetMarked):
(JSC::MarkedBlock::setMarked):
(JSC::MarkedBlock::forEach):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78501 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 568d866c
2011-02-14 Geoffrey Garen <ggaren@apple.com>
Rubber-stamped by Gavin Barraclough.
Some MarkedBlock refactoring.
Made cells private.
Renamed cells => m_cells
marked => m_marks.
* runtime/JSCell.h:
(JSC::JSCell::MarkedBlock::allocate):
* runtime/MarkedBlock.cpp:
(JSC::MarkedBlock::destroy):
(JSC::MarkedBlock::MarkedBlock):
(JSC::MarkedBlock::sweep):
* runtime/MarkedBlock.h:
(JSC::MarkedBlock::isEmpty):
(JSC::MarkedBlock::clearMarks):
(JSC::MarkedBlock::markCount):
(JSC::MarkedBlock::isMarked):
(JSC::MarkedBlock::testAndSetMarked):
(JSC::MarkedBlock::setMarked):
(JSC::MarkedBlock::forEach):
2011-02-14 Adam Barth <abarth@webkit.org>
 
Reviewed by Eric Seidel.
......
......@@ -406,12 +406,12 @@ namespace JSC {
{
do {
ASSERT(nextCell < CELLS_PER_BLOCK);
if (!marked.testAndSet(nextCell)) { // Always false for the last cell in the block
JSCell* cell = reinterpret_cast<JSCell*>(&cells[nextCell++]);
if (!m_marks.testAndSet(nextCell)) { // Always false for the last cell in the block
JSCell* cell = reinterpret_cast<JSCell*>(&m_cells[nextCell++]);
cell->~JSCell();
return cell;
}
nextCell = marked.nextPossiblyUnset(nextCell);
nextCell = m_marks.nextPossiblyUnset(nextCell);
} while (nextCell != CELLS_PER_BLOCK);
nextCell = 0;
......
......@@ -41,7 +41,7 @@ MarkedBlock* MarkedBlock::create(JSGlobalData* globalData)
void MarkedBlock::destroy(MarkedBlock* block)
{
for (size_t i = 0; i < CELLS_PER_BLOCK; ++i)
reinterpret_cast<JSCell*>(&block->cells[i])->~JSCell();
reinterpret_cast<JSCell*>(&block->m_cells[i])->~JSCell();
block->m_allocation.deallocate();
}
......@@ -49,11 +49,11 @@ MarkedBlock::MarkedBlock(const PageAllocationAligned& allocation, JSGlobalData*
: m_allocation(allocation)
, m_heap(&globalData->heap)
{
marked.set(CELLS_PER_BLOCK - 1);
m_marks.set(CELLS_PER_BLOCK - 1);
Structure* dummyMarkableCellStructure = globalData->dummyMarkableCellStructure.get();
for (size_t i = 0; i < CELLS_PER_BLOCK; ++i)
new (&cells[i]) JSCell(dummyMarkableCellStructure);
new (&m_cells[i]) JSCell(dummyMarkableCellStructure);
}
void MarkedBlock::sweep()
......@@ -63,16 +63,16 @@ void MarkedBlock::sweep()
#endif
for (size_t i = 0; i < CELLS_PER_BLOCK; ++i) {
if (marked.get(i))
if (m_marks.get(i))
continue;
JSCell* cell = reinterpret_cast<JSCell*>(&cells[i]);
JSCell* cell = reinterpret_cast<JSCell*>(&m_cells[i]);
#if ENABLE(JSC_ZOMBIES)
if (!cell->isZombie()) {
const ClassInfo* info = cell->classInfo();
cell->~JSCell();
new (cell) JSZombie(info, JSZombie::leakedZombieStructure());
marked.set(i);
m_marks.set(i);
}
#else
cell->~JSCell();
......
......@@ -88,12 +88,11 @@ namespace JSC {
template <typename Functor> void forEach(Functor&);
FixedArray<CollectorCell, CELLS_PER_BLOCK> cells;
private:
MarkedBlock(const PageAllocationAligned&, JSGlobalData*);
WTF::Bitmap<BITS_PER_BLOCK> marked;
FixedArray<CollectorCell, CELLS_PER_BLOCK> m_cells;
WTF::Bitmap<BITS_PER_BLOCK> m_marks;
PageAllocationAligned m_allocation;
Heap* m_heap;
};
......@@ -115,22 +114,22 @@ namespace JSC {
inline bool MarkedBlock::isEmpty()
{
marked.clear(CELLS_PER_BLOCK - 1); // Clear the always-set last bit to avoid confusing isEmpty().
bool result = marked.isEmpty();
marked.set(CELLS_PER_BLOCK - 1);
m_marks.clear(CELLS_PER_BLOCK - 1); // Clear the always-set last bit to avoid confusing isEmpty().
bool result = m_marks.isEmpty();
m_marks.set(CELLS_PER_BLOCK - 1);
return result;
}
inline void MarkedBlock::clearMarks()
{
// allocate() assumes that the last mark bit is always set.
marked.clearAll();
marked.set(CELLS_PER_BLOCK - 1);
m_marks.clearAll();
m_marks.set(CELLS_PER_BLOCK - 1);
}
inline size_t MarkedBlock::markCount()
{
return marked.count() - 1; // The last mark bit is always set.
return m_marks.count() - 1; // The last mark bit is always set.
}
inline size_t MarkedBlock::size()
......@@ -150,25 +149,25 @@ namespace JSC {
inline bool MarkedBlock::isMarked(const void* cell)
{
return marked.get(cellNumber(cell));
return m_marks.get(cellNumber(cell));
}
inline bool MarkedBlock::testAndSetMarked(const void* cell)
{
return marked.testAndSet(cellNumber(cell));
return m_marks.testAndSet(cellNumber(cell));
}
inline void MarkedBlock::setMarked(const void* cell)
{
marked.set(cellNumber(cell));
m_marks.set(cellNumber(cell));
}
template <typename Functor> inline void MarkedBlock::forEach(Functor& functor)
{
for (size_t i = 0; i < CELLS_PER_BLOCK - 1; ++i) { // The last cell is a dummy place-holder.
if (!marked.get(i))
if (!m_marks.get(i))
continue;
functor(reinterpret_cast<JSCell*>(&cells[i]));
functor(reinterpret_cast<JSCell*>(&m_cells[i]));
}
}
......
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