Title: [119878] trunk/Source/_javascript_Core
- Revision
- 119878
- Author
- [email protected]
- Date
- 2012-06-08 16:57:58 -0700 (Fri, 08 Jun 2012)
Log Message
Unreviewed, rolling back in part1 of r118646.
This patch includes everything necessary for lazy finalization, but
keeps eager finalization enabled for the time being.
Weak pointer finalization should be lazy
https://bugs.webkit.org/show_bug.cgi?id=87599
Reviewed by Sam Weinig.
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::resetAllocator):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::resetAllocators):
* heap/MarkedSpace.h:
(JSC::MarkedSpace::resetAllocators): Don't force allocator reset anymore.
It will happen automatically when a weak set is swept. It's simpler to
have only one canonical way for this to happen, and it wasn't buying
us anything to do it eagerly.
* heap/WeakBlock.cpp:
(JSC::WeakBlock::sweep): Don't short-circuit a sweep unless we know
the sweep would be a no-op. If even one finalizer is pending, we need to
run it, since we won't get another chance.
* heap/WeakSet.cpp:
(JSC::WeakSet::sweep): This loop can be simpler now that
WeakBlock::sweep() does what we mean.
Reset our allocator after a sweep because this is the optimal time to
start trying to recycle old weak pointers.
(JSC::WeakSet::tryFindAllocator): Don't sweep when searching for an
allocator because we've swept already, and forcing a new sweep would be
wasteful.
* heap/WeakSet.h:
(JSC::WeakSet::shrink): Be sure to reset our allocator after a shrink
because the shrink may have removed the block the allocator was going to
allocate out of.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (119877 => 119878)
--- trunk/Source/_javascript_Core/ChangeLog 2012-06-08 23:54:16 UTC (rev 119877)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-06-08 23:57:58 UTC (rev 119878)
@@ -1,3 +1,42 @@
+2012-06-02 Geoffrey Garen <[email protected]>
+
+ Unreviewed, rolling back in part1 of r118646.
+
+ This patch includes everything necessary for lazy finalization, but
+ keeps eager finalization enabled for the time being.
+
+ Weak pointer finalization should be lazy
+ https://bugs.webkit.org/show_bug.cgi?id=87599
+
+ Reviewed by Sam Weinig.
+
+ * heap/MarkedBlock.cpp:
+ * heap/MarkedBlock.h:
+ (JSC::MarkedBlock::resetAllocator):
+ * heap/MarkedSpace.cpp:
+ (JSC::MarkedSpace::resetAllocators):
+ * heap/MarkedSpace.h:
+ (JSC::MarkedSpace::resetAllocators): Don't force allocator reset anymore.
+ It will happen automatically when a weak set is swept. It's simpler to
+ have only one canonical way for this to happen, and it wasn't buying
+ us anything to do it eagerly.
+ * heap/WeakBlock.cpp:
+ (JSC::WeakBlock::sweep): Don't short-circuit a sweep unless we know
+ the sweep would be a no-op. If even one finalizer is pending, we need to
+ run it, since we won't get another chance.
+ * heap/WeakSet.cpp:
+ (JSC::WeakSet::sweep): This loop can be simpler now that
+ WeakBlock::sweep() does what we mean.
+ Reset our allocator after a sweep because this is the optimal time to
+ start trying to recycle old weak pointers.
+ (JSC::WeakSet::tryFindAllocator): Don't sweep when searching for an
+ allocator because we've swept already, and forcing a new sweep would be
+ wasteful.
+ * heap/WeakSet.h:
+ (JSC::WeakSet::shrink): Be sure to reset our allocator after a shrink
+ because the shrink may have removed the block the allocator was going to
+ allocate out of.
+
2012-06-08 Gavin Barraclough <[email protected]>
Unreviewed roll out r119795.
Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.h (119877 => 119878)
--- trunk/Source/_javascript_Core/heap/MarkedBlock.h 2012-06-08 23:54:16 UTC (rev 119877)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.h 2012-06-08 23:57:58 UTC (rev 119878)
@@ -129,7 +129,6 @@
FreeList sweep(SweepMode = SweepOnly);
void shrink();
- void resetAllocator();
void visitWeakSet(HeapRootVisitor&);
void reapWeakSet();
@@ -274,11 +273,6 @@
m_weakSet.shrink();
}
- inline void MarkedBlock::resetAllocator()
- {
- m_weakSet.resetAllocator();
- }
-
inline void MarkedBlock::visitWeakSet(HeapRootVisitor& heapRootVisitor)
{
m_weakSet.visit(heapRootVisitor);
Modified: trunk/Source/_javascript_Core/heap/MarkedSpace.cpp (119877 => 119878)
--- trunk/Source/_javascript_Core/heap/MarkedSpace.cpp 2012-06-08 23:54:16 UTC (rev 119877)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.cpp 2012-06-08 23:57:58 UTC (rev 119878)
@@ -112,10 +112,6 @@
forEachBlock<LastChanceToFinalize>();
}
-struct ResetAllocator : MarkedBlock::VoidFunctor {
- void operator()(MarkedBlock* block) { block->resetAllocator(); }
-};
-
void MarkedSpace::resetAllocators()
{
for (size_t cellSize = preciseStep; cellSize <= preciseCutoff; cellSize += preciseStep) {
@@ -127,8 +123,6 @@
allocatorFor(cellSize).reset();
destructorAllocatorFor(cellSize).reset();
}
-
- forEachBlock<ResetAllocator>();
}
void MarkedSpace::visitWeakSets(HeapRootVisitor& heapRootVisitor)
Modified: trunk/Source/_javascript_Core/heap/WeakBlock.cpp (119877 => 119878)
--- trunk/Source/_javascript_Core/heap/WeakBlock.cpp 2012-06-08 23:54:16 UTC (rev 119877)
+++ trunk/Source/_javascript_Core/heap/WeakBlock.cpp 2012-06-08 23:57:58 UTC (rev 119878)
@@ -69,7 +69,8 @@
void WeakBlock::sweep()
{
- if (!m_sweepResult.isNull())
+ // If a block is completely empty, a sweep won't have any effect.
+ if (isEmpty())
return;
SweepResult sweepResult;
Modified: trunk/Source/_javascript_Core/heap/WeakSet.cpp (119877 => 119878)
--- trunk/Source/_javascript_Core/heap/WeakSet.cpp 2012-06-08 23:54:16 UTC (rev 119877)
+++ trunk/Source/_javascript_Core/heap/WeakSet.cpp 2012-06-08 23:57:58 UTC (rev 119878)
@@ -42,17 +42,10 @@
void WeakSet::sweep()
{
- WeakBlock* next;
- for (WeakBlock* block = m_blocks.head(); block; block = next) {
- next = block->next();
-
- // If a block is completely empty, a new sweep won't have any effect.
- if (block->isEmpty())
- continue;
-
- block->takeSweepResult(); // Force a new sweep by discarding the last sweep.
+ for (WeakBlock* block = m_blocks.head(); block; block = block->next())
block->sweep();
- }
+
+ resetAllocator();
}
WeakBlock::FreeCell* WeakSet::findAllocator()
@@ -69,7 +62,6 @@
WeakBlock* block = m_nextAllocator;
m_nextAllocator = m_nextAllocator->next();
- block->sweep();
WeakBlock::SweepResult sweepResult = block->takeSweepResult();
if (sweepResult.freeList)
return sweepResult.freeList;
Modified: trunk/Source/_javascript_Core/heap/WeakSet.h (119877 => 119878)
--- trunk/Source/_javascript_Core/heap/WeakSet.h 2012-06-08 23:54:16 UTC (rev 119877)
+++ trunk/Source/_javascript_Core/heap/WeakSet.h 2012-06-08 23:57:58 UTC (rev 119878)
@@ -118,6 +118,8 @@
if (block->isEmpty())
removeAllocator(block);
}
+
+ resetAllocator();
}
inline void WeakSet::resetAllocator()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes