#include "config.h"
#include "IsoSubspace.h"
#include "AllocatorInlines.h"
#include "BlockDirectoryInlines.h"
#include "IsoAlignedMemoryAllocator.h"
#include "LocalAllocatorInlines.h"
namespace JSC {
IsoSubspace::IsoSubspace(CString name, Heap& heap, HeapCellType* heapCellType, size_t size)
: Subspace(name, heap)
, m_size(size)
, m_directory(&heap, WTF::roundUpToMultipleOf<MarkedBlock::atomSize>(size))
, m_localAllocator(&m_directory)
, m_isoAlignedMemoryAllocator(std::make_unique<IsoAlignedMemoryAllocator>())
{
initialize(heapCellType, m_isoAlignedMemoryAllocator.get());
auto locker = holdLock(m_space.directoryLock());
m_directory.setSubspace(this);
m_space.addBlockDirectory(locker, &m_directory);
m_alignedMemoryAllocator->registerDirectory(&m_directory);
m_firstDirectory = &m_directory;
}
IsoSubspace::~IsoSubspace()
{
}
Allocator IsoSubspace::allocatorFor(size_t size, AllocatorForMode mode)
{
return allocatorForNonVirtual(size, mode);
}
void* IsoSubspace::allocate(VM& vm, size_t size, GCDeferralContext* deferralContext, AllocationFailureMode failureMode)
{
return allocateNonVirtual(vm, size, deferralContext, failureMode);
}
void IsoSubspace::didResizeBits(size_t blockIndex)
{
m_cellSets.forEach(
[&] (IsoCellSet* set) {
set->didResizeBits(blockIndex);
});
}
void IsoSubspace::didRemoveBlock(size_t blockIndex)
{
m_cellSets.forEach(
[&] (IsoCellSet* set) {
set->didRemoveBlock(blockIndex);
});
}
void IsoSubspace::didBeginSweepingToFreeList(MarkedBlock::Handle* block)
{
m_cellSets.forEach(
[&] (IsoCellSet* set) {
set->sweepToFreeList(block);
});
}
}