summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/WeakSet.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/heap/WeakSet.cpp
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/heap/WeakSet.cpp')
-rw-r--r--Source/JavaScriptCore/heap/WeakSet.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/Source/JavaScriptCore/heap/WeakSet.cpp b/Source/JavaScriptCore/heap/WeakSet.cpp
index e62e66eae..8624993ca 100644
--- a/Source/JavaScriptCore/heap/WeakSet.cpp
+++ b/Source/JavaScriptCore/heap/WeakSet.cpp
@@ -27,24 +27,37 @@
#include "WeakSet.h"
#include "Heap.h"
+#include "JSCInlines.h"
#include "VM.h"
namespace JSC {
WeakSet::~WeakSet()
{
+ Heap& heap = *this->heap();
WeakBlock* next = 0;
for (WeakBlock* block = m_blocks.head(); block; block = next) {
next = block->next();
- heap()->blockAllocator().deallocate(WeakBlock::destroy(block));
+ WeakBlock::destroy(heap, block);
}
m_blocks.clear();
}
void WeakSet::sweep()
{
- for (WeakBlock* block = m_blocks.head(); block; block = block->next())
+ for (WeakBlock* block = m_blocks.head(); block;) {
+ WeakBlock* nextBlock = block->next();
block->sweep();
+ if (block->isLogicallyEmptyButNotFree()) {
+ // If this WeakBlock is logically empty, but still has Weaks pointing into it,
+ // we can't destroy it just yet. Detach it from the WeakSet and hand ownership
+ // to the Heap so we don't pin down the entire 64kB MarkedBlock.
+ m_blocks.remove(block);
+ heap()->addLogicallyEmptyWeakBlock(block);
+ block->disconnectMarkedBlock();
+ }
+ block = nextBlock;
+ }
resetAllocator();
}
@@ -73,7 +86,7 @@ WeakBlock::FreeCell* WeakSet::tryFindAllocator()
WeakBlock::FreeCell* WeakSet::addAllocator()
{
- WeakBlock* block = WeakBlock::create(heap()->blockAllocator().allocate<WeakBlock>());
+ WeakBlock* block = WeakBlock::create(*heap(), m_markedBlock);
heap()->didAllocate(WeakBlock::blockSize);
m_blocks.append(block);
WeakBlock::SweepResult sweepResult = block->takeSweepResult();
@@ -84,7 +97,7 @@ WeakBlock::FreeCell* WeakSet::addAllocator()
void WeakSet::removeAllocator(WeakBlock* block)
{
m_blocks.remove(block);
- heap()->blockAllocator().deallocate(WeakBlock::destroy(block));
+ WeakBlock::destroy(*heap(), block);
}
} // namespace JSC