Commit 75736174 authored by ggaren@apple.com's avatar ggaren@apple.com

"GlobalHandle" HandleHeap (now WeakSet) allocations grow but do not shrink

https://bugs.webkit.org/show_bug.cgi?id=84740
<rdar://problem/9917638>

Reviewed by Gavin Barraclough.

Shrink!

* heap/Heap.cpp:
(JSC::Heap::destroy): Be more specific about what's shrinking, since we
can also shrink the WeakSet, but we don't do so here.

(JSC::Heap::collect): If we're going to shrink the heap, shrink the
WeakSet too. Otherwise, its footprint is permanent.

* heap/Heap.h:
(Heap): Removed shrink() as a public interface, since it's vague about
which parts of the heap it affects, and it's really an internal detail.

* heap/WeakSet.cpp:
(JSC::WeakSet::shrink): Nix any free blocks. We assume that sweep() has
already taken place, since that's the convention for shrink() in the heap.

* heap/WeakSet.h:
(WeakSet): New function!


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@115092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ceeb5dc8
2012-04-24 Geoffrey Garen <ggaren@apple.com>
"GlobalHandle" HandleHeap (now WeakSet) allocations grow but do not shrink
https://bugs.webkit.org/show_bug.cgi?id=84740
<rdar://problem/9917638>
Reviewed by Gavin Barraclough.
Shrink!
* heap/Heap.cpp:
(JSC::Heap::destroy): Be more specific about what's shrinking, since we
can also shrink the WeakSet, but we don't do so here.
(JSC::Heap::collect): If we're going to shrink the heap, shrink the
WeakSet too. Otherwise, its footprint is permanent.
* heap/Heap.h:
(Heap): Removed shrink() as a public interface, since it's vague about
which parts of the heap it affects, and it's really an internal detail.
* heap/WeakSet.cpp:
(JSC::WeakSet::shrink): Nix any free blocks. We assume that sweep() has
already taken place, since that's the convention for shrink() in the heap.
* heap/WeakSet.h:
(WeakSet): New function!
2012-04-24 Adam Klein <adamk@chromium.org>
Fix includes in StrongInlines.h and ScriptValue.h
......@@ -378,7 +378,7 @@ void Heap::destroy()
m_weakSet.finalizeAll();
m_globalData->smallStrings.finalizeSmallStrings();
shrink();
m_objectSpace.shrink();
m_storageSpace.destroy();
ASSERT(!size());
......@@ -850,7 +850,8 @@ void Heap::collect(SweepToggle sweepToggle)
SamplingRegion samplingRegion("Garbage Collection: Sweeping");
GCPHASE(Sweeping);
sweep();
shrink();
m_objectSpace.shrink();
m_weakSet.shrink();
}
// To avoid pathological GC churn in large heaps, we set the new allocation
......@@ -915,11 +916,6 @@ void Heap::freeBlocks(MarkedBlock* head)
m_objectSpace.freeBlocks(head);
}
void Heap::shrink()
{
m_objectSpace.shrink();
}
void Heap::releaseFreeBlocks()
{
while (true) {
......
......@@ -191,7 +191,6 @@ namespace JSC {
void harvestWeakReferences();
void finalizeUnconditionalFinalizers();
void shrink();
void releaseFreeBlocks();
void sweep();
......
......@@ -73,6 +73,17 @@ void WeakSet::sweep()
}
}
void WeakSet::shrink()
{
WeakBlock* next;
for (WeakBlock* block = static_cast<WeakBlock*>(m_blocks.head()); block; block = next) {
next = static_cast<WeakBlock*>(block->next());
if (!block->sweepResult().isNull() && block->sweepResult().blockIsFree)
removeAllocator(block);
}
}
void WeakSet::resetAllocator()
{
m_allocator = 0;
......
......@@ -48,6 +48,8 @@ public:
void sweep();
void resetAllocator();
void shrink();
private:
JS_EXPORT_PRIVATE WeakBlock::FreeCell* findAllocator();
WeakBlock::FreeCell* tryFindAllocator();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment