diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-25 15:09:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-25 15:09:11 +0200 |
commit | a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (patch) | |
tree | b7abd9f49ae1d4d2e426a5883bfccd42b8e2ee12 /Source/JavaScriptCore/heap/WeakSet.h | |
parent | 8d473cf9743f1d30a16a27114e93bd5af5648d23 (diff) | |
download | qtwebkit-a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd.tar.gz |
Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516)
Diffstat (limited to 'Source/JavaScriptCore/heap/WeakSet.h')
-rw-r--r-- | Source/JavaScriptCore/heap/WeakSet.h | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/Source/JavaScriptCore/heap/WeakSet.h b/Source/JavaScriptCore/heap/WeakSet.h index 0a683bd5f..be9844a64 100644 --- a/Source/JavaScriptCore/heap/WeakSet.h +++ b/Source/JavaScriptCore/heap/WeakSet.h @@ -35,20 +35,22 @@ class WeakImpl; class WeakSet { public: + static WeakImpl* allocate(JSValue, WeakHandleOwner* = 0, void* context = 0); + static void deallocate(WeakImpl*); + WeakSet(Heap*); - void finalizeAll(); ~WeakSet(); + void lastChanceToFinalize(); - static WeakImpl* allocate(JSValue, WeakHandleOwner* = 0, void* context = 0); - static void deallocate(WeakImpl*); + Heap* heap() const; - void visitLiveWeakImpls(HeapRootVisitor&); - void visitDeadWeakImpls(HeapRootVisitor&); + bool isEmpty() const; + void visit(HeapRootVisitor&); + void reap(); void sweep(); - void resetAllocator(); - void shrink(); + void resetAllocator(); private: JS_EXPORT_PRIVATE WeakBlock::FreeCell* findAllocator(); @@ -69,11 +71,61 @@ inline WeakSet::WeakSet(Heap* heap) { } +inline Heap* WeakSet::heap() const +{ + return m_heap; +} + +inline bool WeakSet::isEmpty() const +{ + for (WeakBlock* block = m_blocks.head(); block; block = block->next()) { + if (!block->isEmpty()) + return false; + } + + return true; +} + inline void WeakSet::deallocate(WeakImpl* weakImpl) { weakImpl->setState(WeakImpl::Deallocated); } +inline void WeakSet::lastChanceToFinalize() +{ + for (WeakBlock* block = m_blocks.head(); block; block = block->next()) + block->lastChanceToFinalize(); +} + +inline void WeakSet::visit(HeapRootVisitor& visitor) +{ + for (WeakBlock* block = m_blocks.head(); block; block = block->next()) + block->visit(visitor); +} + +inline void WeakSet::reap() +{ + for (WeakBlock* block = m_blocks.head(); block; block = block->next()) + block->reap(); +} + +inline void WeakSet::shrink() +{ + WeakBlock* next; + for (WeakBlock* block = m_blocks.head(); block; block = next) { + next = block->next(); + + if (block->isEmpty()) + removeAllocator(block); + } +} + +inline void WeakSet::resetAllocator() +{ + m_allocator = 0; + m_nextAllocator = m_blocks.head(); +} + } // namespace JSC #endif // WeakSet_h |