Changeset 133812 in webkit
- Timestamp:
- Nov 7, 2012, 3:34:30 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r133800 r133812 1 2012-11-07 Mark Hahnenberg <[email protected]> 2 3 WeakBlocks should be HeapBlocks 4 https://bugs.webkit.org/show_bug.cgi?id=101411 5 6 Reviewed by Oliver Hunt. 7 8 Currently WeakBlocks use fastMalloc memory. They are very similar to the other HeapBlocks, however, 9 so we should change them to being allocated with the BlockAllocator. 10 11 * heap/BlockAllocator.cpp: 12 (JSC::BlockAllocator::BlockAllocator): 13 * heap/BlockAllocator.h: Added a new RegionSet for WeakBlocks. 14 (JSC): 15 (BlockAllocator): 16 (JSC::WeakBlock): 17 * heap/Heap.h: Friended WeakSet to allow access to the BlockAllocator. 18 (Heap): 19 * heap/WeakBlock.cpp: 20 (JSC::WeakBlock::create): Refactored to use HeapBlocks rather than fastMalloc. 21 (JSC::WeakBlock::WeakBlock): 22 * heap/WeakBlock.h: Changed the WeakBlock size to 4 KB so that it divides evenly into the Region size. 23 (JSC): 24 (WeakBlock): 25 * heap/WeakSet.cpp: 26 (JSC::WeakSet::~WeakSet): 27 (JSC::WeakSet::addAllocator): 28 1 29 2012-11-07 Filip Pizlo <[email protected]> 2 30 -
trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp
r131619 r133812 29 29 #include "CopiedBlock.h" 30 30 #include "MarkedBlock.h" 31 #include "WeakBlock.h" 31 32 #include <wtf/CurrentTime.h> 32 33 … … 36 37 : m_copiedRegionSet(CopiedBlock::blockSize) 37 38 , m_markedRegionSet(MarkedBlock::blockSize) 39 , m_weakRegionSet(WeakBlock::blockSize) 38 40 , m_numberOfEmptyRegions(0) 39 41 , m_isCurrentlyAllocating(false) -
trunk/Source/JavaScriptCore/heap/BlockAllocator.h
r131321 r133812 40 40 class MarkedBlock; 41 41 class Region; 42 class WeakBlock; 42 43 43 44 // Simple allocator to reduce VM cost by holding onto blocks of memory for … … 185 186 RegionSet m_copiedRegionSet; 186 187 RegionSet m_markedRegionSet; 188 RegionSet m_weakRegionSet; 187 189 188 190 DoublyLinkedList<Region> m_emptyRegions; … … 312 314 313 315 template <> 316 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<WeakBlock>() 317 { 318 return m_weakRegionSet; 319 } 320 321 template <> 314 322 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<CopiedBlock> >() 315 323 { … … 321 329 { 322 330 return m_markedRegionSet; 331 } 332 333 template <> 334 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<WeakBlock> >() 335 { 336 return m_weakRegionSet; 323 337 } 324 338 -
trunk/Source/JavaScriptCore/heap/Heap.h
r133358 r133812 189 189 friend class IncrementalSweeper; 190 190 friend class HeapStatistics; 191 friend class WeakSet; 191 192 template<typename T> friend void* allocateCell(Heap&); 192 193 template<typename T> friend void* allocateCell(Heap&, size_t); -
trunk/Source/JavaScriptCore/heap/WeakBlock.cpp
r133358 r133812 35 35 namespace JSC { 36 36 37 WeakBlock* WeakBlock::create( )37 WeakBlock* WeakBlock::create(DeadBlock* block) 38 38 { 39 void* allocation = fastMalloc(blockSize);40 return new (NotNull, allocation) WeakBlock;39 Region* region = block->region(); 40 return new (NotNull, block) WeakBlock(region); 41 41 } 42 42 43 void WeakBlock::destroy(WeakBlock* block) 44 { 45 fastFree(block); 46 } 47 48 WeakBlock::WeakBlock() 43 WeakBlock::WeakBlock(Region* region) 44 : HeapBlock<WeakBlock>(region) 49 45 { 50 46 for (size_t i = 0; i < weakImplCount(); ++i) { -
trunk/Source/JavaScriptCore/heap/WeakBlock.h
r118616 r133812 35 35 namespace JSC { 36 36 37 class DeadBlock; 37 38 class HeapRootVisitor; 38 39 class JSValue; 39 40 class WeakHandleOwner; 40 41 41 class WeakBlock : public DoublyLinkedListNode<WeakBlock> {42 class WeakBlock : public HeapBlock<WeakBlock> { 42 43 public: 43 44 friend class WTF::DoublyLinkedListNode<WeakBlock>; 44 static const size_t blockSize = 3* KB; // 5% of MarkedBlock size45 static const size_t blockSize = 4 * KB; // 5% of MarkedBlock size 45 46 46 47 struct FreeCell { … … 56 57 }; 57 58 58 static WeakBlock* create(); 59 static void destroy(WeakBlock*); 59 static WeakBlock* create(DeadBlock*); 60 60 61 61 static WeakImpl* asWeakImpl(FreeCell*); … … 74 74 static FreeCell* asFreeCell(WeakImpl*); 75 75 76 WeakBlock( );76 WeakBlock(Region*); 77 77 WeakImpl* firstWeakImpl(); 78 78 void finalize(WeakImpl*); … … 81 81 void addToFreeList(FreeCell**, WeakImpl*); 82 82 83 WeakBlock* m_prev;84 WeakBlock* m_next;85 83 SweepResult m_sweepResult; 86 84 }; -
trunk/Source/JavaScriptCore/heap/WeakSet.cpp
r127338 r133812 37 37 for (WeakBlock* block = m_blocks.head(); block; block = next) { 38 38 next = block->next(); 39 WeakBlock::destroy(block);39 heap()->blockAllocator().deallocate(WeakBlock::destroy(block)); 40 40 } 41 41 m_blocks.clear(); … … 74 74 WeakBlock::FreeCell* WeakSet::addAllocator() 75 75 { 76 WeakBlock* block = WeakBlock::create( );76 WeakBlock* block = WeakBlock::create(heap()->blockAllocator().allocate<WeakBlock>()); 77 77 heap()->didAllocate(WeakBlock::blockSize); 78 78 m_blocks.append(block);
Note:
See TracChangeset
for help on using the changeset viewer.