Changeset 91039 in webkit for trunk/Source/JavaScriptCore/heap/NewSpace.h
- Timestamp:
- Jul 14, 2011, 6:40:25 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/heap/NewSpace.h
r89077 r91039 51 51 SizeClass(); 52 52 void resetAllocator(); 53 53 void canonicalizeBlock(); 54 55 MarkedBlock::FreeCell* firstFreeCell; 56 MarkedBlock* currentBlock; 54 57 MarkedBlock* nextBlock; 55 58 DoublyLinkedList<MarkedBlock> blockList; … … 65 68 void addBlock(SizeClass&, MarkedBlock*); 66 69 void removeBlock(MarkedBlock*); 70 71 void canonicalizeBlocks(); 67 72 68 73 size_t waterMark(); … … 116 121 inline void* NewSpace::allocate(SizeClass& sizeClass) 117 122 { 118 for (MarkedBlock*& block = sizeClass.nextBlock ; block; block = block->next()) { 119 if (void* result = block->allocate()) 120 return result; 121 122 m_waterMark += block->capacity(); 123 } 124 125 return 0; 123 MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell; 124 if (!firstFreeCell) { 125 // There are two possibilities for why we got here: 126 // 1) We've exhausted the allocation cache for currentBlock, in which case 127 // currentBlock == nextBlock, and we know that there is no reason to 128 // repeat a lazy sweep of nextBlock because we won't find anything. 129 // 2) Allocation caches have been cleared, in which case nextBlock may 130 // have (and most likely does have) free cells, so we almost certainly 131 // should do a lazySweep for nextBlock. This also implies that 132 // currentBlock == 0. 133 134 if (sizeClass.currentBlock) { 135 ASSERT(sizeClass.currentBlock == sizeClass.nextBlock); 136 m_waterMark += sizeClass.nextBlock->capacity(); 137 sizeClass.nextBlock = sizeClass.nextBlock->next(); 138 sizeClass.currentBlock = 0; 139 } 140 141 for (MarkedBlock*& block = sizeClass.nextBlock ; block; block = block->next()) { 142 firstFreeCell = block->lazySweep(); 143 if (firstFreeCell) { 144 sizeClass.firstFreeCell = firstFreeCell; 145 sizeClass.currentBlock = block; 146 break; 147 } 148 149 m_waterMark += block->capacity(); 150 } 151 152 if (!firstFreeCell) 153 return 0; 154 } 155 156 ASSERT(firstFreeCell); 157 158 sizeClass.firstFreeCell = firstFreeCell->next; 159 return firstFreeCell; 126 160 } 127 161 … … 156 190 157 191 inline NewSpace::SizeClass::SizeClass() 158 : nextBlock(0) 192 : firstFreeCell(0) 193 , currentBlock(0) 194 , nextBlock(0) 159 195 , cellSize(0) 160 196 { … … 165 201 nextBlock = blockList.head(); 166 202 } 203 204 inline void NewSpace::SizeClass::canonicalizeBlock() 205 { 206 if (currentBlock) { 207 currentBlock->canonicalizeBlock(firstFreeCell); 208 firstFreeCell = 0; 209 } 210 211 ASSERT(!firstFreeCell); 212 213 currentBlock = 0; 214 firstFreeCell = 0; 215 } 167 216 168 217 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.