MarkedAllocatorInlines.h [plain text]
#pragma once
#include "MarkedAllocator.h"
namespace JSC {
ALWAYS_INLINE void* MarkedAllocator::tryAllocate(GCDeferralContext* deferralContext)
{
unsigned remaining = m_freeList.remaining;
if (remaining) {
unsigned cellSize = m_cellSize;
remaining -= cellSize;
m_freeList.remaining = remaining;
return m_freeList.payloadEnd - remaining - cellSize;
}
FreeCell* head = m_freeList.head;
if (UNLIKELY(!head))
return tryAllocateSlowCase(deferralContext);
m_freeList.head = head->next;
return head;
}
ALWAYS_INLINE void* MarkedAllocator::allocate(GCDeferralContext* deferralContext)
{
unsigned remaining = m_freeList.remaining;
if (remaining) {
unsigned cellSize = m_cellSize;
remaining -= cellSize;
m_freeList.remaining = remaining;
return m_freeList.payloadEnd - remaining - cellSize;
}
FreeCell* head = m_freeList.head;
if (UNLIKELY(!head))
return allocateSlowCase(deferralContext);
m_freeList.head = head->next;
return head;
}
template <typename Functor> inline void MarkedAllocator::forEachBlock(const Functor& functor)
{
m_live.forEachSetBit(
[&] (size_t index) {
functor(m_blocks[index]);
});
}
template <typename Functor> inline void MarkedAllocator::forEachNotEmptyBlock(const Functor& functor)
{
m_markingNotEmpty.forEachSetBit(
[&] (size_t index) {
functor(m_blocks[index]);
});
}
}