summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/HeapStatistics.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/heap/HeapStatistics.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/heap/HeapStatistics.cpp')
-rw-r--r--Source/JavaScriptCore/heap/HeapStatistics.cpp75
1 files changed, 43 insertions, 32 deletions
diff --git a/Source/JavaScriptCore/heap/HeapStatistics.cpp b/Source/JavaScriptCore/heap/HeapStatistics.cpp
index 12d12ce92..f23def711 100644
--- a/Source/JavaScriptCore/heap/HeapStatistics.cpp
+++ b/Source/JavaScriptCore/heap/HeapStatistics.cpp
@@ -28,17 +28,16 @@
#include "Heap.h"
#include "HeapIterationScope.h"
-#include "JSCInlines.h"
#include "JSObject.h"
+#include "Operations.h"
#include "Options.h"
#include <stdlib.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/DataLog.h>
-#include <wtf/StdLibExtras.h>
-
#if OS(UNIX)
#include <sys/resource.h>
#endif
+#include <wtf/CurrentTime.h>
+#include <wtf/DataLog.h>
+#include <wtf/Deque.h>
namespace JSC {
@@ -133,7 +132,6 @@ void HeapStatistics::logStatistics()
void HeapStatistics::exitWithFailure()
{
- exit(-1);
}
void HeapStatistics::reportSuccess()
@@ -142,11 +140,33 @@ void HeapStatistics::reportSuccess()
#endif // OS(UNIX)
+size_t HeapStatistics::parseMemoryAmount(char* s)
+{
+ size_t multiplier = 1;
+ char* afterS;
+ size_t value = strtol(s, &afterS, 10);
+ char next = afterS[0];
+ switch (next) {
+ case 'K':
+ multiplier = KB;
+ break;
+ case 'M':
+ multiplier = MB;
+ break;
+ case 'G':
+ multiplier = GB;
+ break;
+ default:
+ break;
+ }
+ return value * multiplier;
+}
+
class StorageStatistics : public MarkedBlock::VoidFunctor {
public:
StorageStatistics();
- IterationStatus operator()(JSCell*);
+ void operator()(JSCell*);
size_t objectWithOutOfLineStorageCount();
size_t objectCount();
@@ -155,8 +175,6 @@ public:
size_t storageCapacity();
private:
- void visit(JSCell*);
-
size_t m_objectWithOutOfLineStorageCount;
size_t m_objectCount;
size_t m_storageSize;
@@ -171,13 +189,13 @@ inline StorageStatistics::StorageStatistics()
{
}
-inline void StorageStatistics::visit(JSCell* cell)
+inline void StorageStatistics::operator()(JSCell* cell)
{
if (!cell->isObject())
return;
JSObject* object = jsCast<JSObject*>(cell);
- if (hasIndexedProperties(object->indexingType()))
+ if (hasIndexedProperties(object->structure()->indexingType()))
return;
if (object->structure()->isUncacheableDictionary())
@@ -190,12 +208,6 @@ inline void StorageStatistics::visit(JSCell* cell)
m_storageCapacity += object->structure()->totalStorageCapacity() * sizeof(WriteBarrierBase<Unknown>);
}
-inline IterationStatus StorageStatistics::operator()(JSCell* cell)
-{
- visit(cell);
- return IterationStatus::Continue;
-}
-
inline size_t StorageStatistics::objectWithOutOfLineStorageCount()
{
return m_objectWithOutOfLineStorageCount;
@@ -216,31 +228,30 @@ inline size_t StorageStatistics::storageCapacity()
return m_storageCapacity;
}
-void HeapStatistics::dumpObjectStatistics(Heap* heap)
+void HeapStatistics::showObjectStatistics(Heap* heap)
{
dataLogF("\n=== Heap Statistics: ===\n");
dataLogF("size: %ldkB\n", static_cast<long>(heap->m_sizeAfterLastCollect / KB));
dataLogF("capacity: %ldkB\n", static_cast<long>(heap->capacity() / KB));
- dataLogF("pause time: %lfs\n\n", heap->m_lastFullGCLength);
+ dataLogF("pause time: %lfms\n\n", heap->m_lastGCLength);
StorageStatistics storageStatistics;
{
HeapIterationScope iterationScope(*heap);
heap->m_objectSpace.forEachLiveCell(iterationScope, storageStatistics);
}
- long wastedPropertyStorageBytes = 0;
- long wastedPropertyStoragePercent = 0;
- long objectWithOutOfLineStorageCount = 0;
- long objectsWithOutOfLineStoragePercent = 0;
- if ((storageStatistics.storageCapacity() > 0) && (storageStatistics.objectCount() > 0)) {
- wastedPropertyStorageBytes = static_cast<long>((storageStatistics.storageCapacity() - storageStatistics.storageSize()) / KB);
- wastedPropertyStoragePercent = static_cast<long>(
- (storageStatistics.storageCapacity() - storageStatistics.storageSize()) * 100 / storageStatistics.storageCapacity());
- objectWithOutOfLineStorageCount = static_cast<long>(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);
+ dataLogF("wasted .property storage: %ldkB (%ld%%)\n",
+ static_cast<long>(
+ (storageStatistics.storageCapacity() - storageStatistics.storageSize()) / KB),
+ static_cast<long>(
+ (storageStatistics.storageCapacity() - storageStatistics.storageSize()) * 100
+ / storageStatistics.storageCapacity()));
+ dataLogF("objects with out-of-line .property storage: %ld (%ld%%)\n",
+ static_cast<long>(
+ storageStatistics.objectWithOutOfLineStorageCount()),
+ static_cast<long>(
+ storageStatistics.objectWithOutOfLineStorageCount() * 100
+ / storageStatistics.objectCount()));
}
} // namespace JSC