Fixed an ASSERT(m_actualSelfTime <= m_actualTotalTime) when starting
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jun 2008 04:39:23 +0000 (04:39 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jun 2008 04:39:23 +0000 (04:39 +0000)
        and stopping a profile from the Develop menu. Also prevents
        inserting an incorrect parent node as the new head after profiling
        is stopped from the Develop menu.

        Reviewed by Dan Bernstein.

        * profiler/Profile.cpp:
        (KJS::Profile::stopProfiling): If the current node is already the head
        then there is no more need to record future nodes in didExecute.
        (KJS::Profile::didExecute): Move the code of setupCurrentNodeAsStopped
        into here since this was the only caller. When setting the total time
        keep any current total time while adding the self time of the head.
        (KJS::Profile::setupCurrentNodeAsStopped): Removed.
        * profiler/Profile.h: Removed setupCurrentNodeAsStopped.

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

JavaScriptCore/ChangeLog
JavaScriptCore/profiler/Profile.cpp
JavaScriptCore/profiler/Profile.h

index 7fe8d0e..6621146 100644 (file)
@@ -1,3 +1,21 @@
+2008-06-20  Timothy Hatcher  <timothy@apple.com>
+
+        Fixed an ASSERT(m_actualSelfTime <= m_actualTotalTime) when starting
+        and stopping a profile from the Develop menu. Also prevents
+        inserting an incorrect parent node as the new head after profiling
+        is stopped from the Develop menu.
+
+        Reviewed by Dan Bernstein.
+
+        * profiler/Profile.cpp:
+        (KJS::Profile::stopProfiling): If the current node is already the head
+        then there is no more need to record future nodes in didExecute.
+        (KJS::Profile::didExecute): Move the code of setupCurrentNodeAsStopped
+        into here since this was the only caller. When setting the total time
+        keep any current total time while adding the self time of the head.
+        (KJS::Profile::setupCurrentNodeAsStopped): Removed.
+        * profiler/Profile.h: Removed setupCurrentNodeAsStopped.
+
 2008-06-20  Kevin Ollivier  <kevino@theolliviers.com>
 
         !USE(MULTIPLE_THREADS) on Darwin build fix
 2008-06-20  Kevin Ollivier  <kevino@theolliviers.com>
 
         !USE(MULTIPLE_THREADS) on Darwin build fix
index 998f624..f92a0d7 100644 (file)
@@ -65,6 +65,11 @@ void Profile::stopProfiling()
     removeProfileStart();
     removeProfileEnd();
 
     removeProfileStart();
     removeProfileEnd();
 
+    // Already at the head, set m_currentNode to prevent
+    // didExecute from recording more nodes.
+    if (m_currentNode == m_head)
+        m_currentNode = 0;
+
     m_stoppedProfiling = true;
 }
 
     m_stoppedProfiling = true;
 }
 
@@ -140,7 +145,9 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
         m_head->insertNode(m_currentNode.get());
 
         if (m_stoppedProfiling) {
         m_head->insertNode(m_currentNode.get());
 
         if (m_stoppedProfiling) {
-            setupCurrentNodeAsStopped();
+            m_currentNode->setTotalTime(m_currentNode->totalTime() + m_head->selfTime());
+            m_head->setSelfTime(0.0);
+            m_currentNode->stopProfiling();
             m_currentNode = 0;
         } else
             m_currentNode = m_head;
             m_currentNode = 0;
         } else
             m_currentNode = m_head;
@@ -156,12 +163,6 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
     m_currentNode = m_currentNode->didExecute();
 }
 
     m_currentNode = m_currentNode->didExecute();
 }
 
-void Profile::setupCurrentNodeAsStopped() {
-    m_currentNode->setTotalTime(m_head->selfTime());
-    m_head->setSelfTime(0.0);
-    m_currentNode->stopProfiling();
-}
-
 void Profile::forEach(UnaryFunction function)
 {
     ProfileNode* currentNode = m_head->firstChild();
 void Profile::forEach(UnaryFunction function)
 {
     ProfileNode* currentNode = m_head->firstChild();
index c275e11..76e5472 100644 (file)
@@ -78,7 +78,6 @@ namespace KJS {
         Profile(const UString& title, ExecState* originatingGlobalExec, unsigned pageGroupIdentifier, ProfilerClient*);
         void removeProfileStart();
         void removeProfileEnd();
         Profile(const UString& title, ExecState* originatingGlobalExec, unsigned pageGroupIdentifier, ProfilerClient*);
         void removeProfileStart();
         void removeProfileEnd();
-        void setupCurrentNodeAsStopped();
 
         UString m_title;
         ExecState* m_originatingGlobalExec;
 
         UString m_title;
         ExecState* m_originatingGlobalExec;