2008-06-06 Kevin McCullough <kmccullough@apple.com>
authorkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jun 2008 16:48:54 +0000 (16:48 +0000)
committerkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jun 2008 16:48:54 +0000 (16:48 +0000)
        Reviewed by Adam.

        <rdar://problem/5969992> JSProfiler: Remove the recursion limit in the
        profiler.
        - Change the remaining functions that do not take arguments, from using
        recursion to using iteration.

        * JavaScriptCore.exp:
        * profiler/Profile.cpp:
        (KJS::stopProfiling):
        (KJS::restoreAll):
        (KJS::Profile::stopProfiling): Use foreach instead of recursion.
        (KJS::Profile::restoreAll): Ditto.
        * profiler/Profile.h:
        * profiler/ProfileNode.cpp: Remove recursion.
        (KJS::ProfileNode::stopProfiling):
        (KJS::ProfileNode::restore):
        * profiler/ProfileNode.h:

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

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

index ff2088d50e384a153e2ad280c7cfa020d0a69c46..342b6f9394f2e9d650237195c87303cd0e52883a 100644 (file)
@@ -1,3 +1,24 @@
+2008-06-06  Kevin McCullough  <kmccullough@apple.com>
+
+        Reviewed by Adam.
+
+        <rdar://problem/5969992> JSProfiler: Remove the recursion limit in the
+        profiler.
+        - Change the remaining functions that do not take arguments, from using
+        recursion to using iteration.
+
+        * JavaScriptCore.exp:
+        * profiler/Profile.cpp:
+        (KJS::stopProfiling):
+        (KJS::restoreAll):
+        (KJS::Profile::stopProfiling): Use foreach instead of recursion.
+        (KJS::Profile::restoreAll): Ditto.
+        * profiler/Profile.h:
+        * profiler/ProfileNode.cpp: Remove recursion.
+        (KJS::ProfileNode::stopProfiling):
+        (KJS::ProfileNode::restore):
+        * profiler/ProfileNode.h:
+
 2008-06-05  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Alexey.
index cf5ce5281098523a85a113a8c4d5f65889fab4b7..4ba228f77341c7d0b6167ff33df331fe46ae66a7 100644 (file)
@@ -18,7 +18,6 @@ __ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
 __ZN3KJS11ProfileNode4sortEPFbRKN3WTF6RefPtrIS0_EES5_E
 __ZN3KJS11ProfileNode5focusERKNS_14CallIdentifierEb
 __ZN3KJS11ProfileNode7excludeERKNS_14CallIdentifierE
-__ZN3KJS11ProfileNode10restoreAllEv
 __ZN3KJS11ProgramNode6createEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_INS3_6RefPtrINS_12FuncDeclNodeEEELm16EEEbb
 __ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE
 __ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierERb
@@ -89,6 +88,7 @@ __ZN3KJS7CStringaSERKS0_
 __ZN3KJS7CStringD1Ev
 __ZN3KJS7Machine13dumpCallFrameEPKNS_9CodeBlockEPNS_14ScopeChainNodeEPNS_12RegisterFileEPKNS_8RegisterE
 __ZN3KJS7Profile7forEachEPFvPNS_11ProfileNodeEE
+__ZN3KJS7Profile10restoreAllEv
 __ZN3KJS7UString3Rep11computeHashEPKti
 __ZN3KJS7UString3Rep4nullE
 __ZN3KJS7UString3Rep7destroyEv
index 6705ba23fbba36ba9ececc8053a5fac105e4904e..5fb20307774ee5411d4bc64a4916e4c5d5128e49 100644 (file)
@@ -37,6 +37,9 @@ namespace KJS {
 
 const unsigned DEPTH_LIMIT = 1000;
 
+static void stopProfiling(ProfileNode* n) { n->stopProfiling(); }
+static void restoreAll(ProfileNode* n) { n->restore(); }
+
 Profile::Profile(const UString& title, ExecState* originatingGlobalExec, unsigned pageGroupIdentifier)
     : m_title(title)
     , m_originatingGlobalExec(originatingGlobalExec)
@@ -53,7 +56,7 @@ void Profile::stopProfiling()
 {
     m_currentNode = 0;
     m_originatingGlobalExec = 0;
-    m_head->stopProfiling();
+    forEach(KJS::stopProfiling);
     m_depth = 0;
 }
 
@@ -86,7 +89,8 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
     --m_depth;
 }
 
-void Profile::forEach(UnaryFunction function) {
+void Profile::forEach(UnaryFunction function)
+{
 
     ProfileNode* currentNode = m_head->firstChild();
     for (ProfileNode* nextNode = currentNode; nextNode; nextNode = nextNode->firstChild())
@@ -99,6 +103,12 @@ void Profile::forEach(UnaryFunction function) {
     } 
 }
 
+void Profile::restoreAll()
+{
+    forEach(KJS::restoreAll);
+}
+
+
 #ifndef NDEBUG
 void Profile::debugPrintData() const
 {
index 40654ca0e43287c3812064bb6a7bea3efba94a72..a6e03d0a8b3b24e9214a55cda40c686ef5b06377 100644 (file)
@@ -63,7 +63,7 @@ namespace KJS {
 
         void focus(const ProfileNode* profileNode) { if (!profileNode) return; m_head->focus(profileNode->callIdentifier()); }
         void exclude(const ProfileNode* profileNode) { if (!profileNode) return; m_head->exclude(profileNode->callIdentifier()); }
-        void restoreAll() { m_head->restoreAll(); }
+        void restoreAll();
 
 #ifndef NDEBUG
         void debugPrintData() const;
index 2e4a76613c68ddaed9227d3fe02e1e6df5587026..fa0daf052a70817a719eeff2d4f98bc8d3f9a111 100644 (file)
@@ -123,12 +123,9 @@ void ProfileNode::stopProfiling()
 
     ASSERT(m_actualSelfTime == 0.0 && m_startTime == 0.0);
 
-    // Calculate Self time and the percentages once we stop profiling.
-    StackIterator endOfChildren = m_children.end();
-    for (StackIterator currentChild = m_children.begin(); currentChild != endOfChildren; ++currentChild) {
-        (*currentChild)->stopProfiling();
-        m_actualSelfTime += (*currentChild)->totalTime();
-    }
+    // Because we iterate in post order all of our children have been stopped before us.
+    for (unsigned i = 0; i < m_children.size(); ++i)
+        m_actualSelfTime += m_children[i]->totalTime();
 
     ASSERT(m_actualSelfTime <= m_actualTotalTime);
     m_actualSelfTime = m_actualTotalTime - m_actualSelfTime;
@@ -209,14 +206,11 @@ double ProfileNode::exclude(const CallIdentifier& callIdentifier)
     return 0;
 }
 
-void ProfileNode::restoreAll()
+void ProfileNode::restore()
 {
     m_visibleTotalTime = m_actualTotalTime;
     m_visibleSelfTime = m_actualSelfTime;
     m_visible = true;
-
-    for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
-        (*currentChild)->restoreAll();
 }
 
 void ProfileNode::endAndRecordCall()
index 293a7482912f123ba915f71640fa1e12c43d4362..541f719da313b93ab652e5f6c75e9ba9745d80f0 100644 (file)
@@ -103,10 +103,10 @@ namespace KJS {
         static void sortCallsAscending(ProfileNode* n) { n->sort(callsAscendingComparator); }
         static void sortFunctionNameDescending(ProfileNode* n) { n->sort(functionNameDescendingComparator); }
         static void sortFunctionNameAscending(ProfileNode* n) { n->sort(functionNameAscendingComparator); }
-
+        
         void focus(const CallIdentifier&, bool forceVisible = false);
         double exclude(const CallIdentifier&);
-        void restoreAll();
+        void restore();
 
         void endAndRecordCall();