[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
ggaren at apple.com
ggaren at apple.com
Mon Feb 21 00:22:04 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit f1b74c88db7c8f3075611e967bbf3d6170c7485c
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Jan 30 06:23:13 2011 +0000
2011-01-29 Geoffrey Garen <ggaren at apple.com>
Reviewed by Cameron Zwarich.
Simplified Heap iteration
https://bugs.webkit.org/show_bug.cgi?id=53393
* runtime/CollectorHeapIterator.h:
(JSC::CollectorHeapIterator::isValid):
(JSC::CollectorHeapIterator::isLive):
(JSC::CollectorHeapIterator::advance): Removed "max" argument to
advance because it's a constant.
(JSC::LiveObjectIterator::LiveObjectIterator):
(JSC::LiveObjectIterator::operator++):
(JSC::DeadObjectIterator::DeadObjectIterator):
(JSC::DeadObjectIterator::operator++):
(JSC::ObjectIterator::ObjectIterator):
(JSC::ObjectIterator::operator++): Factored out common checks into
two helper functions -- isValid() for "Am I past the end?" and isLive()
for "Is the cell I'm pointing to live?".
* runtime/MarkedSpace.cpp:
(JSC::MarkedSpace::freeBlock):
(JSC::MarkedSpace::sweep): Always sweep from the beginning of the heap
to the end, to avoid making sweep subtly reliant on internal Heap state.
(JSC::MarkedSpace::primaryHeapBegin):
(JSC::MarkedSpace::primaryHeapEnd): Always be explicit about where
iteration begins.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 29a475c..9d8b438 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -2,6 +2,35 @@
Reviewed by Cameron Zwarich.
+ Simplified Heap iteration
+ https://bugs.webkit.org/show_bug.cgi?id=53393
+
+ * runtime/CollectorHeapIterator.h:
+ (JSC::CollectorHeapIterator::isValid):
+ (JSC::CollectorHeapIterator::isLive):
+ (JSC::CollectorHeapIterator::advance): Removed "max" argument to
+ advance because it's a constant.
+ (JSC::LiveObjectIterator::LiveObjectIterator):
+ (JSC::LiveObjectIterator::operator++):
+ (JSC::DeadObjectIterator::DeadObjectIterator):
+ (JSC::DeadObjectIterator::operator++):
+ (JSC::ObjectIterator::ObjectIterator):
+ (JSC::ObjectIterator::operator++): Factored out common checks into
+ two helper functions -- isValid() for "Am I past the end?" and isLive()
+ for "Is the cell I'm pointing to live?".
+
+ * runtime/MarkedSpace.cpp:
+ (JSC::MarkedSpace::freeBlock):
+ (JSC::MarkedSpace::sweep): Always sweep from the beginning of the heap
+ to the end, to avoid making sweep subtly reliant on internal Heap state.
+ (JSC::MarkedSpace::primaryHeapBegin):
+ (JSC::MarkedSpace::primaryHeapEnd): Always be explicit about where
+ iteration begins.
+
+2011-01-29 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Cameron Zwarich.
+
Simplified heap destruction
https://bugs.webkit.org/show_bug.cgi?id=53392
diff --git a/Source/JavaScriptCore/runtime/CollectorHeapIterator.h b/Source/JavaScriptCore/runtime/CollectorHeapIterator.h
index 7229d77..0801727 100644
--- a/Source/JavaScriptCore/runtime/CollectorHeapIterator.h
+++ b/Source/JavaScriptCore/runtime/CollectorHeapIterator.h
@@ -38,7 +38,9 @@ namespace JSC {
protected:
CollectorHeapIterator(CollectorHeap&, size_t startBlock, size_t startCell);
- void advance(size_t max);
+ void advance();
+ bool isValid();
+ bool isLive();
CollectorHeap& m_heap;
size_t m_block;
@@ -75,6 +77,18 @@ namespace JSC {
return m_block != other.m_block || m_cell != other.m_cell;
}
+ inline bool CollectorHeapIterator::isValid()
+ {
+ return m_block < m_heap.usedBlocks;
+ }
+
+ inline bool CollectorHeapIterator::isLive()
+ {
+ return m_block < m_heap.nextBlock
+ || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell)
+ || (m_block < m_heap.usedBlocks && m_heap.collectorBlock(m_block)->marked.get(m_cell));
+ }
+
inline JSCell* CollectorHeapIterator::operator*() const
{
return reinterpret_cast<JSCell*>(&m_heap.collectorBlock(m_block)->cells[m_cell]);
@@ -82,56 +96,55 @@ namespace JSC {
// Iterators advance up to the next-to-last -- and not the last -- cell in a
// block, since the last cell is a dummy sentinel.
- inline void CollectorHeapIterator::advance(size_t max)
+ inline void CollectorHeapIterator::advance()
{
++m_cell;
- if (m_cell == max) {
+ if (m_cell == HeapConstants::cellsPerBlock - 1) {
m_cell = 0;
++m_block;
}
}
inline LiveObjectIterator::LiveObjectIterator(CollectorHeap& heap, size_t startBlock, size_t startCell)
- : CollectorHeapIterator(heap, startBlock, startCell - 1)
+ : CollectorHeapIterator(heap, startBlock, startCell)
{
- ++(*this);
+ if (isValid() && !isLive())
+ ++(*this);
}
inline LiveObjectIterator& LiveObjectIterator::operator++()
{
- advance(HeapConstants::cellsPerBlock - 1);
- if (m_block < m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell))
- return *this;
-
- while (m_block < m_heap.usedBlocks && !m_heap.collectorBlock(m_block)->marked.get(m_cell))
- advance(HeapConstants::cellsPerBlock - 1);
+ do {
+ advance();
+ } while (isValid() && !isLive());
return *this;
}
inline DeadObjectIterator::DeadObjectIterator(CollectorHeap& heap, size_t startBlock, size_t startCell)
- : CollectorHeapIterator(heap, startBlock, startCell - 1)
+ : CollectorHeapIterator(heap, startBlock, startCell)
{
- ++(*this);
+ if (isValid() && isLive())
+ ++(*this);
}
inline DeadObjectIterator& DeadObjectIterator::operator++()
{
do {
- advance(HeapConstants::cellsPerBlock - 1);
- ASSERT(m_block > m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell >= m_heap.nextCell));
- } while (m_block < m_heap.usedBlocks && m_heap.collectorBlock(m_block)->marked.get(m_cell));
+ advance();
+ } while (isValid() && isLive());
return *this;
}
inline ObjectIterator::ObjectIterator(CollectorHeap& heap, size_t startBlock, size_t startCell)
- : CollectorHeapIterator(heap, startBlock, startCell - 1)
+ : CollectorHeapIterator(heap, startBlock, startCell)
{
- ++(*this);
+ if (isValid())
+ ++(*this);
}
inline ObjectIterator& ObjectIterator::operator++()
{
- advance(HeapConstants::cellsPerBlock - 1);
+ advance();
return *this;
}
diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.cpp b/Source/JavaScriptCore/runtime/MarkedSpace.cpp
index 9cf8dea..e814d84 100644
--- a/Source/JavaScriptCore/runtime/MarkedSpace.cpp
+++ b/Source/JavaScriptCore/runtime/MarkedSpace.cpp
@@ -91,8 +91,8 @@ NEVER_INLINE CollectorBlock* MarkedSpace::allocateBlock()
NEVER_INLINE void MarkedSpace::freeBlock(size_t block)
{
- ObjectIterator it(m_heap, block);
- ObjectIterator end(m_heap, block + 1);
+ ObjectIterator it(m_heap, block, 0);
+ ObjectIterator end(m_heap, block + 1, 0);
for ( ; it != end; ++it)
(*it)->~JSCell();
m_heap.blocks[block].deallocate();
@@ -251,8 +251,8 @@ void MarkedSpace::sweep()
Structure* dummyMarkableCellStructure = globalData()->dummyMarkableCellStructure.get();
#endif
- DeadObjectIterator it(m_heap, m_heap.nextBlock, m_heap.nextCell);
- DeadObjectIterator end(m_heap, m_heap.usedBlocks);
+ DeadObjectIterator it(m_heap, 0, 0);
+ DeadObjectIterator end(m_heap, m_heap.usedBlocks, 0);
for ( ; it != end; ++it) {
JSCell* cell = *it;
#if ENABLE(JSC_ZOMBIES)
@@ -300,12 +300,12 @@ void MarkedSpace::reset()
LiveObjectIterator MarkedSpace::primaryHeapBegin()
{
- return LiveObjectIterator(m_heap, 0);
+ return LiveObjectIterator(m_heap, 0, 0);
}
LiveObjectIterator MarkedSpace::primaryHeapEnd()
{
- return LiveObjectIterator(m_heap, m_heap.usedBlocks);
+ return LiveObjectIterator(m_heap, m_heap.usedBlocks, 0);
}
} // namespace JSC
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list