OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 }); | 144 }); |
145 return result; | 145 return result; |
146 }, | 146 }, |
147 | 147 |
148 /** | 148 /** |
149 * @param {string} nodeId | 149 * @param {string} nodeId |
150 * @return {!WebInspector.HeapSnapshotCommon.AllocationNodeCallers} | 150 * @return {!WebInspector.HeapSnapshotCommon.AllocationNodeCallers} |
151 */ | 151 */ |
152 serializeCallers: function(nodeId) | 152 serializeCallers: function(nodeId) |
153 { | 153 { |
154 var node = this._idToNode[nodeId]; | 154 var node = this._ensureBottomUpNode(nodeId); |
155 if (!node) { | |
156 var functionInfo = this._collapsedTopNodeIdToFunctionInfo[nodeId]; | |
157 node = functionInfo.bottomUpRoot(); | |
158 delete this._collapsedTopNodeIdToFunctionInfo[nodeId]; | |
159 this._idToNode[nodeId] = node; | |
160 } | |
161 | |
162 var nodesWithSingleCaller = []; | 155 var nodesWithSingleCaller = []; |
163 while (node.callers().length === 1) { | 156 while (node.callers().length === 1) { |
164 node = node.callers()[0]; | 157 node = node.callers()[0]; |
165 nodesWithSingleCaller.push(this._serializeCaller(node)); | 158 nodesWithSingleCaller.push(this._serializeCaller(node)); |
166 } | 159 } |
167 | 160 |
168 var branchingCallers = []; | 161 var branchingCallers = []; |
169 var callers = node.callers(); | 162 var callers = node.callers(); |
170 for (var i = 0; i < callers.length; i++) { | 163 for (var i = 0; i < callers.length; i++) { |
171 branchingCallers.push(this._serializeCaller(callers[i])); | 164 branchingCallers.push(this._serializeCaller(callers[i])); |
172 } | 165 } |
173 return new WebInspector.HeapSnapshotCommon.AllocationNodeCallers(nodesWi thSingleCaller, branchingCallers); | 166 return new WebInspector.HeapSnapshotCommon.AllocationNodeCallers(nodesWi thSingleCaller, branchingCallers); |
174 }, | 167 }, |
175 | 168 |
169 /** | |
170 * @param {number} allocationNodeId | |
171 * @return {!Array.<number>} | |
172 */ | |
173 traceIds: function(allocationNodeId) | |
174 { | |
175 return this._ensureBottomUpNode(allocationNodeId).traceTopIds; | |
176 }, | |
177 | |
178 _ensureBottomUpNode: function(nodeId) | |
alph
2014/03/18 12:28:22
annotate?
yurys
2014/03/18 12:30:47
Done.
| |
179 { | |
180 var node = this._idToNode[nodeId]; | |
181 if (!node) { | |
182 var functionInfo = this._collapsedTopNodeIdToFunctionInfo[nodeId]; | |
183 node = functionInfo.bottomUpRoot(); | |
184 delete this._collapsedTopNodeIdToFunctionInfo[nodeId]; | |
185 this._idToNode[nodeId] = node; | |
186 } | |
187 return node; | |
188 }, | |
189 | |
176 _serializeCaller: function(node) | 190 _serializeCaller: function(node) |
177 { | 191 { |
178 var callerId = this._nextNodeId++; | 192 var callerId = this._nextNodeId++; |
179 this._idToNode[callerId] = node; | 193 this._idToNode[callerId] = node; |
180 return this._serializeNode( | 194 return this._serializeNode( |
181 callerId, | 195 callerId, |
182 node.functionInfo, | 196 node.functionInfo, |
183 node.allocationCount, | 197 node.allocationCount, |
184 node.allocationSize, | 198 node.allocationSize, |
185 node.liveCount, | 199 node.liveCount, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 * @constructor | 256 * @constructor |
243 * @param {!WebInspector.FunctionAllocationInfo} functionInfo | 257 * @param {!WebInspector.FunctionAllocationInfo} functionInfo |
244 */ | 258 */ |
245 WebInspector.BottomUpAllocationNode = function(functionInfo) | 259 WebInspector.BottomUpAllocationNode = function(functionInfo) |
246 { | 260 { |
247 this.functionInfo = functionInfo; | 261 this.functionInfo = functionInfo; |
248 this.allocationCount = 0; | 262 this.allocationCount = 0; |
249 this.allocationSize = 0; | 263 this.allocationSize = 0; |
250 this.liveCount = 0; | 264 this.liveCount = 0; |
251 this.liveSize = 0; | 265 this.liveSize = 0; |
266 this.traceTopIds = []; | |
252 this._callers = []; | 267 this._callers = []; |
253 } | 268 } |
254 | 269 |
255 | 270 |
256 WebInspector.BottomUpAllocationNode.prototype = { | 271 WebInspector.BottomUpAllocationNode.prototype = { |
257 /** | 272 /** |
258 * @param {!WebInspector.TopDownAllocationNode} traceNode | 273 * @param {!WebInspector.TopDownAllocationNode} traceNode |
259 * @return {!WebInspector.TopDownAllocationNode} | 274 * @return {!WebInspector.BottomUpAllocationNode} |
260 */ | 275 */ |
261 addCaller: function(traceNode) | 276 addCaller: function(traceNode) |
262 { | 277 { |
263 var functionInfo = traceNode.functionInfo; | 278 var functionInfo = traceNode.functionInfo; |
264 var result; | 279 var result; |
265 for (var i = 0; i < this._callers.length; i++) { | 280 for (var i = 0; i < this._callers.length; i++) { |
266 var caller = this._callers[i]; | 281 var caller = this._callers[i]; |
267 if (caller.functionInfo === functionInfo) { | 282 if (caller.functionInfo === functionInfo) { |
268 result = caller; | 283 result = caller; |
269 break; | 284 break; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 { | 362 { |
348 this._bottomUpTree = new WebInspector.BottomUpAllocationNode(this); | 363 this._bottomUpTree = new WebInspector.BottomUpAllocationNode(this); |
349 | 364 |
350 for (var i = 0; i < this._traceTops.length; i++) { | 365 for (var i = 0; i < this._traceTops.length; i++) { |
351 var node = this._traceTops[i]; | 366 var node = this._traceTops[i]; |
352 var bottomUpNode = this._bottomUpTree; | 367 var bottomUpNode = this._bottomUpTree; |
353 var count = node.allocationCount; | 368 var count = node.allocationCount; |
354 var size = node.allocationSize; | 369 var size = node.allocationSize; |
355 var liveCount = node.liveCount; | 370 var liveCount = node.liveCount; |
356 var liveSize = node.liveSize; | 371 var liveSize = node.liveSize; |
372 var traceId = node.id; | |
357 while (true) { | 373 while (true) { |
358 bottomUpNode.allocationCount += count; | 374 bottomUpNode.allocationCount += count; |
359 bottomUpNode.allocationSize += size; | 375 bottomUpNode.allocationSize += size; |
360 bottomUpNode.liveCount += liveCount; | 376 bottomUpNode.liveCount += liveCount; |
361 bottomUpNode.liveSize += liveSize; | 377 bottomUpNode.liveSize += liveSize; |
378 bottomUpNode.traceTopIds.push(traceId); | |
362 node = node.parent; | 379 node = node.parent; |
363 if (node === null) { | 380 if (node === null) { |
364 break; | 381 break; |
365 } | 382 } |
366 bottomUpNode = bottomUpNode.addCaller(node); | 383 bottomUpNode = bottomUpNode.addCaller(node); |
367 } | 384 } |
368 } | 385 } |
369 } | 386 } |
370 } | 387 } |
OLD | NEW |