Changeset 87522 in webkit
- Timestamp:
- May 27, 2011 10:39:35 AM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r87520 r87522 1 2011-05-26 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Optimized ConservativeSet to avoid double-visiting objects 6 https://bugs.webkit.org/show_bug.cgi?id=61592 7 8 SunSpider thinks this might be a 1% speedup 9 10 * heap/ConservativeRoots.h: 11 (JSC::ConservativeRoots::add): Use testAndClearMarked to avoid double-visiting 12 an object. 13 14 * heap/Heap.h: 15 (JSC::Heap::isMarked): 16 (JSC::Heap::testAndSetMarked): 17 (JSC::Heap::testAndClearMarked): 18 (JSC::Heap::setMarked): Added testAndClearMarked. Changed argument type 19 to void*, since clients want to ask questions about arbitrary pointers 20 into the heap, even when they aren't known to be JSCells. 21 22 * heap/MarkedBlock.h: 23 (JSC::MarkedBlock::testAndClearMarked): 24 * heap/MarkedSpace.h: 25 (JSC::MarkedSpace::isMarked): 26 (JSC::MarkedSpace::testAndSetMarked): 27 (JSC::MarkedSpace::testAndClearMarked): 28 (JSC::MarkedSpace::setMarked): 29 (JSC::MarkedSpace::contains): Ditto. 30 31 * wtf/Bitmap.h: 32 (WTF::::testAndClear): New function for ConservativeRoots's inverted 33 marking pass. 34 1 35 2011-05-27 Stephanie Lewis <slewis@apple.com> 2 36 -
trunk/Source/JavaScriptCore/heap/ConservativeRoots.h
r83506 r87522 35 35 class JSCell; 36 36 class Heap; 37 38 // May contain duplicates.39 37 40 38 class ConservativeRoots { … … 81 79 return; 82 80 81 // The conservative set inverts the typical meaning of mark bits: We only 82 // visit marked pointers, and our visit clears the mark bit. This efficiently 83 // sifts out pointers to dead objects and duplicate pointers. 84 if (!m_heap->testAndClearMarked(p)) 85 return; 86 83 87 if (m_size == m_capacity) 84 88 grow(); 85 89 86 m_roots[m_size++] = reinterpret_cast<JSCell*>(p);90 m_roots[m_size++] = static_cast<JSCell*>(p); 87 91 } 88 92 -
trunk/Source/JavaScriptCore/heap/Heap.h
r87441 r87522 59 59 static Heap* heap(JSCell*); 60 60 61 static bool isMarked(const JSCell*); 62 static bool testAndSetMarked(const JSCell*); 63 static void setMarked(JSCell*); 61 static bool isMarked(const void*); 62 static bool testAndSetMarked(const void*); 63 static bool testAndClearMarked(const void*); 64 static void setMarked(const void*); 64 65 65 66 static void writeBarrier(const JSCell*, JSValue); … … 155 156 } 156 157 157 inline bool Heap::isMarked(const JSCell* cell)158 inline bool Heap::isMarked(const void* cell) 158 159 { 159 160 return MarkedSpace::isMarked(cell); 160 161 } 161 162 162 inline bool Heap::testAndSetMarked(const JSCell* cell)163 inline bool Heap::testAndSetMarked(const void* cell) 163 164 { 164 165 return MarkedSpace::testAndSetMarked(cell); 165 166 } 166 167 167 inline void Heap::setMarked(JSCell* cell) 168 inline bool Heap::testAndClearMarked(const void* cell) 169 { 170 return MarkedSpace::testAndClearMarked(cell); 171 } 172 173 inline void Heap::setMarked(const void* cell) 168 174 { 169 175 MarkedSpace::setMarked(cell); -
trunk/Source/JavaScriptCore/heap/MarkedBlock.h
r87441 r87522 68 68 size_t capacity(); 69 69 70 bool contains(const void*);71 70 size_t atomNumber(const void*); 72 71 bool isMarked(const void*); 73 72 bool testAndSetMarked(const void*); 73 bool testAndClearMarked(const void*); 74 74 void setMarked(const void*); 75 75 … … 161 161 } 162 162 163 inline bool MarkedBlock::contains(const void* p)164 {165 ASSERT(p && isAtomAligned(p) && atomNumber(p) < atomsPerBlock);166 167 // Even though we physically contain p, we only logically contain p if p168 // points to a live cell. (Claiming to contain a dead cell would trick the169 // conservative garbage collector into resurrecting the cell in a zombie state.)170 return isMarked(p);171 }172 173 163 inline size_t MarkedBlock::atomNumber(const void* p) 174 164 { … … 184 174 { 185 175 return m_marks.testAndSet(atomNumber(p)); 176 } 177 178 inline bool MarkedBlock::testAndClearMarked(const void* p) 179 { 180 return m_marks.testAndClear(atomNumber(p)); 186 181 } 187 182 -
trunk/Source/JavaScriptCore/heap/MarkedSpace.h
r87441 r87522 53 53 static Heap* heap(JSCell*); 54 54 55 static bool isMarked(const JSCell*); 56 static bool testAndSetMarked(const JSCell*); 57 static void setMarked(const JSCell*); 55 static bool isMarked(const void*); 56 static bool testAndSetMarked(const void*); 57 static bool testAndClearMarked(const void*); 58 static void setMarked(const void*); 58 59 59 60 MarkedSpace(JSGlobalData*); … … 124 125 } 125 126 126 inline bool MarkedSpace::isMarked(const JSCell* cell)127 inline bool MarkedSpace::isMarked(const void* cell) 127 128 { 128 129 return MarkedBlock::blockFor(cell)->isMarked(cell); 129 130 } 130 131 131 inline bool MarkedSpace::testAndSetMarked(const JSCell* cell)132 inline bool MarkedSpace::testAndSetMarked(const void* cell) 132 133 { 133 134 return MarkedBlock::blockFor(cell)->testAndSetMarked(cell); 134 135 } 135 136 136 inline void MarkedSpace::setMarked(const JSCell* cell) 137 inline bool MarkedSpace::testAndClearMarked(const void* cell) 138 { 139 return MarkedBlock::blockFor(cell)->testAndClearMarked(cell); 140 } 141 142 inline void MarkedSpace::setMarked(const void* cell) 137 143 { 138 144 MarkedBlock::blockFor(cell)->setMarked(cell); … … 147 153 if (!block || !m_blocks.contains(block)) 148 154 return false; 149 150 return block->contains(x);155 156 return true; 151 157 } 152 158 -
trunk/Source/JavaScriptCore/wtf/Bitmap.h
r79126 r87522 38 38 void set(size_t); 39 39 bool testAndSet(size_t); 40 bool testAndClear(size_t); 40 41 size_t nextPossiblyUnset(size_t) const; 41 42 void clear(size_t); … … 85 86 bool result = bits[index] & mask; 86 87 bits[index] |= mask; 88 return result; 89 } 90 91 template<size_t size> 92 inline bool Bitmap<size>::testAndClear(size_t n) 93 { 94 WordType mask = one << (n % wordSize); 95 size_t index = n / wordSize; 96 bool result = bits[index] & mask; 97 bits[index] &= ~mask; 87 98 return result; 88 99 }
Note: See TracChangeset
for help on using the changeset viewer.