MarkedSpaceInlines.h [plain text]
#pragma once
#include "MarkedBlockInlines.h"
#include "MarkedSpace.h"
namespace JSC {
template<typename Functor> inline void MarkedSpace::forEachLiveCell(HeapIterationScope&, const Functor& functor)
{
ASSERT(isIterating());
forEachLiveCell(functor);
}
template<typename Functor> inline void MarkedSpace::forEachLiveCell(const Functor& functor)
{
BlockIterator end = m_blocks.set().end();
for (BlockIterator it = m_blocks.set().begin(); it != end; ++it) {
IterationStatus result = (*it)->handle().forEachLiveCell(
[&] (size_t, HeapCell* cell, HeapCell::Kind kind) -> IterationStatus {
return functor(cell, kind);
});
if (result == IterationStatus::Done)
return;
}
for (LargeAllocation* allocation : m_largeAllocations) {
if (allocation->isLive()) {
if (functor(allocation->cell(), allocation->attributes().cellKind) == IterationStatus::Done)
return;
}
}
}
template<typename Functor> inline void MarkedSpace::forEachDeadCell(HeapIterationScope&, const Functor& functor)
{
ASSERT(isIterating());
BlockIterator end = m_blocks.set().end();
for (BlockIterator it = m_blocks.set().begin(); it != end; ++it) {
if ((*it)->handle().forEachDeadCell(functor) == IterationStatus::Done)
return;
}
for (LargeAllocation* allocation : m_largeAllocations) {
if (!allocation->isLive()) {
if (functor(allocation->cell(), allocation->attributes().cellKind) == IterationStatus::Done)
return;
}
}
}
}