Changeset 130520 in webkit for trunk/Source/JavaScriptCore/heap/Heap.cpp
- Timestamp:
- Oct 5, 2012, 10:35:49 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/heap/Heap.cpp
r130303 r130520 28 28 #include "GCActivityCallback.h" 29 29 #include "HeapRootVisitor.h" 30 #include "HeapStatistics.h" 30 31 #include "IncrementalSweeper.h" 31 32 #include "Interpreter.h" … … 234 235 { 235 236 return m_typeCountSet.release(); 236 }237 238 class StorageStatistics : public MarkedBlock::VoidFunctor {239 public:240 StorageStatistics();241 242 void operator()(JSCell*);243 244 size_t objectWithOutOfLineStorageCount();245 size_t objectCount();246 247 size_t storageSize();248 size_t storageCapacity();249 250 private:251 size_t m_objectWithOutOfLineStorageCount;252 size_t m_objectCount;253 size_t m_storageSize;254 size_t m_storageCapacity;255 };256 257 inline StorageStatistics::StorageStatistics()258 : m_objectWithOutOfLineStorageCount(0)259 , m_objectCount(0)260 , m_storageSize(0)261 , m_storageCapacity(0)262 {263 }264 265 inline void StorageStatistics::operator()(JSCell* cell)266 {267 if (!cell->isObject())268 return;269 270 JSObject* object = jsCast<JSObject*>(cell);271 if (hasIndexedProperties(object->structure()->indexingType()))272 return;273 274 if (object->structure()->isUncacheableDictionary())275 return;276 277 ++m_objectCount;278 if (!object->hasInlineStorage())279 ++m_objectWithOutOfLineStorageCount;280 m_storageSize += object->structure()->totalStorageSize() * sizeof(WriteBarrierBase<Unknown>);281 m_storageCapacity += object->structure()->totalStorageCapacity() * sizeof(WriteBarrierBase<Unknown>);282 }283 284 inline size_t StorageStatistics::objectWithOutOfLineStorageCount()285 {286 return m_objectWithOutOfLineStorageCount;287 }288 289 inline size_t StorageStatistics::objectCount()290 {291 return m_objectCount;292 }293 294 295 inline size_t StorageStatistics::storageSize()296 {297 return m_storageSize;298 }299 300 301 inline size_t StorageStatistics::storageCapacity()302 {303 return m_storageCapacity;304 237 } 305 238 … … 832 765 833 766 size_t currentHeapSize = size(); 767 if (Options::gcMaxHeapSize() && currentHeapSize > Options::gcMaxHeapSize()) 768 HeapStatistics::exitWithFailure(); 769 834 770 if (fullGC) { 835 771 m_sizeAfterLastCollect = currentHeapSize; … … 845 781 m_lastGCLength = lastGCEndTime - lastGCStartTime; 846 782 783 if (Options::recordGCPauseTimes()) 784 HeapStatistics::recordGCPauseTime(lastGCStartTime, lastGCEndTime); 847 785 if (m_operationInProgress != Collection) 848 786 CRASH(); … … 856 794 markDeadObjects(); 857 795 858 if (Options::showHeapStatistics()) 859 showStatistics(); 860 } 861 862 void Heap::showStatistics() 863 { 864 dataLog("\n=== Heap Statistics: ===\n"); 865 dataLog("size: %ldkB\n", static_cast<long>(m_sizeAfterLastCollect / KB)); 866 dataLog("capacity: %ldkB\n", static_cast<long>(capacity() / KB)); 867 dataLog("pause time: %lfms\n\n", m_lastGCLength); 868 869 StorageStatistics storageStatistics; 870 m_objectSpace.forEachLiveCell(storageStatistics); 871 dataLog("wasted .property storage: %ldkB (%ld%%)\n", 872 static_cast<long>( 873 (storageStatistics.storageCapacity() - storageStatistics.storageSize()) / KB), 874 static_cast<long>( 875 (storageStatistics.storageCapacity() - storageStatistics.storageSize()) * 100 876 / storageStatistics.storageCapacity())); 877 dataLog("objects with out-of-line .property storage: %ld (%ld%%)\n", 878 static_cast<long>( 879 storageStatistics.objectWithOutOfLineStorageCount()), 880 static_cast<long>( 881 storageStatistics.objectWithOutOfLineStorageCount() * 100 882 / storageStatistics.objectCount())); 796 if (Options::showObjectStatistics()) 797 HeapStatistics::showObjectStatistics(this); 883 798 } 884 799
Note:
See TracChangeset
for help on using the changeset viewer.