#include "WeakSet.h"
#include "Heap.h"
+#include "VM.h"
namespace JSC {
WeakBlock* next = 0;
for (WeakBlock* block = m_blocks.head(); block; block = next) {
next = block->next();
- WeakBlock::destroy(block);
+ heap()->blockAllocator().deallocate(WeakBlock::destroy(block));
}
m_blocks.clear();
}
-void WeakSet::finalizeAll()
-{
- for (WeakBlock* block = m_blocks.head(); block; block = block->next())
- block->finalizeAll();
-}
-
-void WeakSet::visitLiveWeakImpls(HeapRootVisitor& visitor)
-{
- for (WeakBlock* block = m_blocks.head(); block; block = block->next())
- block->visitLiveWeakImpls(visitor);
-}
-
-void WeakSet::visitDeadWeakImpls(HeapRootVisitor& visitor)
-{
- for (WeakBlock* block = m_blocks.head(); block; block = block->next())
- block->visitDeadWeakImpls(visitor);
-}
-
void WeakSet::sweep()
{
- WeakBlock* next;
- for (WeakBlock* block = m_blocks.head(); block; block = next) {
- next = block->next();
-
- // If a block is completely empty, a new sweep won't have any effect.
- if (!block->sweepResult().isNull() && block->sweepResult().blockIsFree)
- continue;
-
- block->takeSweepResult(); // Force a new sweep by discarding the last sweep.
+ for (WeakBlock* block = m_blocks.head(); block; block = block->next())
block->sweep();
- }
-}
-
-void WeakSet::shrink()
-{
- WeakBlock* next;
- for (WeakBlock* block = m_blocks.head(); block; block = next) {
- next = block->next();
- if (!block->sweepResult().isNull() && block->sweepResult().blockIsFree)
- removeAllocator(block);
- }
-}
-
-void WeakSet::resetAllocator()
-{
- m_allocator = 0;
- m_nextAllocator = m_blocks.head();
+ resetAllocator();
}
WeakBlock::FreeCell* WeakSet::findAllocator()
WeakBlock* block = m_nextAllocator;
m_nextAllocator = m_nextAllocator->next();
- block->sweep();
WeakBlock::SweepResult sweepResult = block->takeSweepResult();
if (sweepResult.freeList)
return sweepResult.freeList;
WeakBlock::FreeCell* WeakSet::addAllocator()
{
- WeakBlock* block = WeakBlock::create();
- m_heap->didAllocate(WeakBlock::blockSize);
+ WeakBlock* block = WeakBlock::create(heap()->blockAllocator().allocate<WeakBlock>());
+ heap()->didAllocate(WeakBlock::blockSize);
m_blocks.append(block);
WeakBlock::SweepResult sweepResult = block->takeSweepResult();
ASSERT(!sweepResult.isNull() && sweepResult.freeList);
void WeakSet::removeAllocator(WeakBlock* block)
{
m_blocks.remove(block);
- WeakBlock::destroy(block);
+ heap()->blockAllocator().deallocate(WeakBlock::destroy(block));
}
} // namespace JSC