summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/profiler/Profile.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/profiler/Profile.cpp
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/profiler/Profile.cpp')
-rw-r--r--Source/JavaScriptCore/profiler/Profile.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/Source/JavaScriptCore/profiler/Profile.cpp b/Source/JavaScriptCore/profiler/Profile.cpp
index f3d450ab2..ed21e7879 100644
--- a/Source/JavaScriptCore/profiler/Profile.cpp
+++ b/Source/JavaScriptCore/profiler/Profile.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2014 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,34 +31,45 @@
namespace JSC {
-Ref<Profile> Profile::create(const String& title, unsigned uid, double startTime)
+PassRefPtr<Profile> Profile::create(const String& title, unsigned uid)
{
- return adoptRef(*new Profile(title, uid, startTime));
+ return adoptRef(new Profile(title, uid));
}
-Profile::Profile(const String& title, unsigned uid, double startTime)
+Profile::Profile(const String& title, unsigned uid)
: m_title(title)
, m_uid(uid)
{
// FIXME: When multi-threading is supported this will be a vector and calls
// into the profiler will need to know which thread it is executing on.
- m_rootNode = ProfileNode::create(nullptr, CallIdentifier(ASCIILiteral("Thread_1"), String(), 0, 0), nullptr);
- m_rootNode->appendCall(ProfileNode::Call(startTime));
+ m_head = ProfileNode::create(0, CallIdentifier("Thread_1", String(), 0), 0, 0);
}
Profile::~Profile()
{
}
-#ifndef NDEBUG
-void Profile::debugPrint()
+void Profile::forEach(void (ProfileNode::*function)())
{
- CalculateProfileSubtreeDataFunctor functor;
- m_rootNode->forEachNodePostorder(functor);
- ProfileNode::ProfileSubtreeData data = functor.returnValue();
+ ProfileNode* currentNode = m_head->firstChild();
+ for (ProfileNode* nextNode = currentNode; nextNode; nextNode = nextNode->firstChild())
+ currentNode = nextNode;
+
+ if (!currentNode)
+ currentNode = m_head.get();
+
+ ProfileNode* endNode = m_head->traverseNextNodePostOrder();
+ while (currentNode && currentNode != endNode) {
+ (currentNode->*function)();
+ currentNode = currentNode->traverseNextNodePostOrder();
+ }
+}
+#ifndef NDEBUG
+void Profile::debugPrintData() const
+{
dataLogF("Call graph:\n");
- m_rootNode->debugPrintRecursively(0, data);
+ m_head->debugPrintData(0);
}
typedef WTF::KeyValuePair<FunctionCallHashCount::ValueType, unsigned> NameCountPair;
@@ -68,17 +79,13 @@ static inline bool functionNameCountPairComparator(const NameCountPair& a, const
return a.value > b.value;
}
-void Profile::debugPrintSampleStyle()
+void Profile::debugPrintDataSampleStyle() const
{
typedef Vector<NameCountPair> NameCountPairVector;
- CalculateProfileSubtreeDataFunctor functor;
- m_rootNode->forEachNodePostorder(functor);
- ProfileNode::ProfileSubtreeData data = functor.returnValue();
-
FunctionCallHashCount countedFunctions;
dataLogF("Call graph:\n");
- m_rootNode->debugPrintSampleStyleRecursively(0, countedFunctions, data);
+ m_head->debugPrintDataSampleStyle(0, countedFunctions);
dataLogF("\nTotal number in stack:\n");
NameCountPairVector sortedFunctions(countedFunctions.size());