summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/Heap.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
commit284837daa07b29d6a63a748544a90b1f5842ac5c (patch)
treeecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/JavaScriptCore/heap/Heap.cpp
parent2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff)
downloadqtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/JavaScriptCore/heap/Heap.cpp')
-rw-r--r--Source/JavaScriptCore/heap/Heap.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/heap/Heap.cpp b/Source/JavaScriptCore/heap/Heap.cpp
index 669178804..4ab8ccb31 100644
--- a/Source/JavaScriptCore/heap/Heap.cpp
+++ b/Source/JavaScriptCore/heap/Heap.cpp
@@ -753,6 +753,9 @@ void Heap::collect(SweepToggle sweepToggle)
m_objectSpace.resetAllocators();
}
+ if (Options::useZombieMode())
+ zombifyDeadObjects();
+
size_t currentHeapSize = size();
if (fullGC) {
m_sizeAfterLastCollect = currentHeapSize;
@@ -844,4 +847,49 @@ void Heap::didStartVMShutdown()
lastChanceToFinalize();
}
+class ZombifyCellFunctor : public MarkedBlock::VoidFunctor {
+public:
+ ZombifyCellFunctor(size_t cellSize)
+ : m_cellSize(cellSize)
+ {
+ }
+
+ void operator()(JSCell* cell)
+ {
+ if (Options::zombiesAreImmortal())
+ MarkedBlock::blockFor(cell)->setMarked(cell);
+
+ void** current = reinterpret_cast<void**>(cell);
+
+ // We want to maintain zapped-ness because that's how we know if we've called
+ // the destructor.
+ if (cell->isZapped())
+ current++;
+
+ void* limit = static_cast<void*>(reinterpret_cast<char*>(cell) + m_cellSize);
+ for (; current < limit; current++)
+ *current = reinterpret_cast<void*>(0xbbadbeef);
+ }
+
+private:
+ size_t m_cellSize;
+};
+
+class ZombifyBlockFunctor : public MarkedBlock::VoidFunctor {
+public:
+ void operator()(MarkedBlock* block)
+ {
+ ZombifyCellFunctor functor(block->cellSize());
+ block->forEachDeadCell(functor);
+ }
+};
+
+void Heap::zombifyDeadObjects()
+{
+ m_objectSpace.sweep();
+
+ ZombifyBlockFunctor functor;
+ m_objectSpace.forEachBlock(functor);
+}
+
} // namespace JSC