2008-04-21 Kevin McCullough <kmccullough@apple.com>
authorkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Apr 2008 23:13:27 +0000 (23:13 +0000)
committerkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Apr 2008 23:13:27 +0000 (23:13 +0000)
        Reviewed by Adam.

        <rdar://problem/5770054> JavaScript profiler (10928)
        - When stop profiling is called we need to stop the timers on all the
        functions that are still running.

        * profiler/FunctionCallProfile.cpp:
        (KJS::FunctionCallProfile::didExecute):
        (KJS::FunctionCallProfile::stopProfiling):
        * profiler/FunctionCallProfile.h:
        * profiler/Profiler.cpp:
        (KJS::Profiler::stopProfiling):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32354 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/profiler/FunctionCallProfile.cpp
JavaScriptCore/profiler/FunctionCallProfile.h
JavaScriptCore/profiler/Profiler.cpp

index d0fd137..115c20c 100644 (file)
@@ -1,3 +1,18 @@
+2008-04-21  Kevin McCullough  <kmccullough@apple.com>
+
+        Reviewed by Adam.
+
+        <rdar://problem/5770054> JavaScript profiler (10928)
+        - When stop profiling is called we need to stop the timers on all the
+        functions that are still running.
+
+        * profiler/FunctionCallProfile.cpp:
+        (KJS::FunctionCallProfile::didExecute):
+        (KJS::FunctionCallProfile::stopProfiling):
+        * profiler/FunctionCallProfile.h:
+        * profiler/Profiler.cpp:
+        (KJS::Profiler::stopProfiling):
+
 2008-04-21  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
index 034a587..2d775c0 100644 (file)
@@ -60,6 +60,7 @@ void FunctionCallProfile::didExecute(Vector<UString> stackNames, unsigned int st
         ASSERT(stackNames[stackIndex - 1] == m_functionName);
 
         m_timeSum += getCurrentUTCTime() - m_startTime;
+        m_startTime = 0.0;
 
         // FIXME: We may need something with higher resolution than ms as some functions will take 0ms.
         return;
@@ -96,6 +97,16 @@ FunctionCallProfile* FunctionCallProfile::findChild(const UString& name)
     return 0;
 }
 
+void FunctionCallProfile::stopProfiling()
+{
+    if (m_startTime)
+        m_timeSum += getCurrentUTCTime() - m_startTime;
+
+    StackIterator endOfChildren = m_children.end();
+    for (StackIterator it = m_children.begin(); it != endOfChildren; ++it)
+        (*it)->stopProfiling();
+}
+
 void FunctionCallProfile::printDataInspectorStyle(int indentLevel) const
 {
     // Print function names
index 1b57135..607bc45 100644 (file)
@@ -49,6 +49,8 @@ namespace KJS {
         void addChild(FunctionCallProfile* child);
         FunctionCallProfile* findChild(const UString& name);
 
+        void stopProfiling();
+
         UString functionName() const { return m_functionName; }
         double milliSecs() const { return m_timeSum; }
 
index 96dfa05..cec9248 100644 (file)
@@ -66,6 +66,7 @@ void Profiler::startProfiling()
 void Profiler::stopProfiling()
 {
     m_profiling = false;
+    m_callTree->stopProfiling();
 }
 
 void Profiler::willExecute(ExecState* exec, JSObject* calledFunction)