OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 var nodes = this._nodes; | 766 var nodes = this._nodes; |
767 var nodesLength = nodes.length; | 767 var nodesLength = nodes.length; |
768 var nodeFieldCount = this._nodeFieldCount; | 768 var nodeFieldCount = this._nodeFieldCount; |
769 var node = this.rootNode(); | 769 var node = this.rootNode(); |
770 var liveObjects = {}; | 770 var liveObjects = {}; |
771 for (var nodeIndex = 0; nodeIndex < nodesLength; nodeIndex += nodeFieldC
ount) { | 771 for (var nodeIndex = 0; nodeIndex < nodesLength; nodeIndex += nodeFieldC
ount) { |
772 node.nodeIndex = nodeIndex; | 772 node.nodeIndex = nodeIndex; |
773 var traceNodeId = node.traceNodeId(); | 773 var traceNodeId = node.traceNodeId(); |
774 var stats = liveObjects[traceNodeId]; | 774 var stats = liveObjects[traceNodeId]; |
775 if (!stats) { | 775 if (!stats) { |
776 liveObjects[traceNodeId] = stats = { count: 0, size: 0}; | 776 liveObjects[traceNodeId] = stats = { count: 0, size: 0, ids: []}
; |
777 } | 777 } |
778 stats.count++; | 778 stats.count++; |
779 stats.size += node.selfSize(); | 779 stats.size += node.selfSize(); |
| 780 stats.ids.push(node.id()); |
780 } | 781 } |
781 this._allocationProfile = new WebInspector.AllocationProfile(profile, li
veObjects); | 782 this._allocationProfile = new WebInspector.AllocationProfile(profile, li
veObjects); |
782 this._progress.updateStatus("Done"); | 783 this._progress.updateStatus("Done"); |
783 } | 784 } |
784 } | 785 } |
785 | 786 |
786 /** | 787 /** |
787 * @constructor | 788 * @constructor |
788 */ | 789 */ |
789 function HeapSnapshotMetainfo() | 790 function HeapSnapshotMetainfo() |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 }, | 1006 }, |
1006 | 1007 |
1007 /** | 1008 /** |
1008 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter | 1009 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter |
1009 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} | 1010 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} |
1010 */ | 1011 */ |
1011 aggregatesWithFilter: function(nodeFilter) | 1012 aggregatesWithFilter: function(nodeFilter) |
1012 { | 1013 { |
1013 var minNodeId = nodeFilter.minNodeId; | 1014 var minNodeId = nodeFilter.minNodeId; |
1014 var maxNodeId = nodeFilter.maxNodeId; | 1015 var maxNodeId = nodeFilter.maxNodeId; |
| 1016 var allocationNodeId = nodeFilter.allocationNodeId; |
1015 var key; | 1017 var key; |
1016 var filter; | 1018 var filter; |
1017 /** | 1019 if (typeof allocationNodeId === "number") { |
1018 * @param {!WebInspector.HeapSnapshotNode} node | 1020 filter = this._createAllocationStackFilter(allocationNodeId); |
1019 * @return boolean | 1021 } else if (typeof minNodeId === "number" && typeof maxNodeId === "number
") { |
1020 */ | |
1021 function filterById(node) | |
1022 { | |
1023 var id = node.id(); | |
1024 return id > minNodeId && id <= maxNodeId; | |
1025 } | |
1026 if (typeof minNodeId === "number") { | |
1027 key = minNodeId + ".." + maxNodeId; | 1022 key = minNodeId + ".." + maxNodeId; |
1028 filter = filterById; | 1023 filter = this._createNodeIdFilter(minNodeId, maxNodeId); |
1029 } else { | 1024 } else { |
1030 key = "allObjects"; | 1025 key = "allObjects"; |
1031 } | 1026 } |
1032 return this.aggregates(false, key, filter); | 1027 return this.aggregates(false, key, filter); |
1033 }, | 1028 }, |
1034 | 1029 |
1035 /** | 1030 /** |
| 1031 * @param {number} minNodeId |
| 1032 * @param {number} maxNodeId |
| 1033 * @return {function(!WebInspector.HeapSnapshotNode):boolean} |
| 1034 */ |
| 1035 _createNodeIdFilter: function(minNodeId, maxNodeId) |
| 1036 { |
| 1037 /** |
| 1038 * @param {!WebInspector.HeapSnapshotNode} node |
| 1039 * @return boolean |
| 1040 */ |
| 1041 function nodeIdFilter(node) |
| 1042 { |
| 1043 var id = node.id(); |
| 1044 return id > minNodeId && id <= maxNodeId; |
| 1045 } |
| 1046 return nodeIdFilter; |
| 1047 }, |
| 1048 |
| 1049 /** |
| 1050 * @param {number} bottomUpAllocationNodeId |
| 1051 * @return {function(!WebInspector.HeapSnapshotNode):boolean|undefined} |
| 1052 */ |
| 1053 _createAllocationStackFilter: function(bottomUpAllocationNodeId) |
| 1054 { |
| 1055 var traceIds = this._allocationProfile.traceIds(bottomUpAllocationNodeId
); |
| 1056 if (!traceIds.length) |
| 1057 return undefined; |
| 1058 var set = {}; |
| 1059 for (var i = 0; i < traceIds.length; i++) |
| 1060 set[traceIds[i]] = true; |
| 1061 /** |
| 1062 * @param {!WebInspector.HeapSnapshotNode} node |
| 1063 * @return boolean |
| 1064 */ |
| 1065 function traceIdFilter(node) |
| 1066 { |
| 1067 return !!set[node.traceNodeId()]; |
| 1068 }; |
| 1069 return traceIdFilter; |
| 1070 }, |
| 1071 |
| 1072 /** |
1036 * @param {boolean} sortedIndexes | 1073 * @param {boolean} sortedIndexes |
1037 * @param {string} key | 1074 * @param {string=} key |
1038 * @param {function(!WebInspector.HeapSnapshotNode):boolean=} filter | 1075 * @param {function(!WebInspector.HeapSnapshotNode):boolean=} filter |
1039 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} | 1076 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} |
1040 */ | 1077 */ |
1041 aggregates: function(sortedIndexes, key, filter) | 1078 aggregates: function(sortedIndexes, key, filter) |
1042 { | 1079 { |
1043 var aggregatesByClassName = this._aggregates[key]; | 1080 var aggregatesByClassName = key && this._aggregates[key]; |
1044 if (!aggregatesByClassName) { | 1081 if (!aggregatesByClassName) { |
1045 var aggregates = this._buildAggregates(filter); | 1082 var aggregates = this._buildAggregates(filter); |
1046 this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex
, filter); | 1083 this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex
, filter); |
1047 aggregatesByClassName = aggregates.aggregatesByClassName; | 1084 aggregatesByClassName = aggregates.aggregatesByClassName; |
1048 this._aggregates[key] = aggregatesByClassName; | 1085 if (key) |
| 1086 this._aggregates[key] = aggregatesByClassName; |
1049 } | 1087 } |
1050 | 1088 |
1051 if (sortedIndexes && !this._aggregatesSortedFlags[key]) { | 1089 if (sortedIndexes && (!key || !this._aggregatesSortedFlags[key])) { |
1052 this._sortAggregateIndexes(aggregatesByClassName); | 1090 this._sortAggregateIndexes(aggregatesByClassName); |
1053 this._aggregatesSortedFlags[key] = sortedIndexes; | 1091 if (key) |
| 1092 this._aggregatesSortedFlags[key] = sortedIndexes; |
1054 } | 1093 } |
1055 return aggregatesByClassName; | 1094 return aggregatesByClassName; |
1056 }, | 1095 }, |
1057 | 1096 |
1058 /** | 1097 /** |
1059 * @return {!Array.<!WebInspector.HeapSnapshotCommon.SerializedAllocationNod
e>} | 1098 * @return {!Array.<!WebInspector.HeapSnapshotCommon.SerializedAllocationNod
e>} |
1060 */ | 1099 */ |
1061 allocationTracesTops: function() | 1100 allocationTracesTops: function() |
1062 { | 1101 { |
1063 return this._allocationProfile.serializeTraceTops(); | 1102 return this._allocationProfile.serializeTraceTops(); |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 * @param {number} windowRight | 2261 * @param {number} windowRight |
2223 */ | 2262 */ |
2224 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) | 2263 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) |
2225 { | 2264 { |
2226 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); | 2265 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); |
2227 }, | 2266 }, |
2228 | 2267 |
2229 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype | 2268 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype |
2230 } | 2269 } |
2231 | 2270 |
OLD | NEW |