Changeset 244308 in webkit
- Timestamp:
- Apr 15, 2019 4:48:57 PM (5 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r244294 r244308 1 2019-04-15 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Heap: don't use recursion when calculating root paths 4 https://bugs.webkit.org/show_bug.cgi?id=196890 5 <rdar://problem/49870751> 6 7 Reviewed by Joseph Pecoraro. 8 9 * UserInterface/Workers/HeapSnapshot/HeapSnapshot.js: 10 (HeapSnapshot.prototype.shortestGCRootPath): 11 (HeapSnapshot.prototype._determineGCRootPaths): 12 (HeapSnapshot.prototype._gcRootPathes.visitNode): Deleted. 13 (HeapSnapshot.prototype._gcRootPathes): Deleted. 14 1 15 2019-04-15 Joseph Pecoraro <pecoraro@apple.com> 2 16 -
trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js
r241787 r244308 279 279 // node is either a gcRoot or only reachable via Internal nodes. 280 280 281 let paths = this._ gcRootPathes(nodeIdentifier);281 let paths = this._determineGCRootPaths(nodeIdentifier); 282 282 if (!paths.length) 283 283 return []; … … 735 735 } 736 736 737 _ gcRootPathes(nodeIdentifier)737 _determineGCRootPaths(nodeIdentifier) 738 738 { 739 739 let targetNodeOrdinal = this._nodeIdentifierToOrdinal.get(nodeIdentifier); … … 744 744 // FIXME: Array push/pop can affect performance here, but in practice it hasn't been an issue. 745 745 746 let paths = []; 747 let currentPath = []; 746 let gcRootPaths = []; 748 747 let visited = new Uint8Array(this._nodeCount); 749 748 750 function visitNode(nodeOrdinal) 751 { 749 let pathsBeingProcessed = [ 750 { 751 currentPath: [], 752 nodeOrdinal: targetNodeOrdinal, 753 }, 754 ]; 755 for (let i = 0; i < pathsBeingProcessed.length; ++i) { 756 let {currentPath, nodeOrdinal} = pathsBeingProcessed[i]; 757 758 // Rather than use `Array.prototype.unshift`, which may be very expensive, keep track of 759 // the "current" position as `i` and "delete" the values already processed by clearing 760 // the value at that index. 761 pathsBeingProcessed[i] = undefined; 762 752 763 if (this._nodeOrdinalIsGCRoot[nodeOrdinal]) { 753 764 let fullPath = currentPath.slice(); 754 765 let nodeIndex = nodeOrdinal * this._nodeFieldCount; 755 766 fullPath.push({node: nodeIndex}); 756 paths.push(fullPath);757 return;767 gcRootPaths.push(fullPath); 768 continue; 758 769 } 759 770 760 771 if (visited[nodeOrdinal]) 761 return; 772 continue; 773 762 774 visited[nodeOrdinal] = 1; 763 775 … … 776 788 continue; 777 789 778 let edgeIndex = this._incomingEdges[incomingEdgeIndex]; 779 currentPath.push({edge: edgeIndex}); 780 visitNode.call(this, fromNodeOrdinal); 781 currentPath.pop(); 790 let newPath = currentPath.slice(); 791 newPath.push({edge: this._incomingEdges[incomingEdgeIndex]}); 792 pathsBeingProcessed.push({currentPath: newPath, nodeOrdinal: fromNodeOrdinal}); 782 793 } 783 784 currentPath.pop(); 785 } 786 787 visitNode.call(this, targetNodeOrdinal); 788 789 return paths; 794 } 795 796 return gcRootPaths; 790 797 } 791 798 };
Note: See TracChangeset
for help on using the changeset viewer.