void BlockDirectory::addBlock(MarkedBlock::Handle* block) { size_t index; if (m_freeBlockIndices.isEmpty()) { index = m_blocks.size(); size_t oldCapacity = m_blocks.capacity(); m_blocks.append(block); if (m_blocks.capacity() != oldCapacity) { forEachBitVector( NoLockingNecessary, [&] (FastBitVector& vector) { ASSERT_UNUSED(vector, vector.numBits() == oldCapacity); }); ASSERT(m_blocks.capacity() > oldCapacity); LockHolder locker(m_bitvectorLock); subspace()->didResizeBits(m_blocks.capacity()); forEachBitVector( locker, [&] (FastBitVector& vector) { vector.resize(m_blocks.capacity()); }); } } else { index = m_freeBlockIndices.takeLast(); ASSERT(!m_blocks[index]); m_blocks[index] = block; } forEachBitVector( NoLockingNecessary, [&] (FastBitVector& vector) { ASSERT_UNUSED(vector, !vector[index]); }); // This is the point at which the block learns of its cellSize() and attributes(). block->didAddToDirectory(this, index); setIsLive(NoLockingNecessary, index, true); setIsEmpty(NoLockingNecessary, index, true); }
void MarkedAllocator::addBlock(MarkedBlock::Handle* block) { size_t index; if (m_freeBlockIndices.isEmpty()) { index = m_blocks.size(); size_t oldCapacity = m_blocks.capacity(); m_blocks.append(block); if (m_blocks.capacity() != oldCapacity) { forEachBitVector( [&] (FastBitVector& vector) { ASSERT_UNUSED(vector, vector.numBits() == oldCapacity); }); ASSERT(m_blocks.capacity() > oldCapacity); forEachBitVector( [&] (FastBitVector& vector) { vector.resize(m_blocks.capacity()); }); } } else { index = m_freeBlockIndices.takeLast(); ASSERT(!m_blocks[index]); m_blocks[index] = block; } forEachBitVector( [&] (FastBitVector& vector) { ASSERT_UNUSED(vector, !vector[index]); }); // This is the point at which the block learns of its cellSize() and attributes(). block->didAddToAllocator(this, index); setIsLive(index, true); setIsEmpty(index, true); }
void MarkedAllocator::removeBlock(MarkedBlock::Handle* block) { ASSERT(block->allocator() == this); ASSERT(m_blocks[block->index()] == block); m_blocks[block->index()] = nullptr; m_freeBlockIndices.append(block->index()); forEachBitVector( [&] (FastBitVector& vector) { vector[block->index()] = false; }); block->didRemoveFromAllocator(); }
void BlockDirectory::removeBlock(MarkedBlock::Handle* block) { ASSERT(block->directory() == this); ASSERT(m_blocks[block->index()] == block); subspace()->didRemoveBlock(block->index()); m_blocks[block->index()] = nullptr; m_freeBlockIndices.append(block->index()); forEachBitVector( holdLock(m_bitvectorLock), [&] (FastBitVector& vector) { vector[block->index()] = false; }); block->didRemoveFromDirectory(); }