Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Unified Diff: third_party/WebKit/Source/devtools/front_end/heap_snapshot_worker/HeapSnapshot.js

Issue 2197853002: DevTools: Take into account links from root to user global objects when building heap snapshot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/heap_snapshot_worker/HeapSnapshot.js
diff --git a/third_party/WebKit/Source/devtools/front_end/heap_snapshot_worker/HeapSnapshot.js b/third_party/WebKit/Source/devtools/front_end/heap_snapshot_worker/HeapSnapshot.js
index 286a071da499ee19eb340b9faad73aeab855d6c3..de3d6f4bf2d4761d74b15ddd879c89bfe0ce3904 100644
--- a/third_party/WebKit/Source/devtools/front_end/heap_snapshot_worker/HeapSnapshot.js
+++ b/third_party/WebKit/Source/devtools/front_end/heap_snapshot_worker/HeapSnapshot.js
@@ -1030,7 +1030,7 @@ WebInspector.HeapSnapshot.prototype = {
this._dominatorsTree = this._buildDominatorTree(result.postOrderIndex2NodeOrdinal, result.nodeOrdinal2PostOrderIndex);
this._progress.updateStatus("Calculating retained sizes\u2026");
this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);
- this._progress.updateStatus("Buiding dominated nodes\u2026");
+ this._progress.updateStatus("Building dominated nodes\u2026");
this._buildDominatedNodes();
this._progress.updateStatus("Calculating statistics\u2026");
this._calculateStatistics();
@@ -1596,6 +1596,20 @@ WebInspector.HeapSnapshot.prototype = {
});
},
+ /**
+ * The function checks is the edge should be considered during building
+ * postorder iterator and dominator tree.
+ *
+ * @param {number} nodeIndex
+ * @param {number} edgeType
+ * @return {boolean}
+ */
+ _isEssentialEdge: function(nodeIndex, edgeType)
+ {
+ // Shortcuts at the root node have special meaning of marking user global objects.
+ return edgeType !== this._edgeWeakType && (edgeType !== this._edgeShortcutType || nodeIndex === this._rootNodeIndex);
+ },
+
_buildPostOrderIndex: function()
{
var nodeFieldCount = this._nodeFieldCount;
@@ -1605,8 +1619,6 @@ WebInspector.HeapSnapshot.prototype = {
var edgeFieldsCount = this._edgeFieldsCount;
var edgeTypeOffset = this._edgeTypeOffset;
var edgeToNodeOffset = this._edgeToNodeOffset;
- var edgeShortcutType = this._edgeShortcutType;
- var edgeWeakType = this._edgeWeakType;
var firstEdgeIndexes = this._firstEdgeIndexes;
var containmentEdges = this.containmentEdges;
@@ -1637,7 +1649,7 @@ WebInspector.HeapSnapshot.prototype = {
if (edgeIndex < edgesEnd) {
stackCurrentEdge[stackTop] += edgeFieldsCount;
var edgeType = containmentEdges[edgeIndex + edgeTypeOffset];
- if (edgeType === edgeWeakType || edgeType === edgeShortcutType)
+ if (!this._isEssentialEdge(nodeOrdinal * nodeFieldCount, edgeType))
continue;
var childNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
var childNodeOrdinal = childNodeIndex / nodeFieldCount;
@@ -1751,8 +1763,6 @@ WebInspector.HeapSnapshot.prototype = {
var edgeFieldsCount = this._edgeFieldsCount;
var edgeTypeOffset = this._edgeTypeOffset;
var edgeToNodeOffset = this._edgeToNodeOffset;
- var edgeShortcutType = this._edgeShortcutType;
- var edgeWeakType = this._edgeWeakType;
var firstEdgeIndexes = this._firstEdgeIndexes;
var containmentEdges = this.containmentEdges;
var rootNodeIndex = this._rootNodeIndex;
@@ -1777,11 +1787,9 @@ WebInspector.HeapSnapshot.prototype = {
{ // Mark the root direct children as affected.
nodeOrdinal = this._rootNodeIndex / nodeFieldCount;
var endEdgeIndex = firstEdgeIndexes[nodeOrdinal + 1];
- for (var edgeIndex = firstEdgeIndexes[nodeOrdinal];
- edgeIndex < endEdgeIndex;
- edgeIndex += edgeFieldsCount) {
+ for (var edgeIndex = firstEdgeIndexes[nodeOrdinal]; edgeIndex < endEdgeIndex; edgeIndex += edgeFieldsCount) {
var edgeType = containmentEdges[edgeIndex + edgeTypeOffset];
- if (edgeType === edgeWeakType || edgeType === edgeShortcutType)
+ if (!this._isEssentialEdge(this._rootNodeIndex, edgeType))
continue;
var childNodeOrdinal = containmentEdges[edgeIndex + edgeToNodeOffset] / nodeFieldCount;
affected[nodeOrdinal2PostOrderIndex[childNodeOrdinal]] = 1;
@@ -1808,10 +1816,10 @@ WebInspector.HeapSnapshot.prototype = {
for (var retainerIndex = beginRetainerIndex; retainerIndex < endRetainerIndex; ++retainerIndex) {
var retainerEdgeIndex = retainingEdges[retainerIndex];
var retainerEdgeType = containmentEdges[retainerEdgeIndex + edgeTypeOffset];
- if (retainerEdgeType === edgeWeakType || retainerEdgeType === edgeShortcutType)
+ var retainerNodeIndex = retainingNodes[retainerIndex];
+ if (!this._isEssentialEdge(retainerNodeIndex, retainerEdgeType))
continue;
orphanNode = false;
- var retainerNodeIndex = retainingNodes[retainerIndex];
var retainerNodeOrdinal = retainerNodeIndex / nodeFieldCount;
var retainerNodeFlag = !flags || (flags[retainerNodeOrdinal] & flag);
// We are skipping the edges from non-page-owned nodes to page-owned nodes.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698