Changeset 20722 in webkit
- Timestamp:
- Apr 5, 2007 9:35:43 AM (17 years ago)
- Location:
- branches/js-collector-tweaks/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/js-collector-tweaks/JavaScriptCore/ChangeLog
r20699 r20722 1 2007-04-05 Maciej Stachowiak <mjs@apple.com> 2 3 Not reviewed, experimental change. 4 5 - remove the concept of oversize objects, now that there aren't any (for now 6 only enforced with an assert). 7 8 This change is a .66% speedup on JS iBench for 32-bit platforms, probably much more 9 for 64-bit since it finally gives a reasonable cell size, but I did not test that. 10 11 * kjs/collector.cpp: 12 (KJS::): Use different cell size for 32-bit and 64-bit, now that there is no 13 oversize allocation. 14 (KJS::Collector::allocate): Remove oversize allocator. 15 (KJS::Collector::markStackObjectsConservatively): Don't check oversize objects. 16 (KJS::Collector::markMainThreadOnlyObjects): Ditto. 17 (KJS::Collector::collect): Ditto. 18 1 19 2007-04-03 Kevin McCullough <kmccullough@apple.com> 2 20 -
branches/js-collector-tweaks/JavaScriptCore/kjs/collector.cpp
r20353 r20722 59 59 namespace KJS { 60 60 61 62 61 63 // tunable parameters 62 const size_t MINIMUM_CELL_SIZE = 48; 64 65 template<bool is32Bit, bool is64Bit> struct CellSize; 66 template<> struct CellSize<true, false> { static const size_t m_value = 48; }; // 32-bit 67 template<> struct CellSize<false, true> { static const size_t m_value = 80; }; // 64-bit 68 63 69 const size_t BLOCK_SIZE = (8 * 4096); 64 70 const size_t SPARE_EMPTY_BLOCKS = 2; … … 69 75 70 76 // derived constants 71 const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0); 77 const size_t MINIMUM_CELL_SIZE = CellSize<sizeof(void*) == sizeof(uint32_t), sizeof(void*) == sizeof(uint64_t)>::m_value; 78 const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? 1 : 0); 72 79 const size_t CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double); 73 const size_t CELLS_PER_BLOCK = ((BLOCK_SIZE * 8 - sizeof(uint32_t) * 8 - sizeof(void *) * 8) / (CELL_SIZE * 8)); 74 80 const size_t CELLS_PER_BLOCK = ((BLOCK_SIZE * 8 - sizeof(uint32_t) * 8 - sizeof(void*) * 8) / (CELL_SIZE * 8)); 75 81 76 82 … … 98 104 size_t firstBlockWithPossibleSpace; 99 105 100 CollectorCell **oversizeCells;101 size_t numOversizeCells;102 size_t usedOversizeCells;103 104 106 size_t numLiveObjects; 105 107 size_t numLiveObjectsAtLastCollect; 106 108 }; 107 109 108 static CollectorHeap heap = {NULL, 0, 0, 0, NULL, 0, 0,0, 0};110 static CollectorHeap heap = {NULL, 0, 0, 0, 0, 0}; 109 111 110 112 size_t Collector::mainThreadOnlyObjectCount = 0; … … 137 139 ASSERT(JSLock::lockCount() > 0); 138 140 ASSERT(JSLock::currentThreadIsHoldingLock()); 141 ASSERT(s <= CELL_SIZE); 139 142 140 143 // collect if needed … … 151 154 GCLock lock; 152 155 #endif 153 154 if (s > CELL_SIZE) {155 // oversize allocator156 size_t usedOversizeCells = heap.usedOversizeCells;157 size_t numOversizeCells = heap.numOversizeCells;158 159 if (usedOversizeCells == numOversizeCells) {160 numOversizeCells = max(MIN_ARRAY_SIZE, numOversizeCells * GROWTH_FACTOR);161 heap.numOversizeCells = numOversizeCells;162 heap.oversizeCells = static_cast<CollectorCell **>(fastRealloc(heap.oversizeCells, numOversizeCells * sizeof(CollectorCell *)));163 }164 165 void *newCell = fastMalloc(s);166 heap.oversizeCells[usedOversizeCells] = static_cast<CollectorCell *>(newCell);167 heap.usedOversizeCells = usedOversizeCells + 1;168 heap.numLiveObjects = numLiveObjects + 1;169 170 return newCell;171 }172 156 173 157 // slab allocator … … 385 369 size_t usedBlocks = heap.usedBlocks; 386 370 CollectorBlock **blocks = heap.blocks; 387 size_t usedOversizeCells = heap.usedOversizeCells;388 CollectorCell **oversizeCells = heap.oversizeCells;389 371 390 372 const size_t lastCellOffset = sizeof(CollectorCell) * (CELLS_PER_BLOCK - 1); … … 395 377 for (size_t block = 0; block < usedBlocks; block++) { 396 378 size_t offset = x - reinterpret_cast<char *>(blocks[block]); 397 if (offset <= lastCellOffset && offset % sizeof(CollectorCell) == 0) 398 goto gotGoodPointer; 399 } 400 for (size_t i = 0; i != usedOversizeCells; i++) 401 if (x == reinterpret_cast<char *>(oversizeCells[i])) 402 goto gotGoodPointer; 403 continue; 404 405 gotGoodPointer: 406 if (((CollectorCell *)x)->u.freeCell.zeroIfFree != 0) { 407 JSCell *imp = reinterpret_cast<JSCell *>(x); 408 if (!imp->marked()) 409 imp->mark(); 379 if (offset <= lastCellOffset && offset % sizeof(CollectorCell) == 0) { 380 if (((CollectorCell *)x)->u.freeCell.zeroIfFree != 0) { 381 JSCell *imp = reinterpret_cast<JSCell *>(x); 382 if (!imp->marked()) 383 imp->mark(); 384 } 385 break; 386 } 410 387 } 411 388 } … … 695 672 } 696 673 } 697 698 for (size_t cell = 0; cell < heap.usedOversizeCells; cell++) {699 ASSERT(count < mainThreadOnlyObjectCount);700 701 JSCell* imp = reinterpret_cast<JSCell*>(heap.oversizeCells[cell]);702 if (imp->m_collectOnMainThreadOnly) {703 if (!imp->marked())704 imp->mark();705 if (++count == mainThreadOnlyObjectCount)706 return;707 }708 }709 674 } 710 675 … … 842 807 heap.firstBlockWithPossibleSpace = 0; 843 808 844 size_t cell = 0;845 while (cell < heap.usedOversizeCells) {846 JSCell *imp = (JSCell *)heap.oversizeCells[cell];847 848 if (imp->m_marked) {849 imp->m_marked = false;850 cell++;851 } else {852 ASSERT(currentThreadIsMainThread || !imp->m_collectOnMainThreadOnly);853 if (imp->m_collectOnMainThreadOnly)854 --mainThreadOnlyObjectCount;855 imp->~JSCell();856 #if DEBUG_COLLECTOR857 heap.oversizeCells[cell]->u.freeCell.zeroIfFree = 0;858 #else859 fastFree(imp);860 #endif861 862 // swap with the last oversize cell so we compact as we go863 heap.oversizeCells[cell] = heap.oversizeCells[heap.usedOversizeCells - 1];864 865 heap.usedOversizeCells--;866 numLiveObjects--;867 868 if (heap.numOversizeCells > MIN_ARRAY_SIZE && heap.usedOversizeCells < heap.numOversizeCells / LOW_WATER_FACTOR) {869 heap.numOversizeCells = heap.numOversizeCells / GROWTH_FACTOR;870 heap.oversizeCells = (CollectorCell **)fastRealloc(heap.oversizeCells, heap.numOversizeCells * sizeof(CollectorCell *));871 }872 }873 }874 875 809 bool deleted = heap.numLiveObjects != numLiveObjects; 876 810
Note: See TracChangeset
for help on using the changeset viewer.