Fixed an ASSERT(m_actualSelfTime <= m_actualTotalTime) when starting
[WebKit-https.git] / JavaScriptCore / profiler / Profile.cpp
index 998f624..f92a0d7 100644 (file)
@@ -65,6 +65,11 @@ void Profile::stopProfiling()
     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;
 }
 
@@ -140,7 +145,9 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
         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;
@@ -156,12 +163,6 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
     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();