Title: [145367] trunk/Source/WebCore
Revision
145367
Author
yu...@chromium.org
Date
2013-03-11 08:47:44 -0700 (Mon, 11 Mar 2013)

Log Message

Web Inspector: add per image statistics to the native memory snapshot
https://bugs.webkit.org/show_bug.cgi?id=112011

Reviewed by Pavel Feldman.

Added per-image statistics to the native memory distribution table.

* inspector/front-end/HeapSnapshotProxy.js:
(WebInspector.HeapSnapshotWorker):
(WebInspector.HeapSnapshotWorker.prototype.createLoader):
(WebInspector.HeapSnapshotWorker.prototype.wrapCallback):
(WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod):
(WebInspector.HeapSnapshotProxyObject.prototype.callFactoryMethod): the method now accepts
proxy constructor function instead of its name. This eliminates unnecessary function lookup.
(WebInspector.HeapSnapshotLoaderProxy):
(WebInspector.HeapSnapshotLoaderProxy.prototype.close):
(WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
(WebInspector.HeapSnapshotProxy.prototype.createRetainingEdgesProvider):
(WebInspector.HeapSnapshotProxy.prototype.createAddedNodesProvider):
(WebInspector.HeapSnapshotProxy.prototype.createDeletedNodesProvider):
(WebInspector.HeapSnapshotProxy.prototype.createNodesProvider):
(WebInspector.HeapSnapshotProxy.prototype.createNodesProviderForClass):
(WebInspector.HeapSnapshotProxy.prototype.createNodesProviderForDominator):
(WebInspector.NativeHeapSnapshotProxy):
(WebInspector.NativeHeapSnapshotProxy.prototype.images):
* inspector/front-end/HeapSnapshotView.js:
(WebInspector.HeapProfileHeader.prototype.snapshotProxyConstructor):
(WebInspector.HeapProfileHeader.prototype._setupWorker):
* inspector/front-end/NativeHeapSnapshot.js:
(WebInspector.NativeHeapSnapshot.prototype.images):
* inspector/front-end/NativeMemorySnapshotView.js:
(WebInspector.NativeSnapshotNode):
(WebInspector.NativeSnapshotNode.prototype._createSizeCell):
(WebInspector.NativeSnapshotNode.prototype._populate):
(WebInspector.NativeSnapshotNode.prototype._addChildrenFromGraph):
(WebInspector.NativeSnapshotNode.prototype._addImageDetails.didLoad.didReceiveImages):
(WebInspector.NativeSnapshotNode.prototype._addImageDetails):
(WebInspector.NativeSnapshotProfileHeader.prototype.snapshotProxyConstructor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145366 => 145367)


--- trunk/Source/WebCore/ChangeLog	2013-03-11 15:43:06 UTC (rev 145366)
+++ trunk/Source/WebCore/ChangeLog	2013-03-11 15:47:44 UTC (rev 145367)
@@ -1,3 +1,44 @@
+2013-03-11  Yury Semikhatsky  <yu...@chromium.org>
+
+        Web Inspector: add per image statistics to the native memory snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=112011
+
+        Reviewed by Pavel Feldman.
+
+        Added per-image statistics to the native memory distribution table.
+
+        * inspector/front-end/HeapSnapshotProxy.js:
+        (WebInspector.HeapSnapshotWorker):
+        (WebInspector.HeapSnapshotWorker.prototype.createLoader):
+        (WebInspector.HeapSnapshotWorker.prototype.wrapCallback):
+        (WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod):
+        (WebInspector.HeapSnapshotProxyObject.prototype.callFactoryMethod): the method now accepts
+        proxy constructor function instead of its name. This eliminates unnecessary function lookup.
+        (WebInspector.HeapSnapshotLoaderProxy):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.close):
+        (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createRetainingEdgesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createAddedNodesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createDeletedNodesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createNodesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createNodesProviderForClass):
+        (WebInspector.HeapSnapshotProxy.prototype.createNodesProviderForDominator):
+        (WebInspector.NativeHeapSnapshotProxy):
+        (WebInspector.NativeHeapSnapshotProxy.prototype.images):
+        * inspector/front-end/HeapSnapshotView.js:
+        (WebInspector.HeapProfileHeader.prototype.snapshotProxyConstructor):
+        (WebInspector.HeapProfileHeader.prototype._setupWorker):
+        * inspector/front-end/NativeHeapSnapshot.js:
+        (WebInspector.NativeHeapSnapshot.prototype.images):
+        * inspector/front-end/NativeMemorySnapshotView.js:
+        (WebInspector.NativeSnapshotNode):
+        (WebInspector.NativeSnapshotNode.prototype._createSizeCell):
+        (WebInspector.NativeSnapshotNode.prototype._populate):
+        (WebInspector.NativeSnapshotNode.prototype._addChildrenFromGraph):
+        (WebInspector.NativeSnapshotNode.prototype._addImageDetails.didLoad.didReceiveImages):
+        (WebInspector.NativeSnapshotNode.prototype._addImageDetails):
+        (WebInspector.NativeSnapshotProfileHeader.prototype.snapshotProxyConstructor):
+
 2013-03-11  Allan Sandfeld Jensen  <allan.jen...@digia.com>
 
         [Qt] Enable tiled shadow blur for inset box shadows

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js (145366 => 145367)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js	2013-03-11 15:43:06 UTC (rev 145366)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js	2013-03-11 15:47:44 UTC (rev 145367)
@@ -188,10 +188,10 @@
 }
 
 WebInspector.HeapSnapshotWorker.prototype = {
-    createLoader: function(snapshotConstructorName)
+    createLoader: function(snapshotConstructorName, proxyConstructor)
     {
         var objectId = this._nextObjectId++;
-        var proxy = new WebInspector.HeapSnapshotLoaderProxy(this, objectId, snapshotConstructorName);
+        var proxy = new WebInspector.HeapSnapshotLoaderProxy(this, objectId, snapshotConstructorName, proxyConstructor);
         this._postMessage({callId: this._nextCallId++, disposition: "create", objectId: objectId, methodName: "WebInspector.HeapSnapshotLoader"});
         return proxy;
     },
@@ -215,23 +215,22 @@
         this._postMessage({callId: callId, disposition: "getter", objectId: objectId, methodName: getterName});
     },
 
-    callFactoryMethod: function(callback, objectId, methodName, proxyConstructorName)
+    callFactoryMethod: function(callback, objectId, methodName, proxyConstructor)
     {
         var callId = this._nextCallId++;
         var methodArguments = Array.prototype.slice.call(arguments, 4);
         var newObjectId = this._nextObjectId++;
-        var proxyConstructorFunction = this._findFunction(proxyConstructorName);
         if (callback) {
             function wrapCallback(remoteResult)
             {
-                callback(remoteResult ? new proxyConstructorFunction(this, newObjectId) : null);
+                callback(remoteResult ? new proxyConstructor(this, newObjectId) : null);
             }
             this._callbacks[callId] = wrapCallback.bind(this);
             this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId: newObjectId});
             return null;
         } else {
             this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId: newObjectId});
-            return new proxyConstructorFunction(this, newObjectId);
+            return new proxyConstructor(this, newObjectId);
         }
     },
 
@@ -331,7 +330,7 @@
     /**
      * @param {...*} var_args
      */
-    callFactoryMethod: function(callback, methodName, proxyConstructorName, var_args)
+    callFactoryMethod: function(callback, methodName, proxyConstructor, var_args)
     {
         return this._callWorker("callFactoryMethod", Array.prototype.slice.call(arguments, 0));
     },
@@ -359,10 +358,11 @@
  * @extends {WebInspector.HeapSnapshotProxyObject}
  * @implements {WebInspector.OutputStream}
  */
-WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId, snapshotConstructorName)
+WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId, snapshotConstructorName, proxyConstructor)
 {
     WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
     this._snapshotConstructorName = snapshotConstructorName;
+    this._proxyConstructor = proxyConstructor;
     this._pendingSnapshotConsumers = [];
 }
 
@@ -388,7 +388,7 @@
     {
         function buildSnapshot()
         {
-            this.callFactoryMethod(updateStaticData.bind(this), "buildSnapshot", "WebInspector.HeapSnapshotProxy", this._snapshotConstructorName);
+            this.callFactoryMethod(updateStaticData.bind(this), "buildSnapshot", this._proxyConstructor, this._snapshotConstructorName);
         }
         function updateStaticData(snapshotProxy)
         {
@@ -445,37 +445,37 @@
 
     createEdgesProvider: function(nodeIndex, showHiddenData)
     {
-        return this.callFactoryMethod(null, "createEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, showHiddenData);
+        return this.callFactoryMethod(null, "createEdgesProvider", WebInspector.HeapSnapshotProviderProxy, nodeIndex, showHiddenData);
     },
 
     createRetainingEdgesProvider: function(nodeIndex, showHiddenData)
     {
-        return this.callFactoryMethod(null, "createRetainingEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, showHiddenData);
+        return this.callFactoryMethod(null, "createRetainingEdgesProvider", WebInspector.HeapSnapshotProviderProxy, nodeIndex, showHiddenData);
     },
 
     createAddedNodesProvider: function(baseSnapshotId, className)
     {
-        return this.callFactoryMethod(null, "createAddedNodesProvider", "WebInspector.HeapSnapshotProviderProxy", baseSnapshotId, className);
+        return this.callFactoryMethod(null, "createAddedNodesProvider", WebInspector.HeapSnapshotProviderProxy, baseSnapshotId, className);
     },
 
     createDeletedNodesProvider: function(nodeIndexes)
     {
-        return this.callFactoryMethod(null, "createDeletedNodesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndexes);
+        return this.callFactoryMethod(null, "createDeletedNodesProvider", WebInspector.HeapSnapshotProviderProxy, nodeIndexes);
     },
 
     createNodesProvider: function(filter)
     {
-        return this.callFactoryMethod(null, "createNodesProvider", "WebInspector.HeapSnapshotProviderProxy", filter);
+        return this.callFactoryMethod(null, "createNodesProvider", WebInspector.HeapSnapshotProviderProxy, filter);
     },
 
     createNodesProviderForClass: function(className, aggregatesKey)
     {
-        return this.callFactoryMethod(null, "createNodesProviderForClass", "WebInspector.HeapSnapshotProviderProxy", className, aggregatesKey);
+        return this.callFactoryMethod(null, "createNodesProviderForClass", WebInspector.HeapSnapshotProviderProxy, className, aggregatesKey);
     },
 
     createNodesProviderForDominator: function(nodeIndex)
     {
-        return this.callFactoryMethod(null, "createNodesProviderForDominator", "WebInspector.HeapSnapshotProviderProxy", nodeIndex);
+        return this.callFactoryMethod(null, "createNodesProviderForDominator", WebInspector.HeapSnapshotProviderProxy, nodeIndex);
     },
 
     dispose: function()
@@ -519,6 +519,24 @@
 
 /**
  * @constructor
+ * @extends {WebInspector.HeapSnapshotProxy}
+ */
+WebInspector.NativeHeapSnapshotProxy = function(worker, objectId)
+{
+    WebInspector.HeapSnapshotProxy.call(this, worker, objectId);
+}
+
+WebInspector.NativeHeapSnapshotProxy.prototype = {
+    images: function(callback)
+    {
+        this.callMethod(callback, "images");
+    },
+
+    __proto__: WebInspector.HeapSnapshotProxy.prototype
+}
+
+/**
+ * @constructor
  * @extends {WebInspector.HeapSnapshotProxyObject}
  */
 WebInspector.HeapSnapshotProviderProxy = function(worker, objectId)

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js (145366 => 145367)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js	2013-03-11 15:43:06 UTC (rev 145366)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js	2013-03-11 15:47:44 UTC (rev 145367)
@@ -978,6 +978,11 @@
         return "JSHeapSnapshot";
     },
 
+    snapshotProxyConstructor: function()
+    {
+        return WebInspector.HeapSnapshotProxy;
+    },
+
     _setupWorker: function()
     {
         function setProfileWait(event)
@@ -986,7 +991,7 @@
         }
         var worker = new WebInspector.HeapSnapshotWorker();
         worker.addEventListener("wait", setProfileWait, this);
-        var loaderProxy = worker.createLoader(this.snapshotConstructorName());
+        var loaderProxy = worker.createLoader(this.snapshotConstructorName(), this.snapshotProxyConstructor());
         loaderProxy.addConsumer(this._snapshotReceived.bind(this));
         this._receiver = loaderProxy;
     },

Modified: trunk/Source/WebCore/inspector/front-end/NativeHeapSnapshot.js (145366 => 145367)


--- trunk/Source/WebCore/inspector/front-end/NativeHeapSnapshot.js	2013-03-11 15:43:06 UTC (rev 145366)
+++ trunk/Source/WebCore/inspector/front-end/NativeHeapSnapshot.js	2013-03-11 15:47:44 UTC (rev 145367)
@@ -69,6 +69,24 @@
         return null;
     },
 
+    images: function()
+    {
+        var aggregatesByClassName = this.aggregates(false, "allObjects");
+        var images = aggregatesByClassName["WebCore::CachedImage"];
+        var result = [];
+        if (!images)
+            return result;
+        var node = this.rootNode();
+        for (var i = 0; i < images.idxs.length; i++) {
+            node.nodeIndex = images.idxs[i];
+            result.push({
+                name: node.name(),
+                size: node.retainedSize(),
+            });
+        }
+        return result;
+    },
+
     __proto__: WebInspector.HeapSnapshot.prototype
 };
 

Modified: trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js (145366 => 145367)


--- trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js	2013-03-11 15:43:06 UTC (rev 145366)
+++ trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js	2013-03-11 15:47:44 UTC (rev 145367)
@@ -61,7 +61,7 @@
     };
     WebInspector.DataGrid.call(this, columns);
     this._profile = profile;
-    this._totalNode = new WebInspector.NativeSnapshotNode(profile._memoryBlock, profile._memoryBlock);
+    this._totalNode = new WebInspector.NativeSnapshotNode(profile._memoryBlock, profile);
     if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get()) {
         this.setRootNode(new WebInspector.DataGridNode(null, true));
         this.rootNode().appendChild(this._totalNode)
@@ -107,15 +107,14 @@
  * @constructor
  * @extends {WebInspector.DataGridNode}
  * @param {MemoryAgent.MemoryBlock} nodeData
- * @param {MemoryAgent.MemoryBlock} rootMemoryBlock
  */
-WebInspector.NativeSnapshotNode = function(nodeData, rootMemoryBlock)
+WebInspector.NativeSnapshotNode = function(nodeData, profile)
 {
     this._nodeData = nodeData;
-    this._rootMemoryBlock = rootMemoryBlock;
+    this._profile = profile;
     var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(nodeData);
     var data = { name: viewProperties._description, size: this._nodeData.size };
-    var hasChildren = !!nodeData.children && nodeData.children.length !== 0;
+    var hasChildren = this._addChildrenFromGraph();
     WebInspector.DataGridNode.call(this, data, hasChildren);
     this.addEventListener("populate", this._populate, this);
 }
@@ -185,7 +184,7 @@
         }
 
         var sizeKB = this._nodeData.size / 1024;
-        var totalSize = this._rootMemoryBlock.size;
+        var totalSize = this._profile._memoryBlock.size;
         var percentage = this._nodeData.size / totalSize  * 100;
 
         var cell = document.createElement("td");
@@ -220,15 +219,52 @@
 
     _populate: function() {
         this.removeEventListener("populate", this._populate, this);
+        if (this._nodeData.children)
+            this._addChildren();
+    },
+
+    _addChildren: function()
+    {
         this._nodeData.children.sort(this.dataGrid._sortingFunction.bind(this.dataGrid));
 
         for (var node in this._nodeData.children) {
             var nodeData = this._nodeData.children[node];
             if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get() || nodeData.name !== "Other")
-                this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._rootMemoryBlock));
+                this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._profile));
         }
     },
 
+    _addChildrenFromGraph: function()
+    {
+        var memoryBlock = this._nodeData;
+        if (memoryBlock.children)
+             return memoryBlock.children.length > 0;
+        if (memoryBlock.name === "Image") {
+            this._addImageDetails();
+            return true;
+        }
+        return false;
+    },
+
+    _addImageDetails: function()
+    {
+        /**
+         * @param {WebInspector.NativeHeapSnapshotProxy} proxy
+         */
+        function didLoad(proxy)
+        {
+            function didReceiveImages(result)
+            {
+                this._nodeData.children = result;
+                if (this.expanded)
+                    this._addChildren();
+            }
+            proxy.images(didReceiveImages.bind(this));
+
+        }
+        this._profile.load(didLoad.bind(this));
+    },
+
     __proto__: WebInspector.DataGridNode.prototype
 }
 
@@ -428,6 +464,11 @@
         return "NativeHeapSnapshot";
     },
 
+    snapshotProxyConstructor: function()
+    {
+        return WebInspector.NativeHeapSnapshotProxy;
+    },
+
     addNativeSnapshotChunk: function(chunk)
     {
         this._strings = this._strings.concat(chunk.strings);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to