Home | History | Annotate | Download | only in profiler
      1 /*
      2  * Copyright (C) 2014 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 WebInspector.HeapSnapshotProgressEvent = {
     32     Update: "ProgressUpdate"
     33 };
     34 
     35 WebInspector.HeapSnapshotCommon = {
     36 }
     37 
     38 WebInspector.HeapSnapshotCommon.baseSystemDistance = 100000000;
     39 
     40 /**
     41  * @param {!Array.<!WebInspector.HeapSnapshotCommon.SerializedAllocationNode>} nodesWithSingleCaller
     42  * @param {!Array.<!WebInspector.HeapSnapshotCommon.SerializedAllocationNode>} branchingCallers
     43  * @constructor
     44  */
     45 WebInspector.HeapSnapshotCommon.AllocationNodeCallers = function(nodesWithSingleCaller, branchingCallers)
     46 {
     47     /** @type {!Array.<!WebInspector.HeapSnapshotCommon.SerializedAllocationNode>} */
     48     this.nodesWithSingleCaller = nodesWithSingleCaller;
     49     /** @type {!Array.<!WebInspector.HeapSnapshotCommon.SerializedAllocationNode>} */
     50     this.branchingCallers = branchingCallers;
     51 }
     52 
     53 /**
     54  * @param {number} nodeId
     55  * @param {string} functionName
     56  * @param {string} scriptName
     57  * @param {number} scriptId
     58  * @param {number} line
     59  * @param {number} column
     60  * @param {number} count
     61  * @param {number} size
     62  * @param {number} liveCount
     63  * @param {number} liveSize
     64  * @param {boolean} hasChildren
     65  * @constructor
     66  */
     67 WebInspector.HeapSnapshotCommon.SerializedAllocationNode = function(nodeId, functionName, scriptName, scriptId, line, column, count, size, liveCount, liveSize, hasChildren)
     68 {
     69     /** @type {number} */
     70     this.id = nodeId;
     71     /** @type {string} */
     72     this.name = functionName;
     73     /** @type {string} */
     74     this.scriptName = scriptName;
     75     /** @type {number} */
     76     this.scriptId = scriptId;
     77     /** @type {number} */
     78     this.line = line;
     79     /** @type {number} */
     80     this.column = column;
     81     /** @type {number} */
     82     this.count = count;
     83     /** @type {number} */
     84     this.size = size;
     85     /** @type {number} */
     86     this.liveCount = liveCount;
     87     /** @type {number} */
     88     this.liveSize = liveSize;
     89     /** @type {boolean} */
     90     this.hasChildren = hasChildren;
     91 }
     92 
     93 /**
     94  * @param {string} functionName
     95  * @param {string} scriptName
     96  * @param {number} scriptId
     97  * @param {number} line
     98  * @param {number} column
     99  * @constructor
    100  */
    101 WebInspector.HeapSnapshotCommon.AllocationStackFrame = function(functionName, scriptName, scriptId, line, column)
    102 {
    103     /** @type {string} */
    104     this.functionName = functionName;
    105     /** @type {string} */
    106     this.scriptName = scriptName;
    107     /** @type {number} */
    108     this.scriptId = scriptId;
    109     /** @type {number} */
    110     this.line = line;
    111     /** @type {number} */
    112     this.column = column;
    113 }
    114 
    115 /**
    116  * @constructor
    117  * @param {number} id
    118  * @param {string} name
    119  * @param {number} distance
    120  * @param {number} nodeIndex
    121  * @param {number} retainedSize
    122  * @param {number} selfSize
    123  * @param {string} type
    124  */
    125 WebInspector.HeapSnapshotCommon.Node = function(id, name, distance, nodeIndex, retainedSize, selfSize, type)
    126 {
    127     this.id = id;
    128     this.name = name;
    129     this.distance = distance;
    130     this.nodeIndex = nodeIndex;
    131     this.retainedSize = retainedSize;
    132     this.selfSize = selfSize;
    133     this.type = type;
    134 
    135     this.canBeQueried = false;
    136     this.detachedDOMTreeNode = false;
    137 }
    138 
    139 /**
    140  * @constructor
    141  * @param {string} name
    142  * @param {!WebInspector.HeapSnapshotCommon.Node} node
    143  * @param {string} type
    144  * @param {number} edgeIndex
    145  */
    146 WebInspector.HeapSnapshotCommon.Edge = function(name, node, type, edgeIndex)
    147 {
    148     this.name = name;
    149     this.node = node;
    150     this.type = type;
    151     this.edgeIndex = edgeIndex;
    152 };
    153 
    154 /**
    155  * @constructor
    156  */
    157 WebInspector.HeapSnapshotCommon.Aggregate = function()
    158 {
    159     /** @type {number} */
    160     this.count;
    161     /** @type {number} */
    162     this.distance;
    163     /** @type {number} */
    164     this.self;
    165     /** @type {number} */
    166     this.maxRet;
    167     /** @type {number} */
    168     this.type;
    169     /** @type {string} */
    170     this.name;
    171     /** @type {!Array.<number>} */
    172     this.idxs;
    173 }
    174 
    175 /**
    176  * @constructor
    177  */
    178 WebInspector.HeapSnapshotCommon.AggregateForDiff = function() {
    179     /** @type {!Array.<number>} */
    180     this.indexes = [];
    181     /** @type {!Array.<string>} */
    182     this.ids = [];
    183     /** @type {!Array.<number>} */
    184     this.selfSizes = [];
    185 }
    186 
    187 /**
    188  * @constructor
    189  */
    190 WebInspector.HeapSnapshotCommon.Diff = function()
    191 {
    192     /** @type {number} */
    193     this.addedCount = 0;
    194     /** @type {number} */
    195     this.removedCount = 0;
    196     /** @type {number} */
    197     this.addedSize = 0;
    198     /** @type {number} */
    199     this.removedSize = 0;
    200     /** @type {!Array.<number>} */
    201     this.deletedIndexes = [];
    202     /** @type {!Array.<number>} */
    203     this.addedIndexes = [];
    204 }
    205 
    206 /**
    207  * @constructor
    208  */
    209 WebInspector.HeapSnapshotCommon.DiffForClass = function()
    210 {
    211     /** @type {number} */
    212     this.addedCount;
    213     /** @type {number} */
    214     this.removedCount;
    215     /** @type {number} */
    216     this.addedSize;
    217     /** @type {number} */
    218     this.removedSize;
    219     /** @type {!Array.<number>} */
    220     this.deletedIndexes;
    221     /** @type {!Array.<number>} */
    222     this.addedIndexes;
    223 
    224     /** @type {number} */
    225     this.countDelta;
    226     /** @type {number} */
    227     this.sizeDelta;
    228 }
    229 
    230 /**
    231  * @constructor
    232  */
    233 WebInspector.HeapSnapshotCommon.ComparatorConfig = function()
    234 {
    235     /** @type {string} */
    236     this.fieldName1;
    237     /** @type {boolean} */
    238     this.ascending1;
    239     /** @type {string} */
    240     this.fieldName2;
    241     /** @type {boolean} */
    242     this.ascending2;
    243 }
    244 
    245 /**
    246  * @constructor
    247  */
    248 WebInspector.HeapSnapshotCommon.WorkerCommand = function()
    249 {
    250     /** @type {number} */
    251     this.callId;
    252     /** @type {string} */
    253     this.disposition;
    254     /** @type {number} */
    255     this.objectId;
    256     /** @type {number} */
    257     this.newObjectId;
    258     /** @type {string} */
    259     this.methodName;
    260     /** @type {!Array.<*>} */
    261     this.methodArguments;
    262     /** @type {string} */
    263     this.source;
    264 }
    265 
    266 /**
    267  * @constructor
    268  * @param {number} startPosition
    269  * @param {number} endPosition
    270  * @param {number} totalLength
    271  * @param {!Array.<*>} items
    272  */
    273 WebInspector.HeapSnapshotCommon.ItemsRange = function(startPosition, endPosition, totalLength, items)
    274 {
    275     /** @type {number} */
    276     this.startPosition = startPosition;
    277     /** @type {number} */
    278     this.endPosition = endPosition;
    279     /** @type {number} */
    280     this.totalLength = totalLength;
    281     /** @type {!Array.<*>} */
    282     this.items = items;
    283 }
    284 
    285 /**
    286  * @param {number} nodeCount
    287  * @param {number} rootNodeIndex
    288  * @param {number} totalSize
    289  * @param {number} maxJSObjectId
    290  * @constructor
    291  */
    292 WebInspector.HeapSnapshotCommon.StaticData = function(nodeCount, rootNodeIndex, totalSize, maxJSObjectId)
    293 {
    294     /** @type {number} */
    295     this.nodeCount = nodeCount;
    296     /** @type {number} */
    297     this.rootNodeIndex = rootNodeIndex;
    298     /** @type {number} */
    299     this.totalSize = totalSize;
    300     /** @type {number} */
    301     this.maxJSObjectId = maxJSObjectId;
    302 }
    303 
    304 /**
    305  * @constructor
    306  */
    307 WebInspector.HeapSnapshotCommon.Statistics = function()
    308 {
    309     /** @type {number} */
    310     this.total;
    311     /** @type {number} */
    312     this.v8heap;
    313     /** @type {number} */
    314     this.native;
    315     /** @type {number} */
    316     this.code;
    317     /** @type {number} */
    318     this.jsArrays;
    319     /** @type {number} */
    320     this.strings;
    321 }
    322 
    323 
    324 /**
    325  * @param {number=} minNodeId
    326  * @param {number=} maxNodeId
    327  * @constructor
    328  */
    329 WebInspector.HeapSnapshotCommon.NodeFilter = function(minNodeId, maxNodeId)
    330 {
    331     /** @type {number|undefined} */
    332     this.minNodeId = minNodeId;
    333     /** @type {number|undefined} */
    334     this.maxNodeId = maxNodeId;
    335     /** @type {number|undefined} */
    336     this.allocationNodeId;
    337 }
    338 
    339 WebInspector.HeapSnapshotCommon.NodeFilter.prototype =
    340 {
    341     /**
    342      * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} o
    343      * @return {boolean}
    344      */
    345     equals: function(o)
    346     {
    347         return this.minNodeId === o.minNodeId && this.maxNodeId === o.maxNodeId && this.allocationNodeId === o.allocationNodeId;
    348     }
    349 }
    350