| 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 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 } else { | 1561 } else { |
| 1562 // Done with all the node children | 1562 // Done with all the node children |
| 1563 nodeOrdinal2PostOrderIndex[nodeOrdinal] = postOrderIndex; | 1563 nodeOrdinal2PostOrderIndex[nodeOrdinal] = postOrderIndex; |
| 1564 postOrderIndex2NodeOrdinal[postOrderIndex++] = nodeOrdinal; | 1564 postOrderIndex2NodeOrdinal[postOrderIndex++] = nodeOrdinal; |
| 1565 --stackTop; | 1565 --stackTop; |
| 1566 } | 1566 } |
| 1567 } | 1567 } |
| 1568 | 1568 |
| 1569 if (postOrderIndex === nodeCount || iteration > 1) | 1569 if (postOrderIndex === nodeCount || iteration > 1) |
| 1570 break; | 1570 break; |
| 1571 var errors = new WebInspector.HeapSnapshotProblemReport("Error: Corr
upted snapshot. " + (nodeCount - postOrderIndex) + " nodes are unreachable from
the root:"); | 1571 var errors = new WebInspector.HeapSnapshotProblemReport("Heap snapsh
ot: " + (nodeCount - postOrderIndex) + " nodes are unreachable from the root. Fo
llowing nodes have only weak retainers:"); |
| 1572 var dumpNode = this.rootNode(); | 1572 var dumpNode = this.rootNode(); |
| 1573 // Remove root from the result (last node in the array) and put it a
t the bottom of the stack so that it is | 1573 // Remove root from the result (last node in the array) and put it a
t the bottom of the stack so that it is |
| 1574 // visited after all orphan nodes and their subgraphs. | 1574 // visited after all orphan nodes and their subgraphs. |
| 1575 --postOrderIndex; | 1575 --postOrderIndex; |
| 1576 stackTop = 0; | 1576 stackTop = 0; |
| 1577 stackNodes[0] = rootNodeOrdinal; | 1577 stackNodes[0] = rootNodeOrdinal; |
| 1578 stackCurrentEdge[0] = firstEdgeIndexes[rootNodeOrdinal + 1]; // no n
eed to reiterate its edges | 1578 stackCurrentEdge[0] = firstEdgeIndexes[rootNodeOrdinal + 1]; // no n
eed to reiterate its edges |
| 1579 for (var i = 0; i < nodeCount; ++i) { | 1579 for (var i = 0; i < nodeCount; ++i) { |
| 1580 if (!visited[i]) { | 1580 if (!visited[i]) { |
| 1581 dumpNode.nodeIndex = i * nodeFieldCount; | 1581 dumpNode.nodeIndex = i * nodeFieldCount; |
| 1582 // Add all nodes that have only weak retainers to traverse t
heir subgraphs. | 1582 // Add all nodes that have only weak retainers to traverse t
heir subgraphs. |
| 1583 if (this._hasOnlyWeakRetainers(i)) { | 1583 if (this._hasOnlyWeakRetainers(i)) { |
| 1584 stackNodes[++stackTop] = i; | 1584 stackNodes[++stackTop] = i; |
| 1585 stackCurrentEdge[stackTop] = firstEdgeIndexes[i]; | 1585 stackCurrentEdge[stackTop] = firstEdgeIndexes[i]; |
| 1586 visited[i] = 1; | 1586 visited[i] = 1; |
| 1587 errors.addError(dumpNode.name() + " @" + dumpNode.id() +
" - node has only weak retainers."); | |
| 1588 } else { | |
| 1589 errors.addError(dumpNode.name() + " @" + dumpNode.id()); | 1587 errors.addError(dumpNode.name() + " @" + dumpNode.id()); |
| 1590 } | 1588 } |
| 1591 } | 1589 } |
| 1592 } | 1590 } |
| 1593 this._progress.reportProblem(errors.toString()); | 1591 console.warn(errors.toString()); |
| 1594 } | 1592 } |
| 1595 | 1593 |
| 1596 // If we already processed all orphan nodes that have only weak retainer
s and still have some orphans... | 1594 // If we already processed all orphan nodes that have only weak retainer
s and still have some orphans... |
| 1597 if (postOrderIndex !== nodeCount) { | 1595 if (postOrderIndex !== nodeCount) { |
| 1598 var errors = new WebInspector.HeapSnapshotProblemReport("Error: Stil
l found " + (nodeCount - postOrderIndex) + " unreachable nodes:"); | 1596 var errors = new WebInspector.HeapSnapshotProblemReport("Still found
" + (nodeCount - postOrderIndex) + " unreachable nodes in heap snapshot:"); |
| 1599 var dumpNode = this.rootNode(); | 1597 var dumpNode = this.rootNode(); |
| 1600 // Remove root from the result (last node in the array) and put it a
t the bottom of the stack so that it is | 1598 // Remove root from the result (last node in the array) and put it a
t the bottom of the stack so that it is |
| 1601 // visited after all orphan nodes and their subgraphs. | 1599 // visited after all orphan nodes and their subgraphs. |
| 1602 --postOrderIndex; | 1600 --postOrderIndex; |
| 1603 for (var i = 0; i < nodeCount; ++i) { | 1601 for (var i = 0; i < nodeCount; ++i) { |
| 1604 if (visited[i]) | 1602 if (visited[i]) |
| 1605 continue; | 1603 continue; |
| 1606 dumpNode.nodeIndex = i * nodeFieldCount; | 1604 dumpNode.nodeIndex = i * nodeFieldCount; |
| 1607 errors.addError(dumpNode.name() + " @" + dumpNode.id()); | 1605 errors.addError(dumpNode.name() + " @" + dumpNode.id()); |
| 1608 // Fix it by giving the node a postorder index anyway. | 1606 // Fix it by giving the node a postorder index anyway. |
| 1609 nodeOrdinal2PostOrderIndex[i] = postOrderIndex; | 1607 nodeOrdinal2PostOrderIndex[i] = postOrderIndex; |
| 1610 postOrderIndex2NodeOrdinal[postOrderIndex++] = i; | 1608 postOrderIndex2NodeOrdinal[postOrderIndex++] = i; |
| 1611 } | 1609 } |
| 1612 nodeOrdinal2PostOrderIndex[rootNodeOrdinal] = postOrderIndex; | 1610 nodeOrdinal2PostOrderIndex[rootNodeOrdinal] = postOrderIndex; |
| 1613 postOrderIndex2NodeOrdinal[postOrderIndex++] = rootNodeOrdinal; | 1611 postOrderIndex2NodeOrdinal[postOrderIndex++] = rootNodeOrdinal; |
| 1614 this._progress.reportProblem(errors.toString()); | 1612 console.warn(errors.toString()); |
| 1615 } | 1613 } |
| 1616 | 1614 |
| 1617 return {postOrderIndex2NodeOrdinal: postOrderIndex2NodeOrdinal, nodeOrdi
nal2PostOrderIndex: nodeOrdinal2PostOrderIndex}; | 1615 return {postOrderIndex2NodeOrdinal: postOrderIndex2NodeOrdinal, nodeOrdi
nal2PostOrderIndex: nodeOrdinal2PostOrderIndex}; |
| 1618 }, | 1616 }, |
| 1619 | 1617 |
| 1620 /** | 1618 /** |
| 1621 * @param {number} nodeOrdinal | 1619 * @param {number} nodeOrdinal |
| 1622 * @return {boolean} | 1620 * @return {boolean} |
| 1623 */ | 1621 */ |
| 1624 _hasOnlyWeakRetainers: function(nodeOrdinal) | 1622 _hasOnlyWeakRetainers: function(nodeOrdinal) |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 * @param {number} windowRight | 2356 * @param {number} windowRight |
| 2359 */ | 2357 */ |
| 2360 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) | 2358 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) |
| 2361 { | 2359 { |
| 2362 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); | 2360 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); |
| 2363 }, | 2361 }, |
| 2364 | 2362 |
| 2365 __proto__: WebInspector.HeapSnapshotItemProvider.prototype | 2363 __proto__: WebInspector.HeapSnapshotItemProvider.prototype |
| 2366 } | 2364 } |
| 2367 | 2365 |
| OLD | NEW |