Changeset 54672 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 11, 2010, 1:28:52 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r54655 r54672 1 2010-02-10 Geoffrey Garen <[email protected]> 2 3 Reviewed by Oliver Hunt. 4 5 Added an SPI for asking about all the different live objects on the heap. 6 Useful for memory debugging. 7 8 * JavaScriptCore.exp: Export the new SPI. 9 10 * runtime/Collector.cpp: 11 (JSC::typeName): Use a little capitalization. Don't crash in the case of 12 a non-object cell, since it might just be an uninitialized cell. 13 14 (JSC::Heap::objectTypeCounts): The new SPI. 15 16 * runtime/Collector.h: 17 * runtime/CollectorHeapIterator.h: 18 (JSC::CollectorHeapIterator::advance): 19 (JSC::LiveObjectIterator::operator++): 20 (JSC::DeadObjectIterator::operator++): 21 (JSC::ObjectIterator::operator++): Made 2 tweaks to these iterators: 22 (1) Skip the last cell in the block, since it's a dummy sentinel, and 23 we don't want it to confuse the object count; (2) Fixed a logic error 24 in LiveObjectIterator that could cause it to iterate dead objects if 25 m_block were equal to m_heap.nextBlock and m_cell were less than 26 m_heap.nextCell. No test for this since I can't think of a way that this 27 could make WebKit behave badly. 28 1 29 2010-02-11 Steve Block <[email protected]> 2 30 -
trunk/JavaScriptCore/JavaScriptCore.exp
r54531 r54672 191 191 __ZN3JSC4Heap14primaryHeapEndEv 192 192 __ZN3JSC4Heap15recordExtraCostEm 193 __ZN3JSC4Heap16objectTypeCountsEv 193 194 __ZN3JSC4Heap16primaryHeapBeginEv 194 195 __ZN3JSC4Heap17collectAllGarbageEv … … 300 301 __ZN3WTF10fastCallocEmm 301 302 __ZN3WTF10fastMallocEm 303 __ZN3WTF10fastStrDupEPKc 302 304 __ZN3WTF11currentTimeEv 303 305 __ZN3WTF11fastReallocEPvm … … 348 350 __ZN3WTF8CollatorD1Ev 349 351 __ZN3WTF8fastFreeEPv 350 __ZN3WTF10fastStrDupEPKc351 352 __ZN3WTF8msToYearEd 353 __ZN3WTF9ByteArray6createEm 352 354 __ZN3WTF9dayInYearEdi 353 __ZN3WTF9ByteArray6createEm354 355 __ZNK3JSC10JSFunction23isHostFunctionNonInlineEv 355 356 __ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE -
trunk/JavaScriptCore/runtime/Collector.cpp
r53572 r54672 1198 1198 #endif 1199 1199 if (cell->isGetterSetter()) 1200 return " gettersetter";1200 return "Getter-Setter"; 1201 1201 if (cell->isAPIValueWrapper()) 1202 return " valuewrapper";1202 return "API wrapper"; 1203 1203 if (cell->isPropertyNameIterator()) 1204 return "for-in iterator"; 1205 ASSERT(cell->isObject()); 1204 return "For-in iterator"; 1205 if (!cell->isObject()) 1206 return "[empty cell]"; 1206 1207 const ClassInfo* info = cell->classInfo(); 1207 1208 return info ? info->className : "Object"; … … 1215 1216 for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it) 1216 1217 counts->add(typeName(it->first)); 1218 1219 return counts; 1220 } 1221 1222 HashCountedSet<const char*>* Heap::objectTypeCounts() 1223 { 1224 HashCountedSet<const char*>* counts = new HashCountedSet<const char*>; 1225 1226 LiveObjectIterator it = primaryHeapBegin(); 1227 LiveObjectIterator heapEnd = primaryHeapEnd(); 1228 for ( ; it != heapEnd; ++it) 1229 counts->add(typeName(*it)); 1217 1230 1218 1231 return counts; -
trunk/JavaScriptCore/runtime/Collector.h
r52791 r54672 101 101 size_t protectedGlobalObjectCount(); 102 102 HashCountedSet<const char*>* protectedObjectTypeCounts(); 103 HashCountedSet<const char*>* objectTypeCounts(); 103 104 104 105 void registerThread(); // Only needs to be called by clients that can use the same heap from multiple threads. -
trunk/JavaScriptCore/runtime/CollectorHeapIterator.h
r52176 r54672 39 39 protected: 40 40 CollectorHeapIterator(CollectorHeap&, size_t startBlock, size_t startCell); 41 void advance(size_t cellsPerBlock);41 void advance(size_t max); 42 42 43 43 CollectorHeap& m_heap; … … 81 81 } 82 82 83 inline void CollectorHeapIterator::advance(size_t cellsPerBlock) 83 // Iterators advance up to the next-to-last -- and not the last -- cell in a 84 // block, since the last cell is a dummy sentinel. 85 inline void CollectorHeapIterator::advance(size_t max) 84 86 { 85 87 ++m_cell; 86 if (m_cell == cellsPerBlock) {88 if (m_cell == max) { 87 89 m_cell = 0; 88 90 ++m_block; … … 98 100 inline LiveObjectIterator& LiveObjectIterator::operator++() 99 101 { 100 if (m_block < m_heap.nextBlock || m_cell < m_heap.nextCell) {101 advance(HeapConstants::cellsPerBlock);102 advance(HeapConstants::cellsPerBlock - 1); 103 if (m_block < m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell)) 102 104 return *this; 103 }104 105 105 do { 106 advance(HeapConstants::cellsPerBlock); 107 } while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell)); 106 while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell)) 107 advance(HeapConstants::cellsPerBlock - 1); 108 108 return *this; 109 109 } … … 118 118 { 119 119 do { 120 advance(HeapConstants::cellsPerBlock );120 advance(HeapConstants::cellsPerBlock - 1); 121 121 ASSERT(m_block > m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell >= m_heap.nextCell)); 122 122 } while (m_block < m_heap.usedBlocks && m_heap.blocks[m_block]->marked.get(m_cell)); … … 132 132 inline ObjectIterator& ObjectIterator::operator++() 133 133 { 134 advance(HeapConstants::cellsPerBlock );134 advance(HeapConstants::cellsPerBlock - 1); 135 135 return *this; 136 136 }
Note:
See TracChangeset
for help on using the changeset viewer.