2011-05-20 Mikhail Naganov <mnaganov@chromium.org>
authormnaganov@chromium.org <mnaganov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 May 2011 13:46:03 +0000 (13:46 +0000)
committermnaganov@chromium.org <mnaganov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 May 2011 13:46:03 +0000 (13:46 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: [Chromium] Use bottom-up CPU profile tree built in VM,
        instead of building it on Inspector's side.
        https://bugs.webkit.org/show_bug.cgi?id=61185

        * bindings/js/ScriptProfile.cpp:
        (WebCore::ScriptProfile::bottomUpHead):
        (WebCore::ScriptProfile::buildInspectorObjectForBottomUpHead):
        * bindings/js/ScriptProfile.h:
        * bindings/v8/ScriptProfile.cpp:
        (WebCore::ScriptProfile::bottomUpHead):
        (WebCore::ScriptProfile::buildInspectorObjectForBottomUpHead):
        * bindings/v8/ScriptProfile.h:
        * inspector/InspectorProfilerAgent.cpp:
        (WebCore::InspectorProfilerAgent::getProfile):
        * inspector/front-end/ProfileView.js:
        (WebInspector.CPUProfileView.prototype.get bottomUpProfileDataGridTree):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptProfile.cpp
Source/WebCore/bindings/js/ScriptProfile.h
Source/WebCore/bindings/v8/ScriptProfile.cpp
Source/WebCore/bindings/v8/ScriptProfile.h
Source/WebCore/inspector/InspectorProfilerAgent.cpp
Source/WebCore/inspector/front-end/ProfileView.js

index ffe892f..ea7d690 100644 (file)
@@ -1,3 +1,24 @@
+2011-05-20  Mikhail Naganov  <mnaganov@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: [Chromium] Use bottom-up CPU profile tree built in VM,
+        instead of building it on Inspector's side.
+        https://bugs.webkit.org/show_bug.cgi?id=61185
+
+        * bindings/js/ScriptProfile.cpp:
+        (WebCore::ScriptProfile::bottomUpHead):
+        (WebCore::ScriptProfile::buildInspectorObjectForBottomUpHead):
+        * bindings/js/ScriptProfile.h:
+        * bindings/v8/ScriptProfile.cpp:
+        (WebCore::ScriptProfile::bottomUpHead):
+        (WebCore::ScriptProfile::buildInspectorObjectForBottomUpHead):
+        * bindings/v8/ScriptProfile.h:
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::getProfile):
+        * inspector/front-end/ProfileView.js:
+        (WebInspector.CPUProfileView.prototype.get bottomUpProfileDataGridTree):
+
 2011-05-20  Adam Roben  <aroben@apple.com>
 
         Mac build fix after r86936
index 84451fb..6a34978 100644 (file)
@@ -66,6 +66,13 @@ ScriptProfileNode* ScriptProfile::head() const
     return m_profile->head();
 }
 
+PassRefPtr<ScriptProfileNode> ScriptProfile::bottomUpHead() const
+{
+    // FIXME: implement building bottom-up profiles in C++ code,
+    // but consider https://bugs.webkit.org/show_bug.cgi?id=24604
+    return 0;
+}
+
 #if ENABLE(INSPECTOR)
 static PassRefPtr<InspectorObject> buildInspectorObjectFor(const JSC::ProfileNode* node)
 {
@@ -95,6 +102,11 @@ PassRefPtr<InspectorObject> ScriptProfile::buildInspectorObjectForHead() const
 {
     return buildInspectorObjectFor(m_profile->head());
 }
+
+PassRefPtr<InspectorObject> ScriptProfile::buildInspectorObjectForBottomUpHead() const
+{
+    return 0;
+}
 #endif
 
 } // namespace WebCore
index 0b38edc..d725af5 100644 (file)
@@ -50,9 +50,11 @@ public:
     String title() const;
     unsigned int uid() const;
     ScriptProfileNode* head() const;
+    PassRefPtr<ScriptProfileNode> bottomUpHead() const;
 
 #if ENABLE(INSPECTOR)
     PassRefPtr<InspectorObject> buildInspectorObjectForHead() const;
+    PassRefPtr<InspectorObject> buildInspectorObjectForBottomUpHead() const;
 #endif
 
 private:
index 2c9f0f5..866cbab 100644 (file)
@@ -60,6 +60,11 @@ PassRefPtr<ScriptProfileNode> ScriptProfile::head() const
     return ScriptProfileNode::create(m_profile->GetTopDownRoot());
 }
 
+PassRefPtr<ScriptProfileNode> ScriptProfile::bottomUpHead() const
+{
+    return ScriptProfileNode::create(m_profile->GetBottomUpRoot());
+}
+
 static PassRefPtr<InspectorObject> buildInspectorObjectFor(const v8::CpuProfileNode* node)
 {
     v8::HandleScope handleScope;
@@ -88,4 +93,9 @@ PassRefPtr<InspectorObject> ScriptProfile::buildInspectorObjectForHead() const
     return buildInspectorObjectFor(m_profile->GetTopDownRoot());
 }
 
+PassRefPtr<InspectorObject> ScriptProfile::buildInspectorObjectForBottomUpHead() const
+{
+    return buildInspectorObjectFor(m_profile->GetBottomUpRoot());
+}
+
 } // namespace WebCore
index d8196a4..aed45b5 100644 (file)
@@ -53,8 +53,10 @@ public:
     String title() const;
     unsigned int uid() const;
     PassRefPtr<ScriptProfileNode> head() const;
+    PassRefPtr<ScriptProfileNode> bottomUpHead() const;
 
     PassRefPtr<InspectorObject> buildInspectorObjectForHead() const;
+    PassRefPtr<InspectorObject> buildInspectorObjectForBottomUpHead() const;
 
 private:
     ScriptProfile(const v8::CpuProfile* profile)
index 8e654a3..3293b4c 100644 (file)
@@ -212,6 +212,8 @@ void InspectorProfilerAgent::getProfile(ErrorString*, const String& type, unsign
         if (it != m_profiles.end()) {
             *profileObject = createProfileHeader(*it->second);
             (*profileObject)->setObject("head", it->second->buildInspectorObjectForHead());
+            if (it->second->bottomUpHead())
+                (*profileObject)->setObject("bottomUpHead", it->second->buildInspectorObjectForBottomUpHead());
         }
     } else if (type == HeapProfileType) {
         HeapSnapshotsMap::iterator it = m_snapshots.find(uid);
index a8c5ff4..ef3e2b6 100644 (file)
@@ -117,8 +117,12 @@ WebInspector.CPUProfileView.prototype = {
 
     get bottomUpProfileDataGridTree()
     {
-        if (!this._bottomUpProfileDataGridTree)
-            this._bottomUpProfileDataGridTree = new WebInspector.BottomUpProfileDataGridTree(this, this.profile.head);
+        if (!this._bottomUpProfileDataGridTree) {
+            if (this.profile.bottomUpHead)
+                this._bottomUpProfileDataGridTree = new WebInspector.TopDownProfileDataGridTree(this, this.profile.bottomUpHead);
+            else
+                this._bottomUpProfileDataGridTree = new WebInspector.BottomUpProfileDataGridTree(this, this.profile.head);
+        }
         return this._bottomUpProfileDataGridTree;
     },