Changeset 119364 in webkit
- Timestamp:
- Jun 3, 2012 2:16:55 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r119343 r119364 1 2012-06-02 Geoffrey Garen <ggaren@apple.com> 2 3 Weak pointer finalization should be lazy 4 https://bugs.webkit.org/show_bug.cgi?id=87599 5 6 Reviewed by Sam Weinig. 7 8 This time for sure! 9 10 * heap/Heap.cpp: 11 (JSC::Heap::collect): Don't sweep eagerly -- we'll sweep lazily instead. 12 13 * heap/MarkedBlock.cpp: 14 (JSC::MarkedBlock::sweep): Sweep our weak set before we sweep our other 15 destructors -- this is our last chance to run weak set finalizers before 16 we recycle our memory. 17 18 * heap/MarkedBlock.h: 19 (JSC::MarkedBlock::resetAllocator): 20 * heap/MarkedSpace.cpp: 21 (JSC::MarkedSpace::resetAllocators): 22 * heap/MarkedSpace.h: 23 (JSC::MarkedSpace::resetAllocators): Don't force allocator reset anymore. 24 It will happen automatically when a weak set is swept. It's simpler to 25 have only one canonical way for this to happen, and it wasn't buying 26 us anything to do it eagerly. 27 28 * heap/WeakBlock.cpp: 29 (JSC::WeakBlock::sweep): Don't short-circuit a sweep unless we know 30 the sweep would be a no-op. If even one finalizer is pending, we need to 31 run it, since we won't get another chance. 32 33 * heap/WeakSet.cpp: 34 (JSC::WeakSet::sweep): This loop can be simpler now that 35 WeakBlock::sweep() does what we mean. 36 37 Reset our allocator after a sweep because this is the optimal time to 38 start trying to recycle old weak pointers. 39 40 (JSC::WeakSet::tryFindAllocator): Don't sweep when searching for an 41 allocator because we've swept already, and forcing a new sweep would be 42 wasteful. 43 44 * heap/WeakSet.h: 45 (JSC::WeakSet::shrink): Be sure to reset our allocator after a shrink 46 because the shrink may have removed the block the allocator was going to 47 allocate out of. 48 1 49 2012-06-02 Filip Pizlo <fpizlo@apple.com> 2 50 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r119028 r119364 689 689 690 690 { 691 GCPHASE(FinalizeWeakHandles); 692 m_objectSpace.sweepWeakSets(); 691 GCPHASE(FinalizeSmallString); 693 692 m_globalData->smallStrings.finalizeSmallStrings(); 694 693 } -
trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp
r118901 r119364 115 115 HEAP_LOG_BLOCK_STATE_TRANSITION(this); 116 116 117 m_weakSet.sweep(); 118 117 119 if (sweepMode == SweepOnly && !m_cellsNeedDestruction) 118 120 return FreeList(); -
trunk/Source/JavaScriptCore/heap/MarkedBlock.h
r119028 r119364 130 130 131 131 void shrink(); 132 void resetAllocator();133 132 134 133 void visitWeakSet(HeapRootVisitor&); … … 273 272 { 274 273 m_weakSet.shrink(); 275 }276 277 inline void MarkedBlock::resetAllocator()278 {279 m_weakSet.resetAllocator();280 274 } 281 275 -
trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp
r118901 r119364 113 113 } 114 114 115 struct ResetAllocator : MarkedBlock::VoidFunctor {116 void operator()(MarkedBlock* block) { block->resetAllocator(); }117 };118 119 115 void MarkedSpace::resetAllocators() 120 116 { … … 128 124 destructorAllocatorFor(cellSize).reset(); 129 125 } 130 131 forEachBlock<ResetAllocator>();132 126 } 133 127 … … 141 135 { 142 136 forEachBlock<ReapWeakSet>(); 143 }144 145 void MarkedSpace::sweepWeakSets()146 {147 forEachBlock<SweepWeakSet>();148 137 } 149 138 -
trunk/Source/JavaScriptCore/heap/MarkedSpace.h
r118901 r119364 86 86 void visitWeakSets(HeapRootVisitor&); 87 87 void reapWeakSets(); 88 void sweepWeakSets();89 88 90 89 MarkedBlockSet& blocks() { return m_blocks; } -
trunk/Source/JavaScriptCore/heap/WeakBlock.cpp
r118269 r119364 70 70 void WeakBlock::sweep() 71 71 { 72 if (!m_sweepResult.isNull()) 72 // If a block is completely empty, a sweep won't have any effect. 73 if (isEmpty()) 73 74 return; 74 75 -
trunk/Source/JavaScriptCore/heap/WeakSet.cpp
r118416 r119364 43 43 void WeakSet::sweep() 44 44 { 45 WeakBlock* next; 46 for (WeakBlock* block = m_blocks.head(); block; block = next) { 47 next = block->next(); 45 for (WeakBlock* block = m_blocks.head(); block; block = block->next()) 46 block->sweep(); 48 47 49 // If a block is completely empty, a new sweep won't have any effect. 50 if (block->isEmpty()) 51 continue; 52 53 block->takeSweepResult(); // Force a new sweep by discarding the last sweep. 54 block->sweep(); 55 } 48 resetAllocator(); 56 49 } 57 50 … … 70 63 m_nextAllocator = m_nextAllocator->next(); 71 64 72 block->sweep();73 65 WeakBlock::SweepResult sweepResult = block->takeSweepResult(); 74 66 if (sweepResult.freeList) -
trunk/Source/JavaScriptCore/heap/WeakSet.h
r118416 r119364 119 119 removeAllocator(block); 120 120 } 121 122 resetAllocator(); 121 123 } 122 124
Note: See TracChangeset
for help on using the changeset viewer.