From d61a03cf5951a6ee9e890783039e68c8598714e6 Mon Sep 17 00:00:00 2001 From: Julien Brianceau Date: Thu, 28 Aug 2014 16:32:15 +0200 Subject: Correct GC length unit and prevent division by 0 in showObjectStatistics. https://bugs.webkit.org/show_bug.cgi?id=136340 Reviewed by Mark Hahnenberg. Change-Id: I20483be1225d674160bbdab183bc52121fe4411c git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173062 268f45cc-cd09-0410-ab3c-d52691b4dbfc Reviewed-by: Michael Bruning --- Source/JavaScriptCore/heap/HeapStatistics.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'Source/JavaScriptCore') diff --git a/Source/JavaScriptCore/heap/HeapStatistics.cpp b/Source/JavaScriptCore/heap/HeapStatistics.cpp index 55e3e9d9d..b63c316ce 100644 --- a/Source/JavaScriptCore/heap/HeapStatistics.cpp +++ b/Source/JavaScriptCore/heap/HeapStatistics.cpp @@ -232,22 +232,23 @@ void HeapStatistics::showObjectStatistics(Heap* heap) dataLogF("\n=== Heap Statistics: ===\n"); dataLogF("size: %ldkB\n", static_cast(heap->m_sizeAfterLastCollect / KB)); dataLogF("capacity: %ldkB\n", static_cast(heap->capacity() / KB)); - dataLogF("pause time: %lfms\n\n", heap->m_lastGCLength); + dataLogF("pause time: %lfs\n\n", heap->m_lastGCLength); StorageStatistics storageStatistics; heap->m_objectSpace.forEachLiveCell(storageStatistics); - dataLogF("wasted .property storage: %ldkB (%ld%%)\n", - static_cast( - (storageStatistics.storageCapacity() - storageStatistics.storageSize()) / KB), - static_cast( - (storageStatistics.storageCapacity() - storageStatistics.storageSize()) * 100 - / storageStatistics.storageCapacity())); - dataLogF("objects with out-of-line .property storage: %ld (%ld%%)\n", - static_cast( - storageStatistics.objectWithOutOfLineStorageCount()), - static_cast( - storageStatistics.objectWithOutOfLineStorageCount() * 100 - / storageStatistics.objectCount())); + long wastedPropertyStorageBytes = 0; + long wastedPropertyStoragePercent = 0; + long objectWithOutOfLineStorageCount = 0; + long objectsWithOutOfLineStoragePercent = 0; + if ((storageStatistics.storageCapacity() > 0) && (storageStatistics.objectCount() > 0)) { + wastedPropertyStorageBytes = static_cast((storageStatistics.storageCapacity() - storageStatistics.storageSize()) / KB); + wastedPropertyStoragePercent = static_cast( + (storageStatistics.storageCapacity() - storageStatistics.storageSize()) * 100 / storageStatistics.storageCapacity()); + objectWithOutOfLineStorageCount = static_cast(storageStatistics.objectWithOutOfLineStorageCount()); + objectsWithOutOfLineStoragePercent = objectWithOutOfLineStorageCount * 100 / storageStatistics.objectCount(); + } + dataLogF("wasted .property storage: %ldkB (%ld%%)\n", wastedPropertyStorageBytes, wastedPropertyStoragePercent); + dataLogF("objects with out-of-line .property storage: %ld (%ld%%)\n", objectWithOutOfLineStorageCount, objectsWithOutOfLineStoragePercent); } } // namespace JSC -- cgit v1.2.1