⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 145367 in webkit


Ignore:
Timestamp:
Mar 11, 2013, 8:47:44 AM (14 years ago)
Author:
yurys@chromium.org
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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r145366 r145367  
     12013-03-11  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: add per image statistics to the native memory snapshot
     4        https://bugs.webkit.org/show_bug.cgi?id=112011
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Added per-image statistics to the native memory distribution table.
     9
     10        * inspector/front-end/HeapSnapshotProxy.js:
     11        (WebInspector.HeapSnapshotWorker):
     12        (WebInspector.HeapSnapshotWorker.prototype.createLoader):
     13        (WebInspector.HeapSnapshotWorker.prototype.wrapCallback):
     14        (WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod):
     15        (WebInspector.HeapSnapshotProxyObject.prototype.callFactoryMethod): the method now accepts
     16        proxy constructor function instead of its name. This eliminates unnecessary function lookup.
     17        (WebInspector.HeapSnapshotLoaderProxy):
     18        (WebInspector.HeapSnapshotLoaderProxy.prototype.close):
     19        (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
     20        (WebInspector.HeapSnapshotProxy.prototype.createRetainingEdgesProvider):
     21        (WebInspector.HeapSnapshotProxy.prototype.createAddedNodesProvider):
     22        (WebInspector.HeapSnapshotProxy.prototype.createDeletedNodesProvider):
     23        (WebInspector.HeapSnapshotProxy.prototype.createNodesProvider):
     24        (WebInspector.HeapSnapshotProxy.prototype.createNodesProviderForClass):
     25        (WebInspector.HeapSnapshotProxy.prototype.createNodesProviderForDominator):
     26        (WebInspector.NativeHeapSnapshotProxy):
     27        (WebInspector.NativeHeapSnapshotProxy.prototype.images):
     28        * inspector/front-end/HeapSnapshotView.js:
     29        (WebInspector.HeapProfileHeader.prototype.snapshotProxyConstructor):
     30        (WebInspector.HeapProfileHeader.prototype._setupWorker):
     31        * inspector/front-end/NativeHeapSnapshot.js:
     32        (WebInspector.NativeHeapSnapshot.prototype.images):
     33        * inspector/front-end/NativeMemorySnapshotView.js:
     34        (WebInspector.NativeSnapshotNode):
     35        (WebInspector.NativeSnapshotNode.prototype._createSizeCell):
     36        (WebInspector.NativeSnapshotNode.prototype._populate):
     37        (WebInspector.NativeSnapshotNode.prototype._addChildrenFromGraph):
     38        (WebInspector.NativeSnapshotNode.prototype._addImageDetails.didLoad.didReceiveImages):
     39        (WebInspector.NativeSnapshotNode.prototype._addImageDetails):
     40        (WebInspector.NativeSnapshotProfileHeader.prototype.snapshotProxyConstructor):
     41
    1422013-03-11  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    243
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js

    r140953 r145367  
    189189
    190190WebInspector.HeapSnapshotWorker.prototype = {
    191     createLoader: function(snapshotConstructorName)
     191    createLoader: function(snapshotConstructorName, proxyConstructor)
    192192    {
    193193        var objectId = this._nextObjectId++;
    194         var proxy = new WebInspector.HeapSnapshotLoaderProxy(this, objectId, snapshotConstructorName);
     194        var proxy = new WebInspector.HeapSnapshotLoaderProxy(this, objectId, snapshotConstructorName, proxyConstructor);
    195195        this._postMessage({callId: this._nextCallId++, disposition: "create", objectId: objectId, methodName: "WebInspector.HeapSnapshotLoader"});
    196196        return proxy;
    … …  
    216216    },
    217217
    218     callFactoryMethod: function(callback, objectId, methodName, proxyConstructorName)
     218    callFactoryMethod: function(callback, objectId, methodName, proxyConstructor)
    219219    {
    220220        var callId = this._nextCallId++;
    221221        var methodArguments = Array.prototype.slice.call(arguments, 4);
    222222        var newObjectId = this._nextObjectId++;
    223         var proxyConstructorFunction = this._findFunction(proxyConstructorName);
    224223        if (callback) {
    225224            function wrapCallback(remoteResult)
    226225            {
    227                 callback(remoteResult ? new proxyConstructorFunction(this, newObjectId) : null);
     226                callback(remoteResult ? new proxyConstructor(this, newObjectId) : null);
    228227            }
    229228            this._callbacks[callId] = wrapCallback.bind(this);
    … …  
    232231        } else {
    233232            this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId: newObjectId});
    234             return new proxyConstructorFunction(this, newObjectId);
     233            return new proxyConstructor(this, newObjectId);
    235234        }
    236235    },
    … …  
    332331     * @param {...*} var_args
    333332     */
    334     callFactoryMethod: function(callback, methodName, proxyConstructorName, var_args)
     333    callFactoryMethod: function(callback, methodName, proxyConstructor, var_args)
    335334    {
    336335        return this._callWorker("callFactoryMethod", Array.prototype.slice.call(arguments, 0));
    … …  
    360359 * @implements {WebInspector.OutputStream}
    361360 */
    362 WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId, snapshotConstructorName)
     361WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId, snapshotConstructorName, proxyConstructor)
    363362{
    364363    WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
    365364    this._snapshotConstructorName = snapshotConstructorName;
     365    this._proxyConstructor = proxyConstructor;
    366366    this._pendingSnapshotConsumers = [];
    367367}
    … …  
    389389        function buildSnapshot()
    390390        {
    391             this.callFactoryMethod(updateStaticData.bind(this), "buildSnapshot", "WebInspector.HeapSnapshotProxy", this._snapshotConstructorName);
     391            this.callFactoryMethod(updateStaticData.bind(this), "buildSnapshot", this._proxyConstructor, this._snapshotConstructorName);
    392392        }
    393393        function updateStaticData(snapshotProxy)
    … …  
    446446    createEdgesProvider: function(nodeIndex, showHiddenData)
    447447    {
    448         return this.callFactoryMethod(null, "createEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, showHiddenData);
     448        return this.callFactoryMethod(null, "createEdgesProvider", WebInspector.HeapSnapshotProviderProxy, nodeIndex, showHiddenData);
    449449    },
    450450
    451451    createRetainingEdgesProvider: function(nodeIndex, showHiddenData)
    452452    {
    453         return this.callFactoryMethod(null, "createRetainingEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, showHiddenData);
     453        return this.callFactoryMethod(null, "createRetainingEdgesProvider", WebInspector.HeapSnapshotProviderProxy, nodeIndex, showHiddenData);
    454454    },
    455455
    456456    createAddedNodesProvider: function(baseSnapshotId, className)
    457457    {
    458         return this.callFactoryMethod(null, "createAddedNodesProvider", "WebInspector.HeapSnapshotProviderProxy", baseSnapshotId, className);
     458        return this.callFactoryMethod(null, "createAddedNodesProvider", WebInspector.HeapSnapshotProviderProxy, baseSnapshotId, className);
    459459    },
    460460
    461461    createDeletedNodesProvider: function(nodeIndexes)
    462462    {
    463         return this.callFactoryMethod(null, "createDeletedNodesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndexes);
     463        return this.callFactoryMethod(null, "createDeletedNodesProvider", WebInspector.HeapSnapshotProviderProxy, nodeIndexes);
    464464    },
    465465
    466466    createNodesProvider: function(filter)
    467467    {
    468         return this.callFactoryMethod(null, "createNodesProvider", "WebInspector.HeapSnapshotProviderProxy", filter);
     468        return this.callFactoryMethod(null, "createNodesProvider", WebInspector.HeapSnapshotProviderProxy, filter);
    469469    },
    470470
    471471    createNodesProviderForClass: function(className, aggregatesKey)
    472472    {
    473         return this.callFactoryMethod(null, "createNodesProviderForClass", "WebInspector.HeapSnapshotProviderProxy", className, aggregatesKey);
     473        return this.callFactoryMethod(null, "createNodesProviderForClass", WebInspector.HeapSnapshotProviderProxy, className, aggregatesKey);
    474474    },
    475475
    476476    createNodesProviderForDominator: function(nodeIndex)
    477477    {
    478         return this.callFactoryMethod(null, "createNodesProviderForDominator", "WebInspector.HeapSnapshotProviderProxy", nodeIndex);
     478        return this.callFactoryMethod(null, "createNodesProviderForDominator", WebInspector.HeapSnapshotProviderProxy, nodeIndex);
    479479    },
    480480
    … …  
    520520/**
    521521 * @constructor
     522 * @extends {WebInspector.HeapSnapshotProxy}
     523 */
     524WebInspector.NativeHeapSnapshotProxy = function(worker, objectId)
     525{
     526    WebInspector.HeapSnapshotProxy.call(this, worker, objectId);
     527}
     528
     529WebInspector.NativeHeapSnapshotProxy.prototype = {
     530    images: function(callback)
     531    {
     532        this.callMethod(callback, "images");
     533    },
     534
     535    __proto__: WebInspector.HeapSnapshotProxy.prototype
     536}
     537
     538/**
     539 * @constructor
    522540 * @extends {WebInspector.HeapSnapshotProxyObject}
    523541 */
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js

    r145074 r145367  
    979979    },
    980980
     981    snapshotProxyConstructor: function()
     982    {
     983        return WebInspector.HeapSnapshotProxy;
     984    },
     985
    981986    _setupWorker: function()
    982987    {
    … …  
    987992        var worker = new WebInspector.HeapSnapshotWorker();
    988993        worker.addEventListener("wait", setProfileWait, this);
    989         var loaderProxy = worker.createLoader(this.snapshotConstructorName());
     994        var loaderProxy = worker.createLoader(this.snapshotConstructorName(), this.snapshotProxyConstructor());
    990995        loaderProxy.addConsumer(this._snapshotReceived.bind(this));
    991996        this._receiver = loaderProxy;
  • trunk/Source/WebCore/inspector/front-end/NativeHeapSnapshot.js

    r143317 r145367  
    7070    },
    7171
     72    images: function()
     73    {
     74        var aggregatesByClassName = this.aggregates(false, "allObjects");
     75        var images = aggregatesByClassName["WebCore::CachedImage"];
     76        var result = [];
     77        if (!images)
     78            return result;
     79        var node = this.rootNode();
     80        for (var i = 0; i < images.idxs.length; i++) {
     81            node.nodeIndex = images.idxs[i];
     82            result.push({
     83                name: node.name(),
     84                size: node.retainedSize(),
     85            });
     86        }
     87        return result;
     88    },
     89
    7290    __proto__: WebInspector.HeapSnapshot.prototype
    7391};
  • trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js

    r145357 r145367  
    6262    WebInspector.DataGrid.call(this, columns);
    6363    this._profile = profile;
    64     this._totalNode = new WebInspector.NativeSnapshotNode(profile._memoryBlock, profile._memoryBlock);
     64    this._totalNode = new WebInspector.NativeSnapshotNode(profile._memoryBlock, profile);
    6565    if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get()) {
    6666        this.setRootNode(new WebInspector.DataGridNode(null, true));
    … …  
    108108 * @extends {WebInspector.DataGridNode}
    109109 * @param {MemoryAgent.MemoryBlock} nodeData
    110  * @param {MemoryAgent.MemoryBlock} rootMemoryBlock
    111  */
    112 WebInspector.NativeSnapshotNode = function(nodeData, rootMemoryBlock)
     110 */
     111WebInspector.NativeSnapshotNode = function(nodeData, profile)
    113112{
    114113    this._nodeData = nodeData;
    115     this._rootMemoryBlock = rootMemoryBlock;
     114    this._profile = profile;
    116115    var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(nodeData);
    117116    var data = { name: viewProperties._description, size: this._nodeData.size };
    118     var hasChildren = !!nodeData.children && nodeData.children.length !== 0;
     117    var hasChildren = this._addChildrenFromGraph();
    119118    WebInspector.DataGridNode.call(this, data, hasChildren);
    120119    this.addEventListener("populate", this._populate, this);
    … …  
    186185
    187186        var sizeKB = this._nodeData.size / 1024;
    188         var totalSize = this._rootMemoryBlock.size;
     187        var totalSize = this._profile._memoryBlock.size;
    189188        var percentage = this._nodeData.size / totalSize  * 100;
    190189
    … …  
    221220    _populate: function() {
    222221        this.removeEventListener("populate", this._populate, this);
     222        if (this._nodeData.children)
     223            this._addChildren();
     224    },
     225
     226    _addChildren: function()
     227    {
    223228        this._nodeData.children.sort(this.dataGrid._sortingFunction.bind(this.dataGrid));
    224229
    … …  
    226231            var nodeData = this._nodeData.children[node];
    227232            if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get() || nodeData.name !== "Other")
    228                 this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._rootMemoryBlock));
     233                this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._profile));
    229234        }
     235    },
     236
     237    _addChildrenFromGraph: function()
     238    {
     239        var memoryBlock = this._nodeData;
     240        if (memoryBlock.children)
     241             return memoryBlock.children.length > 0;
     242        if (memoryBlock.name === "Image") {
     243            this._addImageDetails();
     244            return true;
     245        }
     246        return false;
     247    },
     248
     249    _addImageDetails: function()
     250    {
     251        /**
     252         * @param {WebInspector.NativeHeapSnapshotProxy} proxy
     253         */
     254        function didLoad(proxy)
     255        {
     256            function didReceiveImages(result)
     257            {
     258                this._nodeData.children = result;
     259                if (this.expanded)
     260                    this._addChildren();
     261            }
     262            proxy.images(didReceiveImages.bind(this));
     263
     264        }
     265        this._profile.load(didLoad.bind(this));
    230266    },
    231267
    … …  
    427463    {
    428464        return "NativeHeapSnapshot";
     465    },
     466
     467    snapshotProxyConstructor: function()
     468    {
     469        return WebInspector.NativeHeapSnapshotProxy;
    429470    },
    430471
Note: See TracChangeset for help on using the changeset viewer.