Changeset 78605 in webkit
- Timestamp:
- Feb 15, 2011 1:03:16 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r78597 r78605 1 2011-02-15 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Moved MarkedBlock data members to the head of the block 6 https://bugs.webkit.org/show_bug.cgi?id=54482 7 8 This allows for a variable-sized tail, to accommodate oversized blocks. 9 10 SunSpider reports no change. 11 12 * runtime/JSCell.h: 13 (JSC::JSCell::MarkedBlock::allocate): 14 * runtime/MarkedBlock.cpp: 15 (JSC::MarkedBlock::destroy): 16 (JSC::MarkedBlock::MarkedBlock): 17 (JSC::MarkedBlock::sweep): 18 * runtime/MarkedBlock.h: Added missing element to the CELLS_PER_BLOCK 19 calculation. This kind of error is why we want to migrate to the system 20 described below. 21 22 (JSC::roundUpToMultipleOf): 23 (JSC::MarkedBlock::firstCell): 24 (JSC::MarkedBlock::cells): 25 (JSC::MarkedBlock::cellNumber): Use subtraction instead of masking to 26 calculate cell number. The mask is no longer correct because the first 27 cell is not at the head of the block. 28 29 (JSC::MarkedBlock::forEach): Replaced m_cells data member with a cells() 30 accessor. We want to use sizeof(MarkedBlock) to calculate the size of the 31 block header, so we can't have an explicit data member to represent the block tail. 32 33 Also replaced iteration from zero with iteration from startCell(), since 34 the first N cells are now occupied by the header. 35 36 * runtime/MarkedSpace.cpp: 37 (JSC::MarkedSpace::MarkedSpace): 38 (JSC::MarkedSpace::reset): Replaced iteration from zero as above. 39 1 40 2011-02-15 Chris Rogers <crogers@google.com> 2 41 -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r78501 r78605 408 408 ASSERT(nextCell < CELLS_PER_BLOCK); 409 409 if (!m_marks.testAndSet(nextCell)) { // Always false for the last cell in the block 410 JSCell* cell = reinterpret_cast<JSCell*>(& m_cells[nextCell++]);410 JSCell* cell = reinterpret_cast<JSCell*>(&cells()[nextCell++]); 411 411 cell->~JSCell(); 412 412 return cell; … … 414 414 nextCell = m_marks.nextPossiblyUnset(nextCell); 415 415 } while (nextCell != CELLS_PER_BLOCK); 416 417 nextCell = 0;416 417 nextCell = firstCell(); 418 418 return 0; 419 419 } -
trunk/Source/JavaScriptCore/runtime/MarkedBlock.cpp
r78501 r78605 41 41 void MarkedBlock::destroy(MarkedBlock* block) 42 42 { 43 for (size_t i = 0; i < CELLS_PER_BLOCK; ++i)44 reinterpret_cast<JSCell*>(&block-> m_cells[i])->~JSCell();43 for (size_t i = block->firstCell(); i < CELLS_PER_BLOCK; ++i) 44 reinterpret_cast<JSCell*>(&block->cells()[i])->~JSCell(); 45 45 block->m_allocation.deallocate(); 46 46 } … … 53 53 54 54 Structure* dummyMarkableCellStructure = globalData->dummyMarkableCellStructure.get(); 55 for (size_t i = 0; i < CELLS_PER_BLOCK; ++i)56 new (& m_cells[i]) JSCell(dummyMarkableCellStructure);55 for (size_t i = firstCell(); i < CELLS_PER_BLOCK; ++i) 56 new (&cells()[i]) JSCell(dummyMarkableCellStructure); 57 57 } 58 58 … … 63 63 #endif 64 64 65 for (size_t i = 0; i < CELLS_PER_BLOCK; ++i) {65 for (size_t i = firstCell(); i < CELLS_PER_BLOCK; ++i) { 66 66 if (m_marks.get(i)) 67 67 continue; 68 68 69 JSCell* cell = reinterpret_cast<JSCell*>(& m_cells[i]);69 JSCell* cell = reinterpret_cast<JSCell*>(&cells()[i]); 70 70 #if ENABLE(JSC_ZOMBIES) 71 71 if (!cell->isZombie()) { -
trunk/Source/JavaScriptCore/runtime/MarkedBlock.h
r78501 r78605 35 35 class JSGlobalData; 36 36 37 // Efficient implementation that takes advantage of powers of two. 38 template<size_t divisor> inline size_t roundUpToMultipleOf(size_t x) 39 { 40 COMPILE_ASSERT(divisor && !(divisor & (divisor - 1)), divisor_is_a_power_of_two); 41 42 size_t remainderMask = divisor - 1; 43 return (x + remainderMask) & ~remainderMask; 44 } 45 37 46 class MarkedBlock { 38 47 #if OS(WINCE) || OS(SYMBIAN) || PLATFORM(BREWMP) … … 42 51 #endif 43 52 44 static const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1; 45 static const size_t BLOCK_MASK = ~BLOCK_OFFSET_MASK; 53 static const size_t BLOCK_MASK = ~(BLOCK_SIZE - 1); 46 54 static const size_t MINIMUM_CELL_SIZE = 64; 47 55 static const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0); … … 54 62 static const size_t CELL_ALIGN_MASK = ~CELL_MASK; 55 63 static const size_t BITS_PER_BLOCK = BLOCK_SIZE / CELL_SIZE; 56 static const size_t CELLS_PER_BLOCK = (BLOCK_SIZE - sizeof( Heap*) - sizeof(WTF::Bitmap<BITS_PER_BLOCK>)) / CELL_SIZE; // Division rounds down intentionally.64 static const size_t CELLS_PER_BLOCK = (BLOCK_SIZE - sizeof(WTF::Bitmap<BITS_PER_BLOCK>) - sizeof(PageAllocationAligned) - sizeof(Heap*)) / CELL_SIZE; // Division rounds down intentionally. 57 65 58 66 struct CollectorCell { … … 82 90 size_t capacity(); 83 91 92 size_t firstCell(); 93 84 94 size_t cellNumber(const void*); 85 95 bool isMarked(const void*); … … 91 101 private: 92 102 MarkedBlock(const PageAllocationAligned&, JSGlobalData*); 103 CollectorCell* cells(); 93 104 94 FixedArray<CollectorCell, CELLS_PER_BLOCK> m_cells;95 105 WTF::Bitmap<BITS_PER_BLOCK> m_marks; 96 106 PageAllocationAligned m_allocation; 97 107 Heap* m_heap; 98 108 }; 109 110 inline size_t MarkedBlock::firstCell() 111 { 112 return roundUpToMultipleOf<CELL_SIZE>(sizeof(MarkedBlock)) / CELL_SIZE; 113 } 114 115 inline MarkedBlock::CollectorCell* MarkedBlock::cells() 116 { 117 return reinterpret_cast<CollectorCell*>(this); 118 } 99 119 100 120 inline bool MarkedBlock::isCellAligned(const void* p) … … 145 165 inline size_t MarkedBlock::cellNumber(const void* cell) 146 166 { 147 return (reinterpret_cast<uintptr_t>(cell) & BLOCK_OFFSET_MASK) / CELL_SIZE;167 return (reinterpret_cast<uintptr_t>(cell) - reinterpret_cast<uintptr_t>(this)) / CELL_SIZE; 148 168 } 149 169 … … 165 185 template <typename Functor> inline void MarkedBlock::forEach(Functor& functor) 166 186 { 167 for (size_t i = 0; i < CELLS_PER_BLOCK - 1; ++i) { // The last cell is a dummy place-holder.187 for (size_t i = firstCell(); i < CELLS_PER_BLOCK - 1; ++i) { // The last cell is a dummy place-holder. 168 188 if (!m_marks.get(i)) 169 189 continue; 170 functor(reinterpret_cast<JSCell*>(& m_cells[i]));190 functor(reinterpret_cast<JSCell*>(&cells()[i])); 171 191 } 172 192 } -
trunk/Source/JavaScriptCore/runtime/MarkedSpace.cpp
r78382 r78605 36 36 { 37 37 allocateBlock(); 38 m_heap.nextCell = m_heap.collectorBlock(0)->firstCell(); 38 39 } 39 40 … … 128 129 void MarkedSpace::reset() 129 130 { 130 m_heap.nextCell = 0;131 131 m_heap.nextBlock = 0; 132 m_heap.nextCell = m_heap.collectorBlock(0)->firstCell(); 132 133 m_waterMark = 0; 133 134 #if ENABLE(JSC_ZOMBIES)
Note: See TracChangeset
for help on using the changeset viewer.