| 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 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 var nodes = this._nodes; | 1505 var nodes = this._nodes; |
| 1506 var nodeCount = this.nodeCount; | 1506 var nodeCount = this.nodeCount; |
| 1507 var rootNodeOrdinal = this._rootNodeIndex / nodeFieldCount; | 1507 var rootNodeOrdinal = this._rootNodeIndex / nodeFieldCount; |
| 1508 | 1508 |
| 1509 var edgeFieldsCount = this._edgeFieldsCount; | 1509 var edgeFieldsCount = this._edgeFieldsCount; |
| 1510 var edgeTypeOffset = this._edgeTypeOffset; | 1510 var edgeTypeOffset = this._edgeTypeOffset; |
| 1511 var edgeToNodeOffset = this._edgeToNodeOffset; | 1511 var edgeToNodeOffset = this._edgeToNodeOffset; |
| 1512 var edgeShortcutType = this._edgeShortcutType; | 1512 var edgeShortcutType = this._edgeShortcutType; |
| 1513 var firstEdgeIndexes = this._firstEdgeIndexes; | 1513 var firstEdgeIndexes = this._firstEdgeIndexes; |
| 1514 var containmentEdges = this._containmentEdges; | 1514 var containmentEdges = this._containmentEdges; |
| 1515 var containmentEdgesLength = this._containmentEdges.length; | |
| 1516 | 1515 |
| 1517 var mapAndFlag = this.userObjectsMapAndFlag(); | 1516 var mapAndFlag = this.userObjectsMapAndFlag(); |
| 1518 var flags = mapAndFlag ? mapAndFlag.map : null; | 1517 var flags = mapAndFlag ? mapAndFlag.map : null; |
| 1519 var flag = mapAndFlag ? mapAndFlag.flag : 0; | 1518 var flag = mapAndFlag ? mapAndFlag.flag : 0; |
| 1520 | 1519 |
| 1521 var nodesToVisit = new Uint32Array(nodeCount); | 1520 var stackNodes = new Uint32Array(nodeCount); |
| 1521 var stackCurrentEdge = new Uint32Array(nodeCount); |
| 1522 var postOrderIndex2NodeOrdinal = new Uint32Array(nodeCount); | 1522 var postOrderIndex2NodeOrdinal = new Uint32Array(nodeCount); |
| 1523 var nodeOrdinal2PostOrderIndex = new Uint32Array(nodeCount); | 1523 var nodeOrdinal2PostOrderIndex = new Uint32Array(nodeCount); |
| 1524 var painted = new Uint8Array(nodeCount); | 1524 var visited = new Uint8Array(nodeCount); |
| 1525 var nodesToVisitLength = 0; | |
| 1526 var postOrderIndex = 0; | 1525 var postOrderIndex = 0; |
| 1527 var grey = 1; | |
| 1528 var black = 2; | |
| 1529 | 1526 |
| 1530 nodesToVisit[nodesToVisitLength++] = rootNodeOrdinal; | 1527 var stackTop = 0; |
| 1531 painted[rootNodeOrdinal] = grey; | 1528 stackNodes[0] = rootNodeOrdinal; |
| 1529 stackCurrentEdge[0] = firstEdgeIndexes[rootNodeOrdinal]; |
| 1530 visited[rootNodeOrdinal] = 1; |
| 1532 | 1531 |
| 1533 while (nodesToVisitLength) { | 1532 while (stackTop >= 0) { |
| 1534 var nodeOrdinal = nodesToVisit[nodesToVisitLength - 1]; | 1533 var nodeOrdinal = stackNodes[stackTop]; |
| 1534 var edgeIndex = stackCurrentEdge[stackTop]; |
| 1535 var edgesEnd = firstEdgeIndexes[nodeOrdinal + 1]; |
| 1535 | 1536 |
| 1536 if (painted[nodeOrdinal] === grey) { | 1537 if (edgeIndex < edgesEnd) { |
| 1537 painted[nodeOrdinal] = black; | 1538 stackCurrentEdge[stackTop] += edgeFieldsCount; |
| 1539 if (nodeOrdinal !== rootNodeOrdinal && containmentEdges[edgeInde
x + edgeTypeOffset] === edgeShortcutType) |
| 1540 continue; |
| 1541 var childNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffs
et]; |
| 1542 var childNodeOrdinal = childNodeIndex / nodeFieldCount; |
| 1543 if (visited[childNodeOrdinal]) |
| 1544 continue; |
| 1538 var nodeFlag = !flags || (flags[nodeOrdinal] & flag); | 1545 var nodeFlag = !flags || (flags[nodeOrdinal] & flag); |
| 1539 var beginEdgeIndex = firstEdgeIndexes[nodeOrdinal]; | 1546 var childNodeFlag = !flags || (flags[childNodeOrdinal] & flag); |
| 1540 var endEdgeIndex = firstEdgeIndexes[nodeOrdinal + 1]; | 1547 // We are skipping the edges from non-page-owned nodes to page-o
wned nodes. |
| 1541 for (var edgeIndex = beginEdgeIndex; edgeIndex < endEdgeIndex; e
dgeIndex += edgeFieldsCount) { | 1548 // Otherwise the dominators for the objects that also were retai
ned by debugger would be affected. |
| 1542 if (nodeOrdinal !== rootNodeOrdinal && containmentEdges[edge
Index + edgeTypeOffset] === edgeShortcutType) | 1549 if (nodeOrdinal !== rootNodeOrdinal && childNodeFlag && !nodeFla
g) |
| 1543 continue; | 1550 continue; |
| 1544 var childNodeIndex = containmentEdges[edgeIndex + edgeToNode
Offset]; | 1551 ++stackTop; |
| 1545 var childNodeOrdinal = childNodeIndex / nodeFieldCount; | 1552 stackNodes[stackTop] = childNodeOrdinal; |
| 1546 var childNodeFlag = !flags || (flags[childNodeOrdinal] & fla
g); | 1553 stackCurrentEdge[stackTop] = firstEdgeIndexes[childNodeOrdinal]; |
| 1547 // We are skipping the edges from non-page-owned nodes to pa
ge-owned nodes. | 1554 visited[childNodeOrdinal] = 1; |
| 1548 // Otherwise the dominators for the objects that also were r
etained by debugger would be affected. | |
| 1549 if (nodeOrdinal !== rootNodeOrdinal && childNodeFlag && !nod
eFlag) | |
| 1550 continue; | |
| 1551 if (!painted[childNodeOrdinal]) { | |
| 1552 painted[childNodeOrdinal] = grey; | |
| 1553 nodesToVisit[nodesToVisitLength++] = childNodeOrdinal; | |
| 1554 } | |
| 1555 } | |
| 1556 } else { | 1555 } else { |
| 1556 // Done with all the node children |
| 1557 nodeOrdinal2PostOrderIndex[nodeOrdinal] = postOrderIndex; | 1557 nodeOrdinal2PostOrderIndex[nodeOrdinal] = postOrderIndex; |
| 1558 postOrderIndex2NodeOrdinal[postOrderIndex++] = nodeOrdinal; | 1558 postOrderIndex2NodeOrdinal[postOrderIndex++] = nodeOrdinal; |
| 1559 --nodesToVisitLength; | 1559 --stackTop; |
| 1560 } | 1560 } |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 if (postOrderIndex !== nodeCount) { | 1563 if (postOrderIndex !== nodeCount) { |
| 1564 console.log("Error: Corrupted snapshot. " + (nodeCount - postOrderIn
dex) + " nodes are unreachable from the root:"); | 1564 console.log("Error: Corrupted snapshot. " + (nodeCount - postOrderIn
dex) + " nodes are unreachable from the root:"); |
| 1565 var dumpNode = this.rootNode(); | 1565 var dumpNode = this.rootNode(); |
| 1566 for (var i = 0; i < nodeCount; ++i) { | 1566 for (var i = 0; i < nodeCount; ++i) { |
| 1567 if (painted[i] !== black) { | 1567 if (!visited[i]) { |
| 1568 // Fix it by giving the node a postorder index anyway. | 1568 // Fix it by giving the node a postorder index anyway. |
| 1569 nodeOrdinal2PostOrderIndex[i] = postOrderIndex; | 1569 nodeOrdinal2PostOrderIndex[i] = postOrderIndex; |
| 1570 postOrderIndex2NodeOrdinal[postOrderIndex++] = i; | 1570 postOrderIndex2NodeOrdinal[postOrderIndex++] = i; |
| 1571 dumpNode.nodeIndex = i * nodeFieldCount; | 1571 dumpNode.nodeIndex = i * nodeFieldCount; |
| 1572 console.log(JSON.stringify(dumpNode.serialize())); | 1572 console.log(JSON.stringify(dumpNode.serialize())); |
| 1573 for (var retainers = dumpNode.retainers(); retainers.hasNext
(); retainers = retainers.item().node().retainers()) | 1573 for (var retainers = dumpNode.retainers(); retainers.hasNext
(); retainers = retainers.item().node().retainers()) |
| 1574 console.log(" edgeName: " + retainers.item().name() + "
nodeClassName: " + retainers.item().node().className()); | 1574 console.log(" edgeName: " + retainers.item().name() + "
nodeClassName: " + retainers.item().node().className()); |
| 1575 } | 1575 } |
| 1576 } | 1576 } |
| 1577 } | 1577 } |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 * @param {number} windowRight | 2311 * @param {number} windowRight |
| 2312 */ | 2312 */ |
| 2313 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) | 2313 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) |
| 2314 { | 2314 { |
| 2315 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); | 2315 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); |
| 2316 }, | 2316 }, |
| 2317 | 2317 |
| 2318 __proto__: WebInspector.HeapSnapshotItemProvider.prototype | 2318 __proto__: WebInspector.HeapSnapshotItemProvider.prototype |
| 2319 } | 2319 } |
| 2320 | 2320 |
| OLD | NEW |