void WeakBlock::reap() { // If a block is completely empty, a reaping won't have any effect. if (isEmpty()) return; // If this WeakBlock doesn't belong to a MarkedBlock, we won't even be here. ASSERT(m_markedBlock); // We only reap after marking. ASSERT(m_markedBlock->isMarkedOrRetired()); for (size_t i = 0; i < weakImplCount(); ++i) { WeakImpl* weakImpl = &weakImpls()[i]; if (weakImpl->state() > WeakImpl::Dead) continue; if (m_markedBlock->isMarkedOrNewlyAllocated(weakImpl->jsValue().asCell())) { ASSERT(weakImpl->state() == WeakImpl::Live); continue; } weakImpl->setState(WeakImpl::Dead); } }
void WeakBlock::lastChanceToFinalize() { for (size_t i = 0; i < weakImplCount(); ++i) { WeakImpl* weakImpl = &weakImpls()[i]; if (weakImpl->state() >= WeakImpl::Finalized) continue; weakImpl->setState(WeakImpl::Dead); finalize(weakImpl); } }
void WeakBlock::visitDeadWeakImpls(HeapRootVisitor&) { // If a block is completely empty, a visit won't have any effect. if (!m_sweepResult.isNull() && m_sweepResult.blockIsFree) return; for (size_t i = 0; i < weakImplCount(); ++i) { WeakImpl* weakImpl = &weakImpls()[i]; if (weakImpl->state() > WeakImpl::Dead) continue; if (Heap::isMarked(weakImpl->jsValue().asCell())) continue; weakImpl->setState(WeakImpl::Dead); } }
void WeakBlock::reap() { // If a block is completely empty, a reaping won't have any effect. if (isEmpty()) return; // If this WeakBlock doesn't belong to a CellContainer, we won't even be here. ASSERT(m_container); HeapVersion markingVersion = m_container.heap()->objectSpace().markingVersion(); for (size_t i = 0; i < weakImplCount(); ++i) { WeakImpl* weakImpl = &weakImpls()[i]; if (weakImpl->state() > WeakImpl::Dead) continue; if (m_container.isMarked(markingVersion, weakImpl->jsValue().asCell())) { ASSERT(weakImpl->state() == WeakImpl::Live); continue; } weakImpl->setState(WeakImpl::Dead); } }