Changeset 116771 in webkit
- Timestamp:
- May 11, 2012, 8:46:18 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/profiler/heap-snapshot-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/profiler/heap-snapshot-loader-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/profiler/heap-snapshot-loader.html (modified) (1 diff)
-
LayoutTests/inspector/profiler/heap-snapshot-test.js (modified) (6 diffs)
-
LayoutTests/inspector/profiler/heap-snapshot.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/inspector/front-end/HeapSnapshot.js (modified) (16 diffs)
-
Source/WebCore/inspector/front-end/HeapSnapshotLoader.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116766 r116771 1 2012-05-11 Alexei Filippov <alexeif@chromium.org> 2 3 Web Inspector: Remove support of combined nodes and edges serialization schema. 4 https://bugs.webkit.org/show_bug.cgi?id=86209 5 6 Reviewed by Yury Semikhatsky. 7 8 * inspector/profiler/heap-snapshot-expected.txt: 9 * inspector/profiler/heap-snapshot-loader-expected.txt: 10 * inspector/profiler/heap-snapshot-loader.html: 11 * inspector/profiler/heap-snapshot-test.js: 12 (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockObject): 13 (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockRaw): 14 (initialize_HeapSnapshotTest.InspectorTest._postprocessHeapSnapshotMock): 15 (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockWithDOM): 16 (initialize_HeapSnapshotTest.): 17 (initialize_HeapSnapshotTest): 18 * inspector/profiler/heap-snapshot.html: 19 1 20 2012-05-11 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 21 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-expected.txt
r112523 r116771 14 14 Running: heapSnapshotSimpleTest 15 15 16 Running: testNodesAndEdgesSeparationInHeapSnapshot17 18 16 Running: heapSnapshotRetainersTest 19 17 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-loader-expected.txt
r113771 r116771 4 4 Running: heapSnapshotLoaderTest 5 5 6 Running: heapSnapshotSeparateEdgesLoaderTest7 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html
r113771 r116771 22 22 loader.pushJSONChunk(sourceStringified.slice(i, i + partSize)); 23 23 var result = loader.finishLoading(); 24 result._nodes = new Uint32Array(result._nodes); 25 result._containmentEdges = new Uint32Array(result._containmentEdges); 24 26 InspectorTest.assertSnapshotEquals(new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock()), result); 25 next();26 },27 28 function heapSnapshotSeparateEdgesLoaderTest(next)29 {30 var source = InspectorTest.createHeapSnapshotSplitNodesEdgesMockRaw();31 var sourceStringified = JSON.stringify(source);32 var partSize = sourceStringified.length >> 3;33 var loader = new WebInspector.HeapSnapshotLoader();34 for (var i = 0, l = sourceStringified.length; i < l; i += partSize)35 loader.pushJSONChunk(sourceStringified.slice(i, i + partSize));36 var result = loader.finishLoading();37 // Patch it a bit to make it identical to the specimen.38 result._onlyNodes = new Uint32Array(result._onlyNodes);39 result._containmentEdges = new Uint32Array(result._containmentEdges);40 var specimen = new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock());41 delete result._metaNode;42 delete specimen._metaNode;43 delete specimen._edgesCountOffset;44 delete specimen._firstEdgeOffset;45 InspectorTest.assertSnapshotEquals(specimen, result);46 27 next(); 47 28 } -
trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js
r116218 r116771 29 29 // B (6) -bd- D (12) 30 30 // 31 _ onlyNodes: [31 _nodes: [ 32 32 0, 0, 0, 33 33 1, 1, 6, … … 47 47 InspectorTest.createHeapSnapshotMockRaw = function() 48 48 { 49 return { 50 snapshot: {}, 51 nodes: [ 52 { fields: ["type", "name", "id", "self_size", "retained_size", "dominator", "children_count", "children"], 53 types: [["hidden", "object"], "", "", "", "", "", "", { fields: ["type", "name_or_index", "to_node"], types: [["element", "property"], "", ""] }] }, 54 // Effectively the same graph as in createHeapSnapshotMockObject, 55 // but having full set of fields. 56 // 57 // A triple in parentheses indicates node index, self size and 58 // retained size. 59 // 60 // --- A (14,2,2) --ac- C (40,4,10) -ce- E(57,6,6) 61 // / | / 62 // "" (1,0,20) 1 --bc----- 63 // \ v / 64 // --- B (27,3,8) --bd- D (50,5,5) 65 // 66 0, 0, 1, 0, 20, 1, 2, 1, 6, 14, 1, 7, 27, 67 1, 1, 2, 2, 2, 1, 2, 0, 1, 27, 1, 8, 40, 68 1, 2, 3, 3, 8, 1, 2, 1, 9, 40, 1, 10, 50, 69 1, 3, 4, 4, 10, 1, 1, 1, 11, 57, 70 1, 4, 5, 5, 5, 27, 0, 71 1, 5, 6, 6, 6, 40, 0], 72 strings: ["", "A", "B", "C", "D", "E", "a", "b", "ac", "bc", "bd", "ce"] 73 }; 74 }; 75 76 InspectorTest.createHeapSnapshotSplitNodesEdgesMockRaw = function() 77 { 78 // Return the same snapshot as above but having the nodes and edges 79 // separated. 49 // Effectively the same graph as in createHeapSnapshotMockObject, 50 // but having full set of fields. 51 // 52 // A triple in parentheses indicates node index, self size and 53 // retained size. 54 // 55 // --- A (14,2,2) --ac- C (40,4,10) -ce- E(57,6,6) 56 // / | / 57 // "" (1,0,20) 1 --bc----- 58 // \ v / 59 // --- B (27,3,8) --bd- D (50,5,5) 60 // 80 61 return { 81 62 snapshot: { … … 106 87 InspectorTest._postprocessHeapSnapshotMock = function(mock) 107 88 { 108 mock.snapshot.meta = mock.nodes[0]; 109 mock.nodes[0] = 0; 110 var tempNodes = new Int32Array(1000); 111 tempNodes.set(mock.nodes); 112 mock.nodes = tempNodes.subarray(0, mock.nodes.length); 89 mock.nodes = new Int32Array(mock.nodes); 90 mock.edges = new Int32Array(mock.edges); 113 91 return mock; 114 92 }; … … 122 100 { 123 101 return InspectorTest._postprocessHeapSnapshotMock({ 124 snapshot: {}, 102 snapshot: { 103 meta: { 104 node_fields: ["type", "name", "id", "edges_index"], 105 node_types: [["hidden", "object"], "", "", ""], 106 edge_fields: ["type", "name_or_index", "to_node"], 107 edge_types: [["element", "hidden", "internal"], "", ""] 108 }, 109 node_count: 13, 110 edge_count: 13 111 }, 125 112 nodes: [ 126 { fields: ["type", "name", "id", "children_count", "children"],127 types: [["hidden", "object"], "", "", "", { fields: ["type", "name_or_index", "to_node"], types: [["element", "hidden", "internal"], "", ""] }] },128 113 // A tree with Window objects. 129 114 // 130 115 // |----->Window--->A 131 // | \116 // | \ 132 117 // |----->Window--->B--->C 133 118 // | | \ … … 136 121 // |----->E H internal 137 122 // | v 138 // |----->F--->G ------>M123 // |----->F--->G M 139 124 // 140 /* (root) */ 0, 0, 1, 4, 0, 1, 17, 0, 2, 27, 0, 3, 40, 0, 4, 44, 141 /* Window */ 1, 11, 2, 2, 0, 1, 51, 0, 2, 55, 142 /* Window */ 1, 11, 3, 3, 0, 1, 55, 0, 2, 62, 1, 3, 72, 143 /* E */ 1, 5, 4, 0, 144 /* F */ 1, 6, 5, 1, 0, 1, 76, 145 /* A */ 1, 1, 6, 0, 146 /* B */ 1, 2, 7, 1, 0, 1, 80, 147 /* D */ 1, 4, 8, 2, 2, 12, 84, 2, 1, 88, 148 /* H */ 1, 8, 9, 0, 149 /* G */ 1, 7, 10, 0, 150 /* C */ 1, 3, 11, 0, 151 /* N */ 1, 10, 12, 0, 152 /* M */ 1, 9, 13, 0 125 /* (root) */ 0, 0, 1, 0, 126 /* Window */ 1, 11, 2, 12, 127 /* Window */ 1, 11, 3, 18, 128 /* E */ 1, 5, 4, 27, 129 /* F */ 1, 6, 5, 27, 130 /* A */ 1, 1, 6, 30, 131 /* B */ 1, 2, 7, 30, 132 /* D */ 1, 4, 8, 33, 133 /* H */ 1, 8, 9, 39, 134 /* G */ 1, 7, 10, 39, 135 /* C */ 1, 3, 11, 39, 136 /* N */ 1, 10, 12, 39, 137 /* M */ 1, 9, 13, 39 138 ], 139 edges: [ 140 /* from (root) */ 0, 1, 4, 0, 2, 8, 0, 3, 12, 0, 4, 16, 141 /* from Window */ 0, 1, 20, 0, 2, 24, 142 /* from Window */ 0, 1, 24, 0, 2, 28, 1, 3, 32, 143 /* from F */ 0, 1, 36, 144 /* from B */ 0, 1, 40, 145 /* from D */ 2, 12, 44, 2, 1, 48 153 146 ], 154 147 strings: ["", "A", "B", "C", "D", "E", "F", "G", "H", "M", "N", "Window", "native"] … … 386 379 // Instances of A have 12 bytes size, instances of B has 16 bytes size. 387 380 var sizeOfA = 12; 388 var sizeOfB = 16; 389 390 function generateNodes() 391 { 392 var nodes = [null]; 393 // Push the 'meta-root' node. 394 nodes.push(0, 0, 1, 0, (sizeOfA + sizeOfB) * instanceCount, 1, 1, 4, 1, null); 395 // Push instances of A and B. 396 var indexesOfB = []; 397 var nextId = firstId || 5; 398 for (var i = 0; i < instanceCount; ++i) { 399 var indexOfA = nodes.length; 400 nodes.push(3, 1, nextId++, sizeOfA, sizeOfA, null, 1, 2, 3, indexOfA); 401 var indexOfB = nodes.length; 402 // Set dominator of A. 403 nodes[indexOfA + 5] = indexOfB; 404 nodes.push(3, 2, nextId++, sizeOfB, sizeOfB + sizeOfA, null, 1, 2, 3, indexOfA); 405 indexesOfB.push(indexOfB); 406 } 407 var indexOfGCRoots = nodes.length; 408 nodes.push(3, 4, 3, 0, (sizeOfA + sizeOfB) * instanceCount, 1, instanceCount); 409 // Set dominator of B. 410 for (var i = 0; i < instanceCount; ++i) { 411 nodes[indexesOfB[i] + 5] = indexOfGCRoots; 412 } 413 // Set (GC roots) as child of meta-root. 414 nodes[10] = indexOfGCRoots; 415 // Push instances of B as children of GC roots. 416 for (var i = 0; i < instanceCount; ++i) { 417 nodes.push(1, i + 1, indexesOfB[i]); 418 } 419 return nodes; 381 var sizeOfB = 16; 382 var nodes = []; 383 var edges = []; 384 385 function addEdge(type, nameOrIndex, toNode) { 386 var edgeIndex = edges.length; 387 edges.push(type, nameOrIndex, toNode); 388 return edgeIndex; 389 } 390 391 nodes.push(0, 0, 1, 0, (sizeOfA + sizeOfB) * instanceCount, 0, addEdge(4, 1, null)); 392 // Push instances of A and B. 393 var indexesOfB = []; 394 var nextId = firstId || 5; 395 for (var i = 0; i < instanceCount; ++i) { 396 var indexOfA = nodes.length; 397 nodes.push(3, 1, nextId++, sizeOfA, sizeOfA, null, addEdge(2, 3, indexOfA)); 398 var indexOfB = nodes.length; 399 // Set dominator of A. 400 nodes[indexOfA + 5] = indexOfB; 401 nodes.push(3, 2, nextId++, sizeOfB, sizeOfB + sizeOfA, null, addEdge(2, 3, indexOfA)); 402 indexesOfB.push(indexOfB); 403 } 404 var indexOfGCRoots = nodes.length; 405 nodes.push(3, 4, 3, 0, (sizeOfA + sizeOfB) * instanceCount, 0, edges.length); 406 // Set dominator of B. 407 for (var i = 0; i < instanceCount; ++i) { 408 nodes[indexesOfB[i] + 5] = indexOfGCRoots; 409 } 410 // Set (GC roots) as child of meta-root. 411 edges[2] = indexOfGCRoots; 412 // Push instances of B as children of GC roots. 413 for (var i = 0; i < instanceCount; ++i) { 414 addEdge(1, i + 1, indexesOfB[i]); 420 415 } 421 416 422 417 var result = { 423 "snapshot": {}, 424 "nodes": generateNodes(), 418 "snapshot": { 419 "meta": { 420 "node_fields": ["type","name","id","self_size","retained_size","dominator","edges_index"], 421 "node_types": [["hidden","array","string","object","code","closure","regexp","number","native"],"string","number","number","number","number","number"], 422 "edge_fields": ["type","name_or_index","to_node"], 423 "edge_types": [["context","element","property","internal","hidden","shortcut"],"string_or_number","node"] 424 } 425 }, 426 "nodes": nodes, 427 "edges": edges, 425 428 "strings": ["", "A", "B", "a", "(GC roots)"] 426 429 }; 427 result.nodes[0] = { 428 "fields":["type","name","id","self_size","retained_size","dominator","children_count","children"], 429 "types":[["hidden","array","string","object","code","closure","regexp","number","native"],"string","number","number","number","number","number",{ 430 "fields":["type","name_or_index","to_node"], 431 "types":[["context","element","property","internal","hidden","shortcut"],"string_or_number","node"]}]}; 430 result.snapshot.node_count = result.nodes.length / result.snapshot.meta.node_fields.length; 431 result.snapshot.edge_count = result.edges.length / result.snapshot.meta.edge_fields.length; 432 432 return result; 433 433 }; -
trunk/LayoutTests/inspector/profiler/heap-snapshot.html
r112523 r116771 95 95 next(); 96 96 }, 97 98 function testNodesAndEdgesSeparationInHeapSnapshot(next)99 {100 var snapshot = new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock());101 function validateNewIndex()102 {103 var copiedNodeIndex = 0;104 for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), copiedNodeIndex += this._nodeFieldCount) {105 var originalNode = nodesIter.node;106 var copiedNode = this._onlyNodes[copiedNodeIndex];107 108 if (originalNode.id !== this._onlyNodes[copiedNodeIndex + this._nodeIdOffset])109 throw new Error("Id mismatch: " + originalNode.id);110 111 if (originalNode._type() !== this._onlyNodes[copiedNodeIndex + this._nodeTypeOffset])112 throw new Error("Node type mismatch: " + originalNode.id);113 114 // Validate containment edges.115 var firstEdgeIndex = this._onlyNodes[copiedNodeIndex + this._edgesCountOffset];116 var nextNodeIndex = copiedNodeIndex + this._nodeFieldCount;117 var lastEdgeIndex = (nextNodeIndex < this._onlyNodes.length)118 ? this._onlyNodes[nextNodeIndex + this._edgesCountOffset]119 : this._containmentEdges.length;120 121 if (originalNode.edgesCount !== (lastEdgeIndex - firstEdgeIndex) / this._edgeFieldsCount)122 throw new Error("Edges count mismatch: " + originalNode.id);123 124 for (var edgeIter = originalNode.edges, copiedEdgeIndex = firstEdgeIndex; edgeIter.hasNext(); edgeIter.next(), copiedEdgeIndex += this._edgeFieldsCount) {125 if (edgeIter.edge._type() !== this._containmentEdges[copiedEdgeIndex + this._edgeTypeOffset])126 throw new Error("Edge type mismatch: " + edgeIter.edge.type);127 128 var toNodeIndex = this._containmentEdges[copiedEdgeIndex + this._edgeToNodeOffset];129 if (edgeIter.edge.node.id !== this._onlyNodes[toNodeIndex + this._nodeIdOffset])130 throw new Error("Edge to node id mismatch: " + edgeIter.edge.node.id);131 }132 }133 }134 try {135 validateNewIndex.call(snapshot);136 } catch (e) {137 InspectorTest.addResult(e);138 throw e;139 }140 next();141 },142 143 97 144 98 function heapSnapshotRetainersTest(next) -
trunk/Source/WebCore/ChangeLog
r116768 r116771 1 2012-05-11 Alexei Filippov <alexeif@chromium.org> 2 3 Web Inspector: Remove support of combined nodes and edges serialization schema. 4 https://bugs.webkit.org/show_bug.cgi?id=86209 5 6 Reviewed by Yury Semikhatsky. 7 8 * inspector/front-end/HeapSnapshot.js: 9 (WebInspector.HeapSnapshotNode.prototype.get _nodes): 10 (WebInspector.HeapSnapshotNode.prototype._edgeIndexesStart): 11 (WebInspector.HeapSnapshotNode.prototype._edgeIndexesEnd): 12 (WebInspector.HeapSnapshot): 13 (WebInspector.HeapSnapshot.prototype._init): 14 (WebInspector.HeapSnapshot.prototype._buildRetainers): 15 (WebInspector.HeapSnapshot.prototype._bfs): 16 (WebInspector.HeapSnapshot.prototype._buildAggregates): 17 (WebInspector.HeapSnapshot.prototype._calculateClassesRetainedSize): 18 (WebInspector.HeapSnapshot.prototype._buildDominatedNodes): 19 * inspector/front-end/HeapSnapshotLoader.js: 20 (WebInspector.HeapSnapshotLoader.prototype.pushJSONChunk): 21 1 22 2012-05-11 Yury Semikhatsky <yurys@chromium.org> 2 23 -
trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js
r115205 r116771 556 556 get _nodes() 557 557 { 558 return this._snapshot._ onlyNodes;558 return this._snapshot._nodes; 559 559 }, 560 560 561 561 _edgeIndexesStart: function() 562 562 { 563 return this._snapshot._ onlyNodes[this.nodeIndex + this._snapshot._firstEdgeIndexOffset];563 return this._snapshot._nodes[this.nodeIndex + this._snapshot._firstEdgeIndexOffset]; 564 564 }, 565 565 … … 567 567 { 568 568 var nextNodeIndex = this._nextNodeIndex; 569 if (nextNodeIndex < this._snapshot._ onlyNodes.length)570 return this._snapshot._ onlyNodes[nextNodeIndex + this._snapshot._firstEdgeIndexOffset]569 if (nextNodeIndex < this._snapshot._nodes.length) 570 return this._snapshot._nodes[nextNodeIndex + this._snapshot._firstEdgeIndexOffset] 571 571 return this._snapshot._containmentEdges.length; 572 572 }, … … 630 630 this.uid = profile.snapshot.uid; 631 631 this._nodes = profile.nodes; 632 this._onlyNodes = profile.onlyNodes; 633 this._containmentEdges = profile.containmentEdges; 632 this._containmentEdges = profile.edges; 634 633 /** @type{HeapSnapshotMetainfo} */ 635 634 this._metaNode = profile.snapshot.meta; … … 675 674 { 676 675 var meta = this._metaNode; 677 if (meta.separate_edges) { 678 this._rootNodeIndex = 0; 679 680 this._nodeTypeOffset = meta.node_fields.indexOf("type"); 681 this._nodeNameOffset = meta.node_fields.indexOf("name"); 682 this._nodeIdOffset = meta.node_fields.indexOf("id"); 683 this._nodeSelfSizeOffset = meta.node_fields.indexOf("self_size"); 684 this._nodeRetainedSizeOffset = meta.node_fields.indexOf("retained_size"); 685 this._dominatorOffset = meta.node_fields.indexOf("dominator"); 686 this._firstEdgeIndexOffset = meta.node_fields.indexOf("edges_index"); 687 this._nodeFieldCount = meta.node_fields.length; 688 689 this._nodeTypes = meta.node_types[this._nodeTypeOffset]; 690 this._nodeHiddenType = this._nodeTypes.indexOf("hidden"); 691 this._nodeObjectType = this._nodeTypes.indexOf("object"); 692 this._nodeNativeType = this._nodeTypes.indexOf("native"); 693 this._nodeCodeType = this._nodeTypes.indexOf("code"); 694 this._nodeSyntheticType = this._nodeTypes.indexOf("synthetic"); 695 696 this._edgeFieldsCount = meta.edge_fields.length; 697 this._edgeTypeOffset = meta.edge_fields.indexOf("type"); 698 this._edgeNameOffset = meta.edge_fields.indexOf("name_or_index"); 699 this._edgeToNodeOffset = meta.edge_fields.indexOf("to_node"); 700 701 this._edgeTypes = meta.edge_types[this._edgeTypeOffset]; 702 this._edgeTypes.push("invisible"); 703 this._edgeElementType = this._edgeTypes.indexOf("element"); 704 this._edgeHiddenType = this._edgeTypes.indexOf("hidden"); 705 this._edgeInternalType = this._edgeTypes.indexOf("internal"); 706 this._edgeShortcutType = this._edgeTypes.indexOf("shortcut"); 707 this._edgeWeakType = this._edgeTypes.indexOf("weak"); 708 this._edgeInvisibleType = this._edgeTypes.indexOf("invisible"); 709 } else { 710 this._rootNodeIndex = 1; // First cell contained metadata, now we should skip it. 711 this._nodeTypeOffset = meta.fields.indexOf("type"); 712 this._nodeNameOffset = meta.fields.indexOf("name"); 713 this._nodeIdOffset = meta.fields.indexOf("id"); 714 this._nodeSelfSizeOffset = meta.fields.indexOf("self_size"); 715 this._nodeRetainedSizeOffset = meta.fields.indexOf("retained_size"); 716 this._dominatorOffset = meta.fields.indexOf("dominator"); 717 this._edgesCountOffset = meta.fields.indexOf("children_count"); 718 // After splitting nodes and edges we store first edge index in the field 719 // where edges count is stored in the raw snapshot. Here we create an alias 720 // for the field. 721 this._firstEdgeIndexOffset = this._edgesCountOffset; 722 this._firstEdgeOffset = meta.fields.indexOf("children"); 723 this._nodeFieldCount = this._firstEdgeOffset; 724 this._nodeTypes = meta.types[this._nodeTypeOffset]; 725 this._nodeHiddenType = this._nodeTypes.indexOf("hidden"); 726 this._nodeObjectType = this._nodeTypes.indexOf("object"); 727 this._nodeNativeType = this._nodeTypes.indexOf("native"); 728 this._nodeCodeType = this._nodeTypes.indexOf("code"); 729 this._nodeSyntheticType = this._nodeTypes.indexOf("synthetic"); 730 var edgesMeta = meta.types[this._firstEdgeOffset]; 731 this._edgeFieldsCount = edgesMeta.fields.length; 732 this._edgeTypeOffset = edgesMeta.fields.indexOf("type"); 733 this._edgeNameOffset = edgesMeta.fields.indexOf("name_or_index"); 734 this._edgeToNodeOffset = edgesMeta.fields.indexOf("to_node"); 735 this._edgeTypes = edgesMeta.types[this._edgeTypeOffset]; 736 this._edgeElementType = this._edgeTypes.indexOf("element"); 737 this._edgeHiddenType = this._edgeTypes.indexOf("hidden"); 738 this._edgeInternalType = this._edgeTypes.indexOf("internal"); 739 this._edgeShortcutType = this._edgeTypes.indexOf("shortcut"); 740 this._edgeWeakType = this._edgeTypes.indexOf("weak"); 741 this._edgeInvisibleType = this._edgeTypes.length; 742 this._edgeTypes.push("invisible"); 743 } 676 this._rootNodeIndex = 0; 677 678 this._nodeTypeOffset = meta.node_fields.indexOf("type"); 679 this._nodeNameOffset = meta.node_fields.indexOf("name"); 680 this._nodeIdOffset = meta.node_fields.indexOf("id"); 681 this._nodeSelfSizeOffset = meta.node_fields.indexOf("self_size"); 682 this._nodeRetainedSizeOffset = meta.node_fields.indexOf("retained_size"); 683 this._dominatorOffset = meta.node_fields.indexOf("dominator"); 684 this._firstEdgeIndexOffset = meta.node_fields.indexOf("edges_index"); 685 this._nodeFieldCount = meta.node_fields.length; 686 687 this._nodeTypes = meta.node_types[this._nodeTypeOffset]; 688 this._nodeHiddenType = this._nodeTypes.indexOf("hidden"); 689 this._nodeObjectType = this._nodeTypes.indexOf("object"); 690 this._nodeNativeType = this._nodeTypes.indexOf("native"); 691 this._nodeCodeType = this._nodeTypes.indexOf("code"); 692 this._nodeSyntheticType = this._nodeTypes.indexOf("synthetic"); 693 694 this._edgeFieldsCount = meta.edge_fields.length; 695 this._edgeTypeOffset = meta.edge_fields.indexOf("type"); 696 this._edgeNameOffset = meta.edge_fields.indexOf("name_or_index"); 697 this._edgeToNodeOffset = meta.edge_fields.indexOf("to_node"); 698 699 this._edgeTypes = meta.edge_types[this._edgeTypeOffset]; 700 this._edgeTypes.push("invisible"); 701 this._edgeElementType = this._edgeTypes.indexOf("element"); 702 this._edgeHiddenType = this._edgeTypes.indexOf("hidden"); 703 this._edgeInternalType = this._edgeTypes.indexOf("internal"); 704 this._edgeShortcutType = this._edgeTypes.indexOf("shortcut"); 705 this._edgeWeakType = this._edgeTypes.indexOf("weak"); 706 this._edgeInvisibleType = this._edgeTypes.indexOf("invisible"); 744 707 745 708 this._nodeFlags = { // bit flags … … 748 711 }; 749 712 750 if (meta.separate_edges) { 751 this.nodeCount = this._onlyNodes.length / this._nodeFieldCount; 752 this._edgeCount = this._containmentEdges.length / this._edgeFieldsCount; 753 } else { 754 this._splitNodesAndContainmentEdges(); 755 this._rootNodeIndex = 0; 756 } 713 this.nodeCount = this._nodes.length / this._nodeFieldCount; 714 this._edgeCount = this._containmentEdges.length / this._edgeFieldsCount; 757 715 758 716 this._markInvisibleEdges(); … … 764 722 }, 765 723 766 _splitNodesAndContainmentEdges: function()767 {768 // Estimate number of nodes.769 var totalEdgeCount = 0;770 var totalNodeCount = 0;771 for (var index = this._rootNodeIndex; index < this._nodes.length; ) {772 ++totalNodeCount;773 var edgesCount = this._nodes[index + this._edgesCountOffset];774 totalEdgeCount += edgesCount;775 index += this._firstEdgeOffset + edgesCount * this._edgeFieldsCount;776 }777 this.nodeCount = totalNodeCount;778 this._edgeCount = totalEdgeCount;779 this._createOnlyNodesArray();780 this._createContainmentEdgesArray();781 delete this._nodes;782 },783 784 _createOnlyNodesArray: function()785 {786 // Copy nodes to their own array.787 this._onlyNodes = new Uint32Array(this.nodeCount * this._nodeFieldCount);788 var dstIndex = 0;789 var srcIndex = this._rootNodeIndex;790 while (srcIndex < this._nodes.length) {791 var srcNodeTypeIndex = srcIndex + this._nodeTypeOffset;792 var currentDstIndex = dstIndex;793 var edgesCount = this._nodes[srcIndex + this._edgesCountOffset];794 for (var i = 0; i < this._nodeFieldCount; i++)795 this._onlyNodes[dstIndex++] = this._nodes[srcIndex++];796 // Write new node index into the type field.797 this._nodes[srcNodeTypeIndex] = currentDstIndex;798 srcIndex += edgesCount * this._edgeFieldsCount;799 }800 // Translate dominator indexes.801 for (var dominatorSlotIndex = this._dominatorOffset; dominatorSlotIndex < this._onlyNodes.length; dominatorSlotIndex += this._nodeFieldCount) {802 var dominatorIndex = this._onlyNodes[dominatorSlotIndex];803 this._onlyNodes[dominatorSlotIndex] = this._nodes[dominatorIndex + this._nodeTypeOffset];804 }805 },806 807 _createContainmentEdgesArray: function()808 {809 // Copy edges to their own array.810 var containmentEdges = this._containmentEdges = new Uint32Array(this._edgeCount * this._edgeFieldsCount);811 812 // Peload fields into local variables for better performance.813 var nodes = this._nodes;814 var onlyNodes = this._onlyNodes;815 var firstEdgeIndexOffset = this._firstEdgeIndexOffset;816 var edgeFieldsCount = this._edgeFieldsCount;817 var edgeToNodeOffset = this._edgeToNodeOffset;818 var edgesCountOffset = this._edgesCountOffset;819 var nodeTypeOffset = this._nodeTypeOffset;820 var firstEdgeOffset = this._firstEdgeOffset;821 822 var edgeArrayIndex = 0;823 var srcIndex = this._rootNodeIndex;824 while (srcIndex < nodes.length) {825 var srcNodeNewIndex = nodes[srcIndex + nodeTypeOffset];826 // Set index of first outgoing egde in the _containmentEdges array.827 onlyNodes[srcNodeNewIndex + firstEdgeIndexOffset] = edgeArrayIndex;828 829 // Now copy all edge information.830 var edgesCount = nodes[srcIndex + edgesCountOffset];831 srcIndex += firstEdgeOffset;832 var nextNodeIndex = srcIndex + edgesCount * edgeFieldsCount;833 while (srcIndex < nextNodeIndex) {834 containmentEdges[edgeArrayIndex] = nodes[srcIndex];835 // Translate destination node indexes for the copied edges.836 if (edgeArrayIndex % edgeFieldsCount === edgeToNodeOffset) {837 var toNodeIndex = containmentEdges[edgeArrayIndex];838 containmentEdges[edgeArrayIndex] = nodes[toNodeIndex + nodeTypeOffset];839 }840 ++edgeArrayIndex;841 ++srcIndex;842 }843 }844 },845 846 724 _buildRetainers: function() 847 725 { … … 856 734 var nodeFieldCount = this._nodeFieldCount; 857 735 var edgeToNodeOffset = this._edgeToNodeOffset; 858 var onlyNodes = this._onlyNodes;736 var nodes = this._nodes; 859 737 var firstEdgeIndexOffset = this._firstEdgeIndexOffset; 860 738 … … 874 752 875 753 var srcNodeIndex = 0; 876 var nextNodeFirstEdgeIndex = onlyNodes[firstEdgeIndexOffset];877 var onlyNodesLength = onlyNodes.length;878 while (srcNodeIndex < onlyNodesLength) {754 var nextNodeFirstEdgeIndex = nodes[firstEdgeIndexOffset]; 755 var nodesLength = nodes.length; 756 while (srcNodeIndex < nodesLength) { 879 757 var firstEdgeIndex = nextNodeFirstEdgeIndex; 880 758 var nextNodeIndex = srcNodeIndex + nodeFieldCount; 881 nextNodeFirstEdgeIndex = nextNodeIndex < onlyNodesLength882 ? onlyNodes[nextNodeIndex + firstEdgeIndexOffset]759 nextNodeFirstEdgeIndex = nextNodeIndex < nodesLength 760 ? nodes[nextNodeIndex + firstEdgeIndexOffset] 883 761 : containmentEdges.length; 884 762 for (var edgeIndex = firstEdgeIndex; edgeIndex < nextNodeFirstEdgeIndex; edgeIndex += edgeFieldsCount) { … … 1049 927 var edgeToNodeOffset = this._edgeToNodeOffset; 1050 928 var distancesToWindow = this._distancesToWindow; 1051 var onlyNodes = this._onlyNodes;929 var nodes = this._nodes; 1052 930 1053 931 var index = 0; … … 1060 938 var distance = distancesToWindow[nodeIndex] + 1; 1061 939 1062 var firstEdgeIndex = onlyNodes[nodeIndex + firstEdgeIndexOffset];1063 var edgesEnd = nodeIndex < onlyNodes.length1064 ? onlyNodes[nodeIndex + nodeFieldCount + firstEdgeIndexOffset]940 var firstEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset]; 941 var edgesEnd = nodeIndex < nodes.length 942 ? nodes[nodeIndex + nodeFieldCount + firstEdgeIndexOffset] 1065 943 : containmentEdges.length; 1066 944 for (var edgeToNodeIndex = firstEdgeIndex + edgeToNodeOffset; edgeToNodeIndex < edgesEnd; edgeToNodeIndex += edgeFieldsCount) { … … 1080 958 var aggregates = {}; 1081 959 var aggregatesByClassName = {}; 1082 var onlyNodes = this._onlyNodes;1083 var onlyNodesLength = onlyNodes.length;960 var nodes = this._nodes; 961 var nodesLength = nodes.length; 1084 962 var nodeNativeType = this._nodeNativeType; 1085 963 var nodeFieldsCount = this._nodeFieldCount; … … 1089 967 var distancesToWindow = this._distancesToWindow; 1090 968 1091 for (var nodeIndex = this._rootNodeIndex; nodeIndex < onlyNodesLength; nodeIndex += nodeFieldsCount) {969 for (var nodeIndex = this._rootNodeIndex; nodeIndex < nodesLength; nodeIndex += nodeFieldsCount) { 1092 970 node.nodeIndex = nodeIndex; 1093 var selfSize = onlyNodes[nodeIndex + selfSizeOffset];971 var selfSize = nodes[nodeIndex + selfSizeOffset]; 1094 972 if (filter && !filter(node)) 1095 973 continue; 1096 if (!selfSize && onlyNodes[nodeIndex + nodeTypeOffset] !== nodeNativeType)974 if (!selfSize && nodes[nodeIndex + nodeTypeOffset] !== nodeNativeType) 1097 975 continue; 1098 976 var classIndex = node.classIndex; … … 1138 1016 var nodeNativeType = this._nodeNativeType; 1139 1017 var dominatedNodes = this._dominatedNodes; 1140 var onlyNodes = this._onlyNodes;1018 var nodes = this._nodes; 1141 1019 var firstDominatedNodeIndex = this._firstDominatedNodeIndex; 1142 1020 … … 1152 1030 if (!seen && 1153 1031 (!filter || filter(node)) && 1154 (node.selfSize || onlyNodes[nodeIndex + nodeTypeOffset] === nodeNativeType)1032 (node.selfSize || nodes[nodeIndex + nodeTypeOffset] === nodeNativeType) 1155 1033 ) { 1156 1034 aggregates[classIndex].maxRet += node.retainedSize; … … 1199 1077 // Count the number of dominated nodes for each node. Skip the root (node at 1200 1078 // index 0) as it is the only node that dominates itself. 1201 for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._ onlyNodes.length; nodeIndex += this._nodeFieldCount) {1202 var dominatorIndex = this._ onlyNodes[nodeIndex + this._dominatorOffset];1079 for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._nodes.length; nodeIndex += this._nodeFieldCount) { 1080 var dominatorIndex = this._nodes[nodeIndex + this._dominatorOffset]; 1203 1081 if (dominatorIndex % this._nodeFieldCount) 1204 1082 throw new Error("Wrong dominatorIndex " + dominatorIndex + " nodeIndex = " + nodeIndex + " nodeCount = " + this.nodeCount); … … 1216 1094 // Fill up the dominatedNodes array with indexes of dominated nodes. Skip the root (node at 1217 1095 // index 0) as it is the only node that dominates itself. 1218 for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._ onlyNodes.length; nodeIndex += this._nodeFieldCount) {1219 var dominatorIndex = this._ onlyNodes[nodeIndex + this._dominatorOffset];1096 for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._nodes.length; nodeIndex += this._nodeFieldCount) { 1097 var dominatorIndex = this._nodes[nodeIndex + this._dominatorOffset]; 1220 1098 if (dominatorIndex % this._nodeFieldCount) 1221 1099 throw new Error("Wrong dominatorIndex " + dominatorIndex); -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotLoader.js
r115205 r116771 148 148 return; 149 149 this._json = this._json.slice(bracketIndex + 1); 150 if (this._snapshot.snapshot.meta) { 151 var node_fields_count = this._snapshot.snapshot.meta.node_fields.length; 152 var nodes_length = this._snapshot.snapshot.node_count * node_fields_count; 153 this._array = new WebInspector.Uint32Array(nodes_length); 154 this._snapshot.snapshot.meta.separate_edges = true; 155 this._state = "parse-nodes"; 156 } else { 157 this._state = "parse-nodes-meta-info"; 158 } 159 this.pushJSONChunk(""); 160 break; 161 } 162 case "parse-nodes-meta-info": { 163 var closingBracketIndex = this._findBalancedCurlyBrackets(); 164 if (closingBracketIndex === -1) 165 return; 166 this._snapshot.snapshot.meta = JSON.parse(this._json.slice(0, closingBracketIndex)); 167 this._json = this._json.slice(closingBracketIndex); 168 this._array = new WebInspector.Uint32Array(); 169 this._array.push(0); 150 var node_fields_count = this._snapshot.snapshot.meta.node_fields.length; 151 var nodes_length = this._snapshot.snapshot.node_count * node_fields_count; 152 this._array = new WebInspector.Uint32Array(nodes_length); 170 153 this._state = "parse-nodes"; 171 154 this.pushJSONChunk(""); … … 175 158 if (this._parseUintArray()) 176 159 return; 177 if (this._snapshot.snapshot.meta.separate_edges) { 178 this._snapshot.onlyNodes = this._array.array; 179 this._state = "find-edges"; 180 } else { 181 this._snapshot.nodes = this._array.array; 182 this._state = "find-strings"; 183 } 160 this._snapshot.nodes = this._array.array; 161 this._state = "find-edges"; 184 162 this._array = null; 185 163 this.pushJSONChunk(""); … … 205 183 if (this._parseUintArray()) 206 184 return; 207 this._snapshot. containmentEdges = this._array.array;185 this._snapshot.edges = this._array.array; 208 186 this._array = null; 209 187 this._state = "find-strings";
Note:
See TracChangeset
for help on using the changeset viewer.