HeapSnapshot.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  1. /*
  2. * Copyright (C) 2011 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /**
  31. * @constructor
  32. */
  33. WebInspector.HeapSnapshotArraySlice = function(array, start, end)
  34. {
  35. this._array = array;
  36. this._start = start;
  37. this.length = end - start;
  38. }
  39. WebInspector.HeapSnapshotArraySlice.prototype = {
  40. item: function(index)
  41. {
  42. return this._array[this._start + index];
  43. },
  44. slice: function(start, end)
  45. {
  46. if (typeof end === "undefined")
  47. end = this.length;
  48. return this._array.subarray(this._start + start, this._start + end);
  49. }
  50. }
  51. /**
  52. * @constructor
  53. * @param {number=} edgeIndex
  54. */
  55. WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex)
  56. {
  57. this._snapshot = snapshot;
  58. this._edges = edges;
  59. this.edgeIndex = edgeIndex || 0;
  60. }
  61. WebInspector.HeapSnapshotEdge.prototype = {
  62. clone: function()
  63. {
  64. return new WebInspector.HeapSnapshotEdge(this._snapshot, this._edges, this.edgeIndex);
  65. },
  66. hasStringName: function()
  67. {
  68. throw new Error("Not implemented");
  69. },
  70. name: function()
  71. {
  72. throw new Error("Not implemented");
  73. },
  74. node: function()
  75. {
  76. return this._snapshot.createNode(this.nodeIndex());
  77. },
  78. nodeIndex: function()
  79. {
  80. return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffset);
  81. },
  82. rawEdges: function()
  83. {
  84. return this._edges;
  85. },
  86. toString: function()
  87. {
  88. return "HeapSnapshotEdge: " + this.name();
  89. },
  90. type: function()
  91. {
  92. return this._snapshot._edgeTypes[this._type()];
  93. },
  94. serialize: function()
  95. {
  96. var node = this.node();
  97. return {
  98. name: this.name(),
  99. node: node.serialize(),
  100. nodeIndex: this.nodeIndex(),
  101. type: this.type(),
  102. distance: node.distance()
  103. };
  104. },
  105. _type: function()
  106. {
  107. return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset);
  108. }
  109. };
  110. /**
  111. * @constructor
  112. */
  113. WebInspector.HeapSnapshotEdgeIterator = function(edge)
  114. {
  115. this.edge = edge;
  116. }
  117. WebInspector.HeapSnapshotEdgeIterator.prototype = {
  118. rewind: function()
  119. {
  120. this.edge.edgeIndex = 0;
  121. },
  122. hasNext: function()
  123. {
  124. return this.edge.edgeIndex < this.edge._edges.length;
  125. },
  126. index: function()
  127. {
  128. return this.edge.edgeIndex;
  129. },
  130. setIndex: function(newIndex)
  131. {
  132. this.edge.edgeIndex = newIndex;
  133. },
  134. item: function()
  135. {
  136. return this.edge;
  137. },
  138. next: function()
  139. {
  140. this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount;
  141. }
  142. };
  143. /**
  144. * @constructor
  145. */
  146. WebInspector.HeapSnapshotRetainerEdge = function(snapshot, retainedNodeIndex, retainerIndex)
  147. {
  148. this._snapshot = snapshot;
  149. this._retainedNodeIndex = retainedNodeIndex;
  150. var retainedNodeOrdinal = retainedNodeIndex / snapshot._nodeFieldCount;
  151. this._firstRetainer = snapshot._firstRetainerIndex[retainedNodeOrdinal];
  152. this._retainersCount = snapshot._firstRetainerIndex[retainedNodeOrdinal + 1] - this._firstRetainer;
  153. this.setRetainerIndex(retainerIndex);
  154. }
  155. WebInspector.HeapSnapshotRetainerEdge.prototype = {
  156. clone: function()
  157. {
  158. return new WebInspector.HeapSnapshotRetainerEdge(this._snapshot, this._retainedNodeIndex, this.retainerIndex());
  159. },
  160. hasStringName: function()
  161. {
  162. return this._edge().hasStringName();
  163. },
  164. name: function()
  165. {
  166. return this._edge().name();
  167. },
  168. node: function()
  169. {
  170. return this._node();
  171. },
  172. nodeIndex: function()
  173. {
  174. return this._nodeIndex;
  175. },
  176. retainerIndex: function()
  177. {
  178. return this._retainerIndex;
  179. },
  180. setRetainerIndex: function(newIndex)
  181. {
  182. if (newIndex !== this._retainerIndex) {
  183. this._retainerIndex = newIndex;
  184. this.edgeIndex = newIndex;
  185. }
  186. },
  187. set edgeIndex(edgeIndex)
  188. {
  189. var retainerIndex = this._firstRetainer + edgeIndex;
  190. this._globalEdgeIndex = this._snapshot._retainingEdges[retainerIndex];
  191. this._nodeIndex = this._snapshot._retainingNodes[retainerIndex];
  192. delete this._edgeInstance;
  193. delete this._nodeInstance;
  194. },
  195. _node: function()
  196. {
  197. if (!this._nodeInstance)
  198. this._nodeInstance = this._snapshot.createNode(this._nodeIndex);
  199. return this._nodeInstance;
  200. },
  201. _edge: function()
  202. {
  203. if (!this._edgeInstance) {
  204. var edgeIndex = this._globalEdgeIndex - this._node()._edgeIndexesStart();
  205. this._edgeInstance = this._snapshot.createEdge(this._node().rawEdges(), edgeIndex);
  206. }
  207. return this._edgeInstance;
  208. },
  209. toString: function()
  210. {
  211. return this._edge().toString();
  212. },
  213. serialize: function()
  214. {
  215. var node = this.node();
  216. return {
  217. name: this.name(),
  218. node: node.serialize(),
  219. nodeIndex: this.nodeIndex(),
  220. type: this.type(),
  221. distance: node.distance()
  222. };
  223. },
  224. type: function()
  225. {
  226. return this._edge().type();
  227. }
  228. }
  229. /**
  230. * @constructor
  231. */
  232. WebInspector.HeapSnapshotRetainerEdgeIterator = function(retainer)
  233. {
  234. this.retainer = retainer;
  235. }
  236. WebInspector.HeapSnapshotRetainerEdgeIterator.prototype = {
  237. rewind: function()
  238. {
  239. this.retainer.setRetainerIndex(0);
  240. },
  241. hasNext: function()
  242. {
  243. return this.retainer.retainerIndex() < this.retainer._retainersCount;
  244. },
  245. index: function()
  246. {
  247. return this.retainer.retainerIndex();
  248. },
  249. setIndex: function(newIndex)
  250. {
  251. this.retainer.setRetainerIndex(newIndex);
  252. },
  253. item: function()
  254. {
  255. return this.retainer;
  256. },
  257. next: function()
  258. {
  259. this.retainer.setRetainerIndex(this.retainer.retainerIndex() + 1);
  260. }
  261. };
  262. /**
  263. * @constructor
  264. * @param {number=} nodeIndex
  265. */
  266. WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex)
  267. {
  268. this._snapshot = snapshot;
  269. this._firstNodeIndex = nodeIndex;
  270. this.nodeIndex = nodeIndex;
  271. }
  272. WebInspector.HeapSnapshotNode.prototype = {
  273. distance: function()
  274. {
  275. return this._snapshot._nodeDistances[this.nodeIndex / this._snapshot._nodeFieldCount];
  276. },
  277. className: function()
  278. {
  279. throw new Error("Not implemented");
  280. },
  281. classIndex: function()
  282. {
  283. throw new Error("Not implemented");
  284. },
  285. dominatorIndex: function()
  286. {
  287. var nodeFieldCount = this._snapshot._nodeFieldCount;
  288. return this._snapshot._dominatorsTree[this.nodeIndex / this._snapshot._nodeFieldCount] * nodeFieldCount;
  289. },
  290. edges: function()
  291. {
  292. return new WebInspector.HeapSnapshotEdgeIterator(this._snapshot.createEdge(this.rawEdges(), 0));
  293. },
  294. edgesCount: function()
  295. {
  296. return (this._edgeIndexesEnd() - this._edgeIndexesStart()) / this._snapshot._edgeFieldsCount;
  297. },
  298. id: function()
  299. {
  300. throw new Error("Not implemented");
  301. },
  302. isRoot: function()
  303. {
  304. return this.nodeIndex === this._snapshot._rootNodeIndex;
  305. },
  306. name: function()
  307. {
  308. return this._snapshot._strings[this._name()];
  309. },
  310. rawEdges: function()
  311. {
  312. return new WebInspector.HeapSnapshotArraySlice(this._snapshot._containmentEdges, this._edgeIndexesStart(), this._edgeIndexesEnd());
  313. },
  314. retainedSize: function()
  315. {
  316. var snapshot = this._snapshot;
  317. return snapshot._nodes[this.nodeIndex + snapshot._nodeRetainedSizeOffset];
  318. },
  319. retainers: function()
  320. {
  321. return new WebInspector.HeapSnapshotRetainerEdgeIterator(this._snapshot.createRetainingEdge(this.nodeIndex, 0));
  322. },
  323. selfSize: function()
  324. {
  325. var snapshot = this._snapshot;
  326. return snapshot._nodes[this.nodeIndex + snapshot._nodeSelfSizeOffset];
  327. },
  328. type: function()
  329. {
  330. return this._snapshot._nodeTypes[this._type()];
  331. },
  332. serialize: function()
  333. {
  334. return {
  335. id: this.id(),
  336. name: this.name(),
  337. distance: this.distance(),
  338. nodeIndex: this.nodeIndex,
  339. retainedSize: this.retainedSize(),
  340. selfSize: this.selfSize(),
  341. type: this.type(),
  342. };
  343. },
  344. _name: function()
  345. {
  346. var snapshot = this._snapshot;
  347. return snapshot._nodes[this.nodeIndex + snapshot._nodeNameOffset];
  348. },
  349. _edgeIndexesStart: function()
  350. {
  351. return this._snapshot._firstEdgeIndexes[this._ordinal()];
  352. },
  353. _edgeIndexesEnd: function()
  354. {
  355. return this._snapshot._firstEdgeIndexes[this._ordinal() + 1];
  356. },
  357. _ordinal: function()
  358. {
  359. return this.nodeIndex / this._snapshot._nodeFieldCount;
  360. },
  361. _nextNodeIndex: function()
  362. {
  363. return this.nodeIndex + this._snapshot._nodeFieldCount;
  364. },
  365. _type: function()
  366. {
  367. var snapshot = this._snapshot;
  368. return snapshot._nodes[this.nodeIndex + snapshot._nodeTypeOffset];
  369. }
  370. };
  371. /**
  372. * @constructor
  373. */
  374. WebInspector.HeapSnapshotNodeIterator = function(node)
  375. {
  376. this.node = node;
  377. this._nodesLength = node._snapshot._nodes.length;
  378. }
  379. WebInspector.HeapSnapshotNodeIterator.prototype = {
  380. rewind: function()
  381. {
  382. this.node.nodeIndex = this.node._firstNodeIndex;
  383. },
  384. hasNext: function()
  385. {
  386. return this.node.nodeIndex < this._nodesLength;
  387. },
  388. index: function()
  389. {
  390. return this.node.nodeIndex;
  391. },
  392. setIndex: function(newIndex)
  393. {
  394. this.node.nodeIndex = newIndex;
  395. },
  396. item: function()
  397. {
  398. return this.node;
  399. },
  400. next: function()
  401. {
  402. this.node.nodeIndex = this.node._nextNodeIndex();
  403. }
  404. }
  405. /**
  406. * @constructor
  407. */
  408. WebInspector.HeapSnapshot = function(profile)
  409. {
  410. this.uid = profile.snapshot.uid;
  411. this._nodes = profile.nodes;
  412. this._containmentEdges = profile.edges;
  413. /** @type{HeapSnapshotMetainfo} */
  414. this._metaNode = profile.snapshot.meta;
  415. this._strings = profile.strings;
  416. this._rootNodeIndex = 0;
  417. if (profile.snapshot.root_index)
  418. this._rootNodeIndex = profile.snapshot.root_index;
  419. this._snapshotDiffs = {};
  420. this._aggregatesForDiff = null;
  421. this._init();
  422. }
  423. /**
  424. * @constructor
  425. */
  426. function HeapSnapshotMetainfo()
  427. {
  428. // New format.
  429. this.node_fields = [];
  430. this.node_types = [];
  431. this.edge_fields = [];
  432. this.edge_types = [];
  433. this.type_strings = {};
  434. // Old format.
  435. this.fields = [];
  436. this.types = [];
  437. }
  438. /**
  439. * @constructor
  440. */
  441. function HeapSnapshotHeader()
  442. {
  443. // New format.
  444. this.title = "";
  445. this.uid = 0;
  446. this.meta = new HeapSnapshotMetainfo();
  447. this.node_count = 0;
  448. this.edge_count = 0;
  449. }
  450. WebInspector.HeapSnapshot.prototype = {
  451. _init: function()
  452. {
  453. var meta = this._metaNode;
  454. this._nodeTypeOffset = meta.node_fields.indexOf("type");
  455. this._nodeNameOffset = meta.node_fields.indexOf("name");
  456. this._nodeIdOffset = meta.node_fields.indexOf("id");
  457. this._nodeSelfSizeOffset = meta.node_fields.indexOf("self_size");
  458. this._nodeEdgeCountOffset = meta.node_fields.indexOf("edge_count");
  459. this._nodeFieldCount = meta.node_fields.length;
  460. this._nodeTypes = meta.node_types[this._nodeTypeOffset];
  461. this._nodeHiddenType = this._nodeTypes.indexOf("hidden");
  462. this._nodeObjectType = this._nodeTypes.indexOf("object");
  463. this._nodeNativeType = this._nodeTypes.indexOf("native");
  464. this._nodeCodeType = this._nodeTypes.indexOf("code");
  465. this._nodeSyntheticType = this._nodeTypes.indexOf("synthetic");
  466. this._edgeFieldsCount = meta.edge_fields.length;
  467. this._edgeTypeOffset = meta.edge_fields.indexOf("type");
  468. this._edgeNameOffset = meta.edge_fields.indexOf("name_or_index");
  469. this._edgeToNodeOffset = meta.edge_fields.indexOf("to_node");
  470. this._edgeTypes = meta.edge_types[this._edgeTypeOffset];
  471. this._edgeTypes.push("invisible");
  472. this._edgeElementType = this._edgeTypes.indexOf("element");
  473. this._edgeHiddenType = this._edgeTypes.indexOf("hidden");
  474. this._edgeInternalType = this._edgeTypes.indexOf("internal");
  475. this._edgeShortcutType = this._edgeTypes.indexOf("shortcut");
  476. this._edgeWeakType = this._edgeTypes.indexOf("weak");
  477. this._edgeInvisibleType = this._edgeTypes.indexOf("invisible");
  478. this.nodeCount = this._nodes.length / this._nodeFieldCount;
  479. this._edgeCount = this._containmentEdges.length / this._edgeFieldsCount;
  480. this._buildEdgeIndexes();
  481. this._markInvisibleEdges();
  482. this._buildRetainers();
  483. this._calculateFlags();
  484. this._calculateDistances();
  485. var result = this._buildPostOrderIndex();
  486. // Actually it is array that maps node ordinal number to dominator node ordinal number.
  487. this._dominatorsTree = this._buildDominatorTree(result.postOrderIndex2NodeOrdinal, result.nodeOrdinal2PostOrderIndex);
  488. this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);
  489. this._buildDominatedNodes();
  490. },
  491. _buildEdgeIndexes: function()
  492. {
  493. var nodes = this._nodes;
  494. var nodeCount = this.nodeCount;
  495. var firstEdgeIndexes = this._firstEdgeIndexes = new Uint32Array(nodeCount + 1);
  496. var nodeFieldCount = this._nodeFieldCount;
  497. var edgeFieldsCount = this._edgeFieldsCount;
  498. var nodeEdgeCountOffset = this._nodeEdgeCountOffset;
  499. firstEdgeIndexes[nodeCount] = this._containmentEdges.length;
  500. for (var nodeOrdinal = 0, edgeIndex = 0; nodeOrdinal < nodeCount; ++nodeOrdinal) {
  501. firstEdgeIndexes[nodeOrdinal] = edgeIndex;
  502. edgeIndex += nodes[nodeOrdinal * nodeFieldCount + nodeEdgeCountOffset] * edgeFieldsCount;
  503. }
  504. },
  505. _buildRetainers: function()
  506. {
  507. var retainingNodes = this._retainingNodes = new Uint32Array(this._edgeCount);
  508. var retainingEdges = this._retainingEdges = new Uint32Array(this._edgeCount);
  509. // Index of the first retainer in the _retainingNodes and _retainingEdges
  510. // arrays. Addressed by retained node index.
  511. var firstRetainerIndex = this._firstRetainerIndex = new Uint32Array(this.nodeCount + 1);
  512. var containmentEdges = this._containmentEdges;
  513. var edgeFieldsCount = this._edgeFieldsCount;
  514. var nodeFieldCount = this._nodeFieldCount;
  515. var edgeToNodeOffset = this._edgeToNodeOffset;
  516. var nodes = this._nodes;
  517. var firstEdgeIndexes = this._firstEdgeIndexes;
  518. var nodeCount = this.nodeCount;
  519. for (var toNodeFieldIndex = edgeToNodeOffset, l = containmentEdges.length; toNodeFieldIndex < l; toNodeFieldIndex += edgeFieldsCount) {
  520. var toNodeIndex = containmentEdges[toNodeFieldIndex];
  521. if (toNodeIndex % nodeFieldCount)
  522. throw new Error("Invalid toNodeIndex " + toNodeIndex);
  523. ++firstRetainerIndex[toNodeIndex / nodeFieldCount];
  524. }
  525. for (var i = 0, firstUnusedRetainerSlot = 0; i < nodeCount; i++) {
  526. var retainersCount = firstRetainerIndex[i];
  527. firstRetainerIndex[i] = firstUnusedRetainerSlot;
  528. retainingNodes[firstUnusedRetainerSlot] = retainersCount;
  529. firstUnusedRetainerSlot += retainersCount;
  530. }
  531. firstRetainerIndex[nodeCount] = retainingNodes.length;
  532. var nextNodeFirstEdgeIndex = firstEdgeIndexes[0];
  533. for (var srcNodeOrdinal = 0; srcNodeOrdinal < nodeCount; ++srcNodeOrdinal) {
  534. var firstEdgeIndex = nextNodeFirstEdgeIndex;
  535. nextNodeFirstEdgeIndex = firstEdgeIndexes[srcNodeOrdinal + 1];
  536. var srcNodeIndex = srcNodeOrdinal * nodeFieldCount;
  537. for (var edgeIndex = firstEdgeIndex; edgeIndex < nextNodeFirstEdgeIndex; edgeIndex += edgeFieldsCount) {
  538. var toNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
  539. if (toNodeIndex % nodeFieldCount)
  540. throw new Error("Invalid toNodeIndex " + toNodeIndex);
  541. var firstRetainerSlotIndex = firstRetainerIndex[toNodeIndex / nodeFieldCount];
  542. var nextUnusedRetainerSlotIndex = firstRetainerSlotIndex + (--retainingNodes[firstRetainerSlotIndex]);
  543. retainingNodes[nextUnusedRetainerSlotIndex] = srcNodeIndex;
  544. retainingEdges[nextUnusedRetainerSlotIndex] = edgeIndex;
  545. }
  546. }
  547. },
  548. /**
  549. * @param {number=} nodeIndex
  550. */
  551. createNode: function(nodeIndex)
  552. {
  553. throw new Error("Not implemented");
  554. },
  555. createEdge: function(edges, edgeIndex)
  556. {
  557. throw new Error("Not implemented");
  558. },
  559. createRetainingEdge: function(retainedNodeIndex, retainerIndex)
  560. {
  561. throw new Error("Not implemented");
  562. },
  563. dispose: function()
  564. {
  565. delete this._nodes;
  566. delete this._strings;
  567. delete this._retainingEdges;
  568. delete this._retainingNodes;
  569. delete this._firstRetainerIndex;
  570. if (this._aggregates) {
  571. delete this._aggregates;
  572. delete this._aggregatesSortedFlags;
  573. }
  574. delete this._dominatedNodes;
  575. delete this._firstDominatedNodeIndex;
  576. delete this._nodeDistances;
  577. delete this._dominatorsTree;
  578. },
  579. _allNodes: function()
  580. {
  581. return new WebInspector.HeapSnapshotNodeIterator(this.rootNode());
  582. },
  583. rootNode: function()
  584. {
  585. return this.createNode(this._rootNodeIndex);
  586. },
  587. get rootNodeIndex()
  588. {
  589. return this._rootNodeIndex;
  590. },
  591. get totalSize()
  592. {
  593. return this.rootNode().retainedSize();
  594. },
  595. _getDominatedIndex: function(nodeIndex)
  596. {
  597. if (nodeIndex % this._nodeFieldCount)
  598. throw new Error("Invalid nodeIndex: " + nodeIndex);
  599. return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount];
  600. },
  601. _dominatedNodesOfNode: function(node)
  602. {
  603. var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex);
  604. var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex());
  605. return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes, dominatedIndexFrom, dominatedIndexTo);
  606. },
  607. /**
  608. * @param {boolean} sortedIndexes
  609. * @param {string} key
  610. * @param {string=} filterString
  611. */
  612. aggregates: function(sortedIndexes, key, filterString)
  613. {
  614. if (!this._aggregates) {
  615. this._aggregates = {};
  616. this._aggregatesSortedFlags = {};
  617. }
  618. var aggregatesByClassName = this._aggregates[key];
  619. if (aggregatesByClassName) {
  620. if (sortedIndexes && !this._aggregatesSortedFlags[key]) {
  621. this._sortAggregateIndexes(aggregatesByClassName);
  622. this._aggregatesSortedFlags[key] = sortedIndexes;
  623. }
  624. return aggregatesByClassName;
  625. }
  626. var filter;
  627. if (filterString)
  628. filter = this._parseFilter(filterString);
  629. var aggregates = this._buildAggregates(filter);
  630. this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex, filter);
  631. aggregatesByClassName = aggregates.aggregatesByClassName;
  632. if (sortedIndexes)
  633. this._sortAggregateIndexes(aggregatesByClassName);
  634. this._aggregatesSortedFlags[key] = sortedIndexes;
  635. this._aggregates[key] = aggregatesByClassName;
  636. return aggregatesByClassName;
  637. },
  638. aggregatesForDiff: function()
  639. {
  640. if (this._aggregatesForDiff)
  641. return this._aggregatesForDiff;
  642. var aggregatesByClassName = this.aggregates(true, "allObjects");
  643. this._aggregatesForDiff = {};
  644. var node = this.createNode();
  645. for (var className in aggregatesByClassName) {
  646. var aggregate = aggregatesByClassName[className];
  647. var indexes = aggregate.idxs;
  648. var ids = new Array(indexes.length);
  649. var selfSizes = new Array(indexes.length);
  650. for (var i = 0; i < indexes.length; i++) {
  651. node.nodeIndex = indexes[i];
  652. ids[i] = node.id();
  653. selfSizes[i] = node.selfSize();
  654. }
  655. this._aggregatesForDiff[className] = {
  656. indexes: indexes,
  657. ids: ids,
  658. selfSizes: selfSizes
  659. };
  660. }
  661. return this._aggregatesForDiff;
  662. },
  663. distanceForUserRoot: function(node)
  664. {
  665. return 1;
  666. },
  667. _calculateDistances: function()
  668. {
  669. var nodeFieldCount = this._nodeFieldCount;
  670. var distances = new Uint32Array(this.nodeCount);
  671. // bfs for Window roots
  672. var nodesToVisit = new Uint32Array(this.nodeCount);
  673. var nodesToVisitLength = 0;
  674. for (var iter = this.rootNode().edges(); iter.hasNext(); iter.next()) {
  675. var node = iter.edge.node();
  676. var distance = this.distanceForUserRoot(node);
  677. if (distance !== -1) {
  678. nodesToVisit[nodesToVisitLength++] = node.nodeIndex;
  679. distances[node.nodeIndex / nodeFieldCount] = distance;
  680. }
  681. }
  682. this._bfs(nodesToVisit, nodesToVisitLength, distances);
  683. // bfs for root
  684. nodesToVisitLength = 0;
  685. nodesToVisit[nodesToVisitLength++] = this._rootNodeIndex;
  686. distances[this._rootNodeIndex / nodeFieldCount] = 1;
  687. this._bfs(nodesToVisit, nodesToVisitLength, distances);
  688. this._nodeDistances = distances;
  689. },
  690. _bfs: function(nodesToVisit, nodesToVisitLength, distances)
  691. {
  692. // Peload fields into local variables for better performance.
  693. var edgeFieldsCount = this._edgeFieldsCount;
  694. var nodeFieldCount = this._nodeFieldCount;
  695. var containmentEdges = this._containmentEdges;
  696. var firstEdgeIndexes = this._firstEdgeIndexes;
  697. var edgeToNodeOffset = this._edgeToNodeOffset;
  698. var edgeTypeOffset = this._edgeTypeOffset;
  699. var nodes = this._nodes;
  700. var nodeCount = this.nodeCount;
  701. var containmentEdgesLength = containmentEdges.length;
  702. var edgeWeakType = this._edgeWeakType;
  703. var index = 0;
  704. while (index < nodesToVisitLength) {
  705. var nodeIndex = nodesToVisit[index++]; // shift generates too much garbage.
  706. var nodeOrdinal = nodeIndex / nodeFieldCount;
  707. var distance = distances[nodeOrdinal] + 1;
  708. var firstEdgeIndex = firstEdgeIndexes[nodeOrdinal];
  709. var edgesEnd = firstEdgeIndexes[nodeOrdinal + 1];
  710. for (var edgeIndex = firstEdgeIndex; edgeIndex < edgesEnd; edgeIndex += edgeFieldsCount) {
  711. var edgeType = containmentEdges[edgeIndex + edgeTypeOffset];
  712. if (edgeType == edgeWeakType)
  713. continue;
  714. var childNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
  715. var childNodeOrdinal = childNodeIndex / nodeFieldCount;
  716. if (distances[childNodeOrdinal])
  717. continue;
  718. distances[childNodeOrdinal] = distance;
  719. nodesToVisit[nodesToVisitLength++] = childNodeIndex;
  720. }
  721. }
  722. if (nodesToVisitLength > nodeCount)
  723. throw new Error("BFS failed. Nodes to visit (" + nodesToVisitLength + ") is more than nodes count (" + nodeCount + ")");
  724. },
  725. _buildAggregates: function(filter)
  726. {
  727. var aggregates = {};
  728. var aggregatesByClassName = {};
  729. var classIndexes = [];
  730. var nodes = this._nodes;
  731. var mapAndFlag = this.userObjectsMapAndFlag();
  732. var flags = mapAndFlag ? mapAndFlag.map : null;
  733. var flag = mapAndFlag ? mapAndFlag.flag : 0;
  734. var nodesLength = nodes.length;
  735. var nodeNativeType = this._nodeNativeType;
  736. var nodeFieldCount = this._nodeFieldCount;
  737. var selfSizeOffset = this._nodeSelfSizeOffset;
  738. var nodeTypeOffset = this._nodeTypeOffset;
  739. var node = this.rootNode();
  740. var nodeDistances = this._nodeDistances;
  741. for (var nodeIndex = 0; nodeIndex < nodesLength; nodeIndex += nodeFieldCount) {
  742. var nodeOrdinal = nodeIndex / nodeFieldCount;
  743. if (flags && !(flags[nodeOrdinal] & flag))
  744. continue;
  745. node.nodeIndex = nodeIndex;
  746. if (filter && !filter(node))
  747. continue;
  748. var selfSize = nodes[nodeIndex + selfSizeOffset];
  749. if (!selfSize && nodes[nodeIndex + nodeTypeOffset] !== nodeNativeType)
  750. continue;
  751. var classIndex = node.classIndex();
  752. if (!(classIndex in aggregates)) {
  753. var nodeType = node.type();
  754. var nameMatters = nodeType === "object" || nodeType === "native";
  755. var value = {
  756. count: 1,
  757. distance: nodeDistances[nodeOrdinal],
  758. self: selfSize,
  759. maxRet: 0,
  760. type: nodeType,
  761. name: nameMatters ? node.name() : null,
  762. idxs: [nodeIndex]
  763. };
  764. aggregates[classIndex] = value;
  765. classIndexes.push(classIndex);
  766. aggregatesByClassName[node.className()] = value;
  767. } else {
  768. var clss = aggregates[classIndex];
  769. clss.distance = Math.min(clss.distance, nodeDistances[nodeOrdinal]);
  770. ++clss.count;
  771. clss.self += selfSize;
  772. clss.idxs.push(nodeIndex);
  773. }
  774. }
  775. // Shave off provisionally allocated space.
  776. for (var i = 0, l = classIndexes.length; i < l; ++i) {
  777. var classIndex = classIndexes[i];
  778. aggregates[classIndex].idxs = aggregates[classIndex].idxs.slice();
  779. }
  780. return {aggregatesByClassName: aggregatesByClassName, aggregatesByClassIndex: aggregates};
  781. },
  782. _calculateClassesRetainedSize: function(aggregates, filter)
  783. {
  784. var rootNodeIndex = this._rootNodeIndex;
  785. var node = this.createNode(rootNodeIndex);
  786. var list = [rootNodeIndex];
  787. var sizes = [-1];
  788. var classes = [];
  789. var seenClassNameIndexes = {};
  790. var nodeFieldCount = this._nodeFieldCount;
  791. var nodeTypeOffset = this._nodeTypeOffset;
  792. var nodeNativeType = this._nodeNativeType;
  793. var dominatedNodes = this._dominatedNodes;
  794. var nodes = this._nodes;
  795. var mapAndFlag = this.userObjectsMapAndFlag();
  796. var flags = mapAndFlag ? mapAndFlag.map : null;
  797. var flag = mapAndFlag ? mapAndFlag.flag : 0;
  798. var firstDominatedNodeIndex = this._firstDominatedNodeIndex;
  799. while (list.length) {
  800. var nodeIndex = list.pop();
  801. node.nodeIndex = nodeIndex;
  802. var classIndex = node.classIndex();
  803. var seen = !!seenClassNameIndexes[classIndex];
  804. var nodeOrdinal = nodeIndex / nodeFieldCount;
  805. var dominatedIndexFrom = firstDominatedNodeIndex[nodeOrdinal];
  806. var dominatedIndexTo = firstDominatedNodeIndex[nodeOrdinal + 1];
  807. if (!seen &&
  808. (!flags || (flags[nodeOrdinal] & flag)) &&
  809. (!filter || filter(node)) &&
  810. (node.selfSize() || nodes[nodeIndex + nodeTypeOffset] === nodeNativeType)
  811. ) {
  812. aggregates[classIndex].maxRet += node.retainedSize();
  813. if (dominatedIndexFrom !== dominatedIndexTo) {
  814. seenClassNameIndexes[classIndex] = true;
  815. sizes.push(list.length);
  816. classes.push(classIndex);
  817. }
  818. }
  819. for (var i = dominatedIndexFrom; i < dominatedIndexTo; i++)
  820. list.push(dominatedNodes[i]);
  821. var l = list.length;
  822. while (sizes[sizes.length - 1] === l) {
  823. sizes.pop();
  824. classIndex = classes.pop();
  825. seenClassNameIndexes[classIndex] = false;
  826. }
  827. }
  828. },
  829. _sortAggregateIndexes: function(aggregates)
  830. {
  831. var nodeA = this.createNode();
  832. var nodeB = this.createNode();
  833. for (var clss in aggregates)
  834. aggregates[clss].idxs.sort(
  835. function(idxA, idxB) {
  836. nodeA.nodeIndex = idxA;
  837. nodeB.nodeIndex = idxB;
  838. return nodeA.id() < nodeB.id() ? -1 : 1;
  839. });
  840. },
  841. _buildPostOrderIndex: function()
  842. {
  843. var nodeFieldCount = this._nodeFieldCount;
  844. var nodes = this._nodes;
  845. var nodeCount = this.nodeCount;
  846. var rootNodeOrdinal = this._rootNodeIndex / nodeFieldCount;
  847. var edgeFieldsCount = this._edgeFieldsCount;
  848. var edgeTypeOffset = this._edgeTypeOffset;
  849. var edgeToNodeOffset = this._edgeToNodeOffset;
  850. var edgeShortcutType = this._edgeShortcutType;
  851. var firstEdgeIndexes = this._firstEdgeIndexes;
  852. var containmentEdges = this._containmentEdges;
  853. var containmentEdgesLength = this._containmentEdges.length;
  854. var mapAndFlag = this.userObjectsMapAndFlag();
  855. var flags = mapAndFlag ? mapAndFlag.map : null;
  856. var flag = mapAndFlag ? mapAndFlag.flag : 0;
  857. var nodesToVisit = new Uint32Array(nodeCount);
  858. var postOrderIndex2NodeOrdinal = new Uint32Array(nodeCount);
  859. var nodeOrdinal2PostOrderIndex = new Uint32Array(nodeCount);
  860. var painted = new Uint8Array(nodeCount);
  861. var nodesToVisitLength = 0;
  862. var postOrderIndex = 0;
  863. var grey = 1;
  864. var black = 2;
  865. nodesToVisit[nodesToVisitLength++] = rootNodeOrdinal;
  866. painted[rootNodeOrdinal] = grey;
  867. while (nodesToVisitLength) {
  868. var nodeOrdinal = nodesToVisit[nodesToVisitLength - 1];
  869. if (painted[nodeOrdinal] === grey) {
  870. painted[nodeOrdinal] = black;
  871. var nodeFlag = !flags || (flags[nodeOrdinal] & flag);
  872. var beginEdgeIndex = firstEdgeIndexes[nodeOrdinal];
  873. var endEdgeIndex = firstEdgeIndexes[nodeOrdinal + 1];
  874. for (var edgeIndex = beginEdgeIndex; edgeIndex < endEdgeIndex; edgeIndex += edgeFieldsCount) {
  875. if (nodeOrdinal !== rootNodeOrdinal && containmentEdges[edgeIndex + edgeTypeOffset] === edgeShortcutType)
  876. continue;
  877. var childNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
  878. var childNodeOrdinal = childNodeIndex / nodeFieldCount;
  879. var childNodeFlag = !flags || (flags[childNodeOrdinal] & flag);
  880. // We are skipping the edges from non-page-owned nodes to page-owned nodes.
  881. // Otherwise the dominators for the objects that also were retained by debugger would be affected.
  882. if (nodeOrdinal !== rootNodeOrdinal && childNodeFlag && !nodeFlag)
  883. continue;
  884. if (!painted[childNodeOrdinal]) {
  885. painted[childNodeOrdinal] = grey;
  886. nodesToVisit[nodesToVisitLength++] = childNodeOrdinal;
  887. }
  888. }
  889. } else {
  890. nodeOrdinal2PostOrderIndex[nodeOrdinal] = postOrderIndex;
  891. postOrderIndex2NodeOrdinal[postOrderIndex++] = nodeOrdinal;
  892. --nodesToVisitLength;
  893. }
  894. }
  895. if (postOrderIndex !== nodeCount) {
  896. var dumpNode = this.rootNode();
  897. for (var i = 0; i < nodeCount; ++i) {
  898. if (painted[i] !== black) {
  899. dumpNode.nodeIndex = i * nodeFieldCount;
  900. console.log(JSON.stringify(dumpNode.serialize()));
  901. var retainers = dumpNode.retainers();
  902. while (retainers) {
  903. console.log("edgeName: " + retainers.item().name() + " nodeClassName: " + retainers.item().node().className());
  904. retainers = retainers.item().node().retainers();
  905. }
  906. }
  907. }
  908. throw new Error("Postordering failed. " + (nodeCount - postOrderIndex) + " hanging nodes");
  909. }
  910. return {postOrderIndex2NodeOrdinal: postOrderIndex2NodeOrdinal, nodeOrdinal2PostOrderIndex: nodeOrdinal2PostOrderIndex};
  911. },
  912. // The algorithm is based on the article:
  913. // K. Cooper, T. Harvey and K. Kennedy "A Simple, Fast Dominance Algorithm"
  914. // Softw. Pract. Exper. 4 (2001), pp. 1-10.
  915. /**
  916. * @param {Array.<number>} postOrderIndex2NodeOrdinal
  917. * @param {Array.<number>} nodeOrdinal2PostOrderIndex
  918. */
  919. _buildDominatorTree: function(postOrderIndex2NodeOrdinal, nodeOrdinal2PostOrderIndex)
  920. {
  921. var nodeFieldCount = this._nodeFieldCount;
  922. var nodes = this._nodes;
  923. var firstRetainerIndex = this._firstRetainerIndex;
  924. var retainingNodes = this._retainingNodes;
  925. var retainingEdges = this._retainingEdges;
  926. var edgeFieldsCount = this._edgeFieldsCount;
  927. var edgeTypeOffset = this._edgeTypeOffset;
  928. var edgeToNodeOffset = this._edgeToNodeOffset;
  929. var edgeShortcutType = this._edgeShortcutType;
  930. var firstEdgeIndexes = this._firstEdgeIndexes;
  931. var containmentEdges = this._containmentEdges;
  932. var containmentEdgesLength = this._containmentEdges.length;
  933. var rootNodeIndex = this._rootNodeIndex;
  934. var mapAndFlag = this.userObjectsMapAndFlag();
  935. var flags = mapAndFlag ? mapAndFlag.map : null;
  936. var flag = mapAndFlag ? mapAndFlag.flag : 0;
  937. var nodesCount = postOrderIndex2NodeOrdinal.length;
  938. var rootPostOrderedIndex = nodesCount - 1;
  939. var noEntry = nodesCount;
  940. var dominators = new Uint32Array(nodesCount);
  941. for (var i = 0; i < rootPostOrderedIndex; ++i)
  942. dominators[i] = noEntry;
  943. dominators[rootPostOrderedIndex] = rootPostOrderedIndex;
  944. // The affected array is used to mark entries which dominators
  945. // have to be racalculated because of changes in their retainers.
  946. var affected = new Uint8Array(nodesCount);
  947. var nodeOrdinal;
  948. { // Mark the root direct children as affected.
  949. nodeOrdinal = this._rootNodeIndex / nodeFieldCount;
  950. var beginEdgeToNodeFieldIndex = firstEdgeIndexes[nodeOrdinal] + edgeToNodeOffset;
  951. var endEdgeToNodeFieldIndex = firstEdgeIndexes[nodeOrdinal + 1];
  952. for (var toNodeFieldIndex = beginEdgeToNodeFieldIndex;
  953. toNodeFieldIndex < endEdgeToNodeFieldIndex;
  954. toNodeFieldIndex += edgeFieldsCount) {
  955. var childNodeOrdinal = containmentEdges[toNodeFieldIndex] / nodeFieldCount;
  956. affected[nodeOrdinal2PostOrderIndex[childNodeOrdinal]] = 1;
  957. }
  958. }
  959. var changed = true;
  960. while (changed) {
  961. changed = false;
  962. for (var postOrderIndex = rootPostOrderedIndex - 1; postOrderIndex >= 0; --postOrderIndex) {
  963. if (affected[postOrderIndex] === 0)
  964. continue;
  965. affected[postOrderIndex] = 0;
  966. // If dominator of the entry has already been set to root,
  967. // then it can't propagate any further.
  968. if (dominators[postOrderIndex] === rootPostOrderedIndex)
  969. continue;
  970. nodeOrdinal = postOrderIndex2NodeOrdinal[postOrderIndex];
  971. var nodeFlag = !flags || (flags[nodeOrdinal] & flag);
  972. var newDominatorIndex = noEntry;
  973. var beginRetainerIndex = firstRetainerIndex[nodeOrdinal];
  974. var endRetainerIndex = firstRetainerIndex[nodeOrdinal + 1];
  975. for (var retainerIndex = beginRetainerIndex; retainerIndex < endRetainerIndex; ++retainerIndex) {
  976. var retainerEdgeIndex = retainingEdges[retainerIndex];
  977. var retainerEdgeType = containmentEdges[retainerEdgeIndex + edgeTypeOffset];
  978. var retainerNodeIndex = retainingNodes[retainerIndex];
  979. if (retainerNodeIndex !== rootNodeIndex && retainerEdgeType === edgeShortcutType)
  980. continue;
  981. var retainerNodeOrdinal = retainerNodeIndex / nodeFieldCount;
  982. var retainerNodeFlag = !flags || (flags[retainerNodeOrdinal] & flag);
  983. // We are skipping the edges from non-page-owned nodes to page-owned nodes.
  984. // Otherwise the dominators for the objects that also were retained by debugger would be affected.
  985. if (retainerNodeIndex !== rootNodeIndex && nodeFlag && !retainerNodeFlag)
  986. continue;
  987. var retanerPostOrderIndex = nodeOrdinal2PostOrderIndex[retainerNodeOrdinal];
  988. if (dominators[retanerPostOrderIndex] !== noEntry) {
  989. if (newDominatorIndex === noEntry)
  990. newDominatorIndex = retanerPostOrderIndex;
  991. else {
  992. while (retanerPostOrderIndex !== newDominatorIndex) {
  993. while (retanerPostOrderIndex < newDominatorIndex)
  994. retanerPostOrderIndex = dominators[retanerPostOrderIndex];
  995. while (newDominatorIndex < retanerPostOrderIndex)
  996. newDominatorIndex = dominators[newDominatorIndex];
  997. }
  998. }
  999. // If idom has already reached the root, it doesn't make sense
  1000. // to check other retainers.
  1001. if (newDominatorIndex === rootPostOrderedIndex)
  1002. break;
  1003. }
  1004. }
  1005. if (newDominatorIndex !== noEntry && dominators[postOrderIndex] !== newDominatorIndex) {
  1006. dominators[postOrderIndex] = newDominatorIndex;
  1007. changed = true;
  1008. nodeOrdinal = postOrderIndex2NodeOrdinal[postOrderIndex];
  1009. beginEdgeToNodeFieldIndex = firstEdgeIndexes[nodeOrdinal] + edgeToNodeOffset;
  1010. endEdgeToNodeFieldIndex = firstEdgeIndexes[nodeOrdinal + 1];
  1011. for (var toNodeFieldIndex = beginEdgeToNodeFieldIndex;
  1012. toNodeFieldIndex < endEdgeToNodeFieldIndex;
  1013. toNodeFieldIndex += edgeFieldsCount) {
  1014. var childNodeOrdinal = containmentEdges[toNodeFieldIndex] / nodeFieldCount;
  1015. affected[nodeOrdinal2PostOrderIndex[childNodeOrdinal]] = 1;
  1016. }
  1017. }
  1018. }
  1019. }
  1020. var dominatorsTree = new Uint32Array(nodesCount);
  1021. for (var postOrderIndex = 0, l = dominators.length; postOrderIndex < l; ++postOrderIndex) {
  1022. nodeOrdinal = postOrderIndex2NodeOrdinal[postOrderIndex];
  1023. dominatorsTree[nodeOrdinal] = postOrderIndex2NodeOrdinal[dominators[postOrderIndex]];
  1024. }
  1025. return dominatorsTree;
  1026. },
  1027. _calculateRetainedSizes: function(postOrderIndex2NodeOrdinal)
  1028. {
  1029. var nodeCount = this.nodeCount;
  1030. var nodes = this._nodes;
  1031. var nodeSelfSizeOffset = this._nodeSelfSizeOffset;
  1032. var nodeFieldCount = this._nodeFieldCount;
  1033. var dominatorsTree = this._dominatorsTree;
  1034. // Reuse now unused edge_count field to store retained size.
  1035. var nodeRetainedSizeOffset = this._nodeRetainedSizeOffset = this._nodeEdgeCountOffset;
  1036. delete this._nodeEdgeCountOffset;
  1037. for (var nodeIndex = 0, l = nodes.length; nodeIndex < l; nodeIndex += nodeFieldCount)
  1038. nodes[nodeIndex + nodeRetainedSizeOffset] = nodes[nodeIndex + nodeSelfSizeOffset];
  1039. // Propagate retained sizes for each node excluding root.
  1040. for (var postOrderIndex = 0; postOrderIndex < nodeCount - 1; ++postOrderIndex) {
  1041. var nodeOrdinal = postOrderIndex2NodeOrdinal[postOrderIndex];
  1042. var nodeIndex = nodeOrdinal * nodeFieldCount;
  1043. var dominatorIndex = dominatorsTree[nodeOrdinal] * nodeFieldCount;
  1044. nodes[dominatorIndex + nodeRetainedSizeOffset] += nodes[nodeIndex + nodeRetainedSizeOffset];
  1045. }
  1046. },
  1047. _buildDominatedNodes: function()
  1048. {
  1049. // Builds up two arrays:
  1050. // - "dominatedNodes" is a continuous array, where each node owns an
  1051. // interval (can be empty) with corresponding dominated nodes.
  1052. // - "indexArray" is an array of indexes in the "dominatedNodes"
  1053. // with the same positions as in the _nodeIndex.
  1054. var indexArray = this._firstDominatedNodeIndex = new Uint32Array(this.nodeCount + 1);
  1055. // All nodes except the root have dominators.
  1056. var dominatedNodes = this._dominatedNodes = new Uint32Array(this.nodeCount - 1);
  1057. // Count the number of dominated nodes for each node. Skip the root (node at
  1058. // index 0) as it is the only node that dominates itself.
  1059. var nodeFieldCount = this._nodeFieldCount;
  1060. var dominatorsTree = this._dominatorsTree;
  1061. var fromNodeOrdinal = 0;
  1062. var toNodeOrdinal = this.nodeCount;
  1063. var rootNodeOrdinal = this._rootNodeIndex / nodeFieldCount;
  1064. if (rootNodeOrdinal === fromNodeOrdinal)
  1065. fromNodeOrdinal = 1;
  1066. else if (rootNodeOrdinal === toNodeOrdinal - 1)
  1067. toNodeOrdinal = toNodeOrdinal - 1;
  1068. else
  1069. throw new Error("Root node is expected to be either first or last");
  1070. for (var nodeOrdinal = fromNodeOrdinal; nodeOrdinal < toNodeOrdinal; ++nodeOrdinal)
  1071. ++indexArray[dominatorsTree[nodeOrdinal]];
  1072. // Put in the first slot of each dominatedNodes slice the count of entries
  1073. // that will be filled.
  1074. var firstDominatedNodeIndex = 0;
  1075. for (var i = 0, l = this.nodeCount; i < l; ++i) {
  1076. var dominatedCount = dominatedNodes[firstDominatedNodeIndex] = indexArray[i];
  1077. indexArray[i] = firstDominatedNodeIndex;
  1078. firstDominatedNodeIndex += dominatedCount;
  1079. }
  1080. indexArray[this.nodeCount] = dominatedNodes.length;
  1081. // Fill up the dominatedNodes array with indexes of dominated nodes. Skip the root (node at
  1082. // index 0) as it is the only node that dominates itself.
  1083. for (var nodeOrdinal = fromNodeOrdinal; nodeOrdinal < toNodeOrdinal; ++nodeOrdinal) {
  1084. var dominatorOrdinal = dominatorsTree[nodeOrdinal];
  1085. var dominatedRefIndex = indexArray[dominatorOrdinal];
  1086. dominatedRefIndex += (--dominatedNodes[dominatedRefIndex]);
  1087. dominatedNodes[dominatedRefIndex] = nodeOrdinal * nodeFieldCount;
  1088. }
  1089. },
  1090. _markInvisibleEdges: function()
  1091. {
  1092. throw new Error("Not implemented");
  1093. },
  1094. _numbersComparator: function(a, b)
  1095. {
  1096. return a < b ? -1 : (a > b ? 1 : 0);
  1097. },
  1098. _calculateFlags: function()
  1099. {
  1100. throw new Error("Not implemented");
  1101. },
  1102. userObjectsMapAndFlag: function()
  1103. {
  1104. throw new Error("Not implemented");
  1105. },
  1106. calculateSnapshotDiff: function(baseSnapshotId, baseSnapshotAggregates)
  1107. {
  1108. var snapshotDiff = this._snapshotDiffs[baseSnapshotId];
  1109. if (snapshotDiff)
  1110. return snapshotDiff;
  1111. snapshotDiff = {};
  1112. var aggregates = this.aggregates(true, "allObjects");
  1113. for (var className in baseSnapshotAggregates) {
  1114. var baseAggregate = baseSnapshotAggregates[className];
  1115. var diff = this._calculateDiffForClass(baseAggregate, aggregates[className]);
  1116. if (diff)
  1117. snapshotDiff[className] = diff;
  1118. }
  1119. var emptyBaseAggregate = { ids: [], indexes: [], selfSizes: [] };
  1120. for (var className in aggregates) {
  1121. if (className in baseSnapshotAggregates)
  1122. continue;
  1123. snapshotDiff[className] = this._calculateDiffForClass(emptyBaseAggregate, aggregates[className]);
  1124. }
  1125. this._snapshotDiffs[baseSnapshotId] = snapshotDiff;
  1126. return snapshotDiff;
  1127. },
  1128. _calculateDiffForClass: function(baseAggregate, aggregate)
  1129. {
  1130. var baseIds = baseAggregate.ids;
  1131. var baseIndexes = baseAggregate.indexes;
  1132. var baseSelfSizes = baseAggregate.selfSizes;
  1133. var indexes = aggregate ? aggregate.idxs : [];
  1134. var i = 0, l = baseIds.length;
  1135. var j = 0, m = indexes.length;
  1136. var diff = { addedCount: 0,
  1137. removedCount: 0,
  1138. addedSize: 0,
  1139. removedSize: 0,
  1140. deletedIndexes: [],
  1141. addedIndexes: [] };
  1142. var nodeB = this.createNode(indexes[j]);
  1143. while (i < l && j < m) {
  1144. var nodeAId = baseIds[i];
  1145. if (nodeAId < nodeB.id()) {
  1146. diff.deletedIndexes.push(baseIndexes[i]);
  1147. diff.removedCount++;
  1148. diff.removedSize += baseSelfSizes[i];
  1149. ++i;
  1150. } else if (nodeAId > nodeB.id()) { // Native nodes(e.g. dom groups) may have ids less than max JS object id in the base snapshot
  1151. diff.addedIndexes.push(indexes[j]);
  1152. diff.addedCount++;
  1153. diff.addedSize += nodeB.selfSize();
  1154. nodeB.nodeIndex = indexes[++j];
  1155. } else { // nodeAId === nodeB.id()
  1156. ++i;
  1157. nodeB.nodeIndex = indexes[++j];
  1158. }
  1159. }
  1160. while (i < l) {
  1161. diff.deletedIndexes.push(baseIndexes[i]);
  1162. diff.removedCount++;
  1163. diff.removedSize += baseSelfSizes[i];
  1164. ++i;
  1165. }
  1166. while (j < m) {
  1167. diff.addedIndexes.push(indexes[j]);
  1168. diff.addedCount++;
  1169. diff.addedSize += nodeB.selfSize();
  1170. nodeB.nodeIndex = indexes[++j];
  1171. }
  1172. diff.countDelta = diff.addedCount - diff.removedCount;
  1173. diff.sizeDelta = diff.addedSize - diff.removedSize;
  1174. if (!diff.addedCount && !diff.removedCount)
  1175. return null;
  1176. return diff;
  1177. },
  1178. _nodeForSnapshotObjectId: function(snapshotObjectId)
  1179. {
  1180. for (var it = this._allNodes(); it.hasNext(); it.next()) {
  1181. if (it.node.id() === snapshotObjectId)
  1182. return it.node;
  1183. }
  1184. return null;
  1185. },
  1186. nodeClassName: function(snapshotObjectId)
  1187. {
  1188. var node = this._nodeForSnapshotObjectId(snapshotObjectId);
  1189. if (node)
  1190. return node.className();
  1191. return null;
  1192. },
  1193. dominatorIdsForNode: function(snapshotObjectId)
  1194. {
  1195. var node = this._nodeForSnapshotObjectId(snapshotObjectId);
  1196. if (!node)
  1197. return null;
  1198. var result = [];
  1199. while (!node.isRoot()) {
  1200. result.push(node.id());
  1201. node.nodeIndex = node.dominatorIndex();
  1202. }
  1203. return result;
  1204. },
  1205. _parseFilter: function(filter)
  1206. {
  1207. if (!filter)
  1208. return null;
  1209. var parsedFilter = eval("(function(){return " + filter + "})()");
  1210. return parsedFilter.bind(this);
  1211. },
  1212. createEdgesProvider: function(nodeIndex, showHiddenData)
  1213. {
  1214. var node = this.createNode(nodeIndex);
  1215. var filter = this.containmentEdgesFilter(showHiddenData);
  1216. return new WebInspector.HeapSnapshotEdgesProvider(this, filter, node.edges());
  1217. },
  1218. createEdgesProviderForTest: function(nodeIndex, filter)
  1219. {
  1220. var node = this.createNode(nodeIndex);
  1221. return new WebInspector.HeapSnapshotEdgesProvider(this, filter, node.edges());
  1222. },
  1223. retainingEdgesFilter: function(showHiddenData)
  1224. {
  1225. return null;
  1226. },
  1227. containmentEdgesFilter: function(showHiddenData)
  1228. {
  1229. return null;
  1230. },
  1231. createRetainingEdgesProvider: function(nodeIndex, showHiddenData)
  1232. {
  1233. var node = this.createNode(nodeIndex);
  1234. var filter = this.retainingEdgesFilter(showHiddenData);
  1235. return new WebInspector.HeapSnapshotEdgesProvider(this, filter, node.retainers());
  1236. },
  1237. createAddedNodesProvider: function(baseSnapshotId, className)
  1238. {
  1239. var snapshotDiff = this._snapshotDiffs[baseSnapshotId];
  1240. var diffForClass = snapshotDiff[className];
  1241. return new WebInspector.HeapSnapshotNodesProvider(this, null, diffForClass.addedIndexes);
  1242. },
  1243. createDeletedNodesProvider: function(nodeIndexes)
  1244. {
  1245. return new WebInspector.HeapSnapshotNodesProvider(this, null, nodeIndexes);
  1246. },
  1247. classNodesFilter: function()
  1248. {
  1249. return null;
  1250. },
  1251. createNodesProviderForClass: function(className, aggregatesKey)
  1252. {
  1253. return new WebInspector.HeapSnapshotNodesProvider(this, this.classNodesFilter(), this.aggregates(false, aggregatesKey)[className].idxs);
  1254. },
  1255. createNodesProviderForDominator: function(nodeIndex)
  1256. {
  1257. var node = this.createNode(nodeIndex);
  1258. return new WebInspector.HeapSnapshotNodesProvider(this, null, this._dominatedNodesOfNode(node));
  1259. },
  1260. updateStaticData: function()
  1261. {
  1262. return {nodeCount: this.nodeCount, rootNodeIndex: this._rootNodeIndex, totalSize: this.totalSize, uid: this.uid};
  1263. }
  1264. };
  1265. /**
  1266. * @constructor
  1267. * @param {Array.<number>=} unfilteredIterationOrder
  1268. */
  1269. WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, unfilteredIterationOrder)
  1270. {
  1271. this._filter = filter;
  1272. this._iterator = iterator;
  1273. this._unfilteredIterationOrder = unfilteredIterationOrder;
  1274. this._iterationOrder = null;
  1275. this._position = 0;
  1276. this._currentComparator = null;
  1277. this._sortedPrefixLength = 0;
  1278. }
  1279. WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
  1280. _createIterationOrder: function()
  1281. {
  1282. if (this._iterationOrder)
  1283. return;
  1284. if (this._unfilteredIterationOrder && !this._filter) {
  1285. this._iterationOrder = this._unfilteredIterationOrder.slice(0);
  1286. this._unfilteredIterationOrder = null;
  1287. return;
  1288. }
  1289. this._iterationOrder = [];
  1290. var iterator = this._iterator;
  1291. if (!this._unfilteredIterationOrder && !this._filter) {
  1292. for (iterator.rewind(); iterator.hasNext(); iterator.next())
  1293. this._iterationOrder.push(iterator.index());
  1294. } else if (!this._unfilteredIterationOrder) {
  1295. for (iterator.rewind(); iterator.hasNext(); iterator.next()) {
  1296. if (this._filter(iterator.item()))
  1297. this._iterationOrder.push(iterator.index());
  1298. }
  1299. } else {
  1300. var order = this._unfilteredIterationOrder.constructor === Array ?
  1301. this._unfilteredIterationOrder : this._unfilteredIterationOrder.slice(0);
  1302. for (var i = 0, l = order.length; i < l; ++i) {
  1303. iterator.setIndex(order[i]);
  1304. if (this._filter(iterator.item()))
  1305. this._iterationOrder.push(iterator.index());
  1306. }
  1307. this._unfilteredIterationOrder = null;
  1308. }
  1309. },
  1310. rewind: function()
  1311. {
  1312. this._position = 0;
  1313. },
  1314. hasNext: function()
  1315. {
  1316. return this._position < this._iterationOrder.length;
  1317. },
  1318. isEmpty: function()
  1319. {
  1320. if (this._iterationOrder)
  1321. return !this._iterationOrder.length;
  1322. if (this._unfilteredIterationOrder && !this._filter)
  1323. return !this._unfilteredIterationOrder.length;
  1324. var iterator = this._iterator;
  1325. if (!this._unfilteredIterationOrder && !this._filter) {
  1326. iterator.rewind();
  1327. return !iterator.hasNext();
  1328. } else if (!this._unfilteredIterationOrder) {
  1329. for (iterator.rewind(); iterator.hasNext(); iterator.next())
  1330. if (this._filter(iterator.item()))
  1331. return false;
  1332. } else {
  1333. var order = this._unfilteredIterationOrder.constructor === Array ?
  1334. this._unfilteredIterationOrder : this._unfilteredIterationOrder.slice(0);
  1335. for (var i = 0, l = order.length; i < l; ++i) {
  1336. iterator.setIndex(order[i]);
  1337. if (this._filter(iterator.item()))
  1338. return false;
  1339. }
  1340. }
  1341. return true;
  1342. },
  1343. item: function()
  1344. {
  1345. this._iterator.setIndex(this._iterationOrder[this._position]);
  1346. return this._iterator.item();
  1347. },
  1348. get length()
  1349. {
  1350. this._createIterationOrder();
  1351. return this._iterationOrder.length;
  1352. },
  1353. next: function()
  1354. {
  1355. ++this._position;
  1356. },
  1357. /**
  1358. * @param {number} begin
  1359. * @param {number} end
  1360. */
  1361. serializeItemsRange: function(begin, end)
  1362. {
  1363. this._createIterationOrder();
  1364. if (begin > end)
  1365. throw new Error("Start position > end position: " + begin + " > " + end);
  1366. if (end >= this._iterationOrder.length)
  1367. end = this._iterationOrder.length;
  1368. if (this._sortedPrefixLength < end) {
  1369. this.sort(this._currentComparator, this._sortedPrefixLength, this._iterationOrder.length - 1, end - this._sortedPrefixLength);
  1370. this._sortedPrefixLength = end;
  1371. }
  1372. this._position = begin;
  1373. var startPosition = this._position;
  1374. var count = end - begin;
  1375. var result = new Array(count);
  1376. for (var i = 0 ; i < count && this.hasNext(); ++i, this.next())
  1377. result[i] = this.item().serialize();
  1378. result.length = i;
  1379. result.totalLength = this._iterationOrder.length;
  1380. result.startPosition = startPosition;
  1381. result.endPosition = this._position;
  1382. return result;
  1383. },
  1384. sortAll: function()
  1385. {
  1386. this._createIterationOrder();
  1387. if (this._sortedPrefixLength === this._iterationOrder.length)
  1388. return;
  1389. this.sort(this._currentComparator, this._sortedPrefixLength, this._iterationOrder.length - 1, this._iterationOrder.length);
  1390. this._sortedPrefixLength = this._iterationOrder.length;
  1391. },
  1392. sortAndRewind: function(comparator)
  1393. {
  1394. this._currentComparator = comparator;
  1395. this._sortedPrefixLength = 0;
  1396. this.rewind();
  1397. }
  1398. }
  1399. WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator = function(fieldNames)
  1400. {
  1401. return {fieldName1: fieldNames[0], ascending1: fieldNames[1], fieldName2: fieldNames[2], ascending2: fieldNames[3]};
  1402. }
  1403. /**
  1404. * @constructor
  1405. * @extends {WebInspector.HeapSnapshotFilteredOrderedIterator}
  1406. */
  1407. WebInspector.HeapSnapshotEdgesProvider = function(snapshot, filter, edgesIter)
  1408. {
  1409. this.snapshot = snapshot;
  1410. WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, edgesIter, filter);
  1411. }
  1412. WebInspector.HeapSnapshotEdgesProvider.prototype = {
  1413. sort: function(comparator, leftBound, rightBound, count)
  1414. {
  1415. var fieldName1 = comparator.fieldName1;
  1416. var fieldName2 = comparator.fieldName2;
  1417. var ascending1 = comparator.ascending1;
  1418. var ascending2 = comparator.ascending2;
  1419. var edgeA = this._iterator.item().clone();
  1420. var edgeB = edgeA.clone();
  1421. var nodeA = this.snapshot.createNode();
  1422. var nodeB = this.snapshot.createNode();
  1423. function compareEdgeFieldName(ascending, indexA, indexB)
  1424. {
  1425. edgeA.edgeIndex = indexA;
  1426. edgeB.edgeIndex = indexB;
  1427. if (edgeB.name() === "__proto__") return -1;
  1428. if (edgeA.name() === "__proto__") return 1;
  1429. var result =
  1430. edgeA.hasStringName() === edgeB.hasStringName() ?
  1431. (edgeA.name() < edgeB.name() ? -1 : (edgeA.name() > edgeB.name() ? 1 : 0)) :
  1432. (edgeA.hasStringName() ? -1 : 1);
  1433. return ascending ? result : -result;
  1434. }
  1435. function compareNodeField(fieldName, ascending, indexA, indexB)
  1436. {
  1437. edgeA.edgeIndex = indexA;
  1438. nodeA.nodeIndex = edgeA.nodeIndex();
  1439. var valueA = nodeA[fieldName]();
  1440. edgeB.edgeIndex = indexB;
  1441. nodeB.nodeIndex = edgeB.nodeIndex();
  1442. var valueB = nodeB[fieldName]();
  1443. var result = valueA < valueB ? -1 : (valueA > valueB ? 1 : 0);
  1444. return ascending ? result : -result;
  1445. }
  1446. function compareEdgeAndNode(indexA, indexB) {
  1447. var result = compareEdgeFieldName(ascending1, indexA, indexB);
  1448. if (result === 0)
  1449. result = compareNodeField(fieldName2, ascending2, indexA, indexB);
  1450. return result;
  1451. }
  1452. function compareNodeAndEdge(indexA, indexB) {
  1453. var result = compareNodeField(fieldName1, ascending1, indexA, indexB);
  1454. if (result === 0)
  1455. result = compareEdgeFieldName(ascending2, indexA, indexB);
  1456. return result;
  1457. }
  1458. function compareNodeAndNode(indexA, indexB) {
  1459. var result = compareNodeField(fieldName1, ascending1, indexA, indexB);
  1460. if (result === 0)
  1461. result = compareNodeField(fieldName2, ascending2, indexA, indexB);
  1462. return result;
  1463. }
  1464. if (fieldName1 === "!edgeName")
  1465. this._iterationOrder.sortRange(compareEdgeAndNode, leftBound, rightBound, count);
  1466. else if (fieldName2 === "!edgeName")
  1467. this._iterationOrder.sortRange(compareNodeAndEdge, leftBound, rightBound, count);
  1468. else
  1469. this._iterationOrder.sortRange(compareNodeAndNode, leftBound, rightBound, count);
  1470. },
  1471. __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype
  1472. }
  1473. /**
  1474. * @constructor
  1475. * @extends {WebInspector.HeapSnapshotFilteredOrderedIterator}
  1476. * @param {Array.<number>=} nodeIndexes
  1477. */
  1478. WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes)
  1479. {
  1480. this.snapshot = snapshot;
  1481. WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot._allNodes(), filter, nodeIndexes);
  1482. }
  1483. WebInspector.HeapSnapshotNodesProvider.prototype = {
  1484. nodePosition: function(snapshotObjectId)
  1485. {
  1486. this._createIterationOrder();
  1487. if (this.isEmpty())
  1488. return -1;
  1489. this.sortAll();
  1490. var node = this.snapshot.createNode();
  1491. for (var i = 0; i < this._iterationOrder.length; i++) {
  1492. node.nodeIndex = this._iterationOrder[i];
  1493. if (node.id() === snapshotObjectId)
  1494. return i;
  1495. }
  1496. return -1;
  1497. },
  1498. sort: function(comparator, leftBound, rightBound, count)
  1499. {
  1500. var fieldName1 = comparator.fieldName1;
  1501. var fieldName2 = comparator.fieldName2;
  1502. var ascending1 = comparator.ascending1;
  1503. var ascending2 = comparator.ascending2;
  1504. var nodeA = this.snapshot.createNode();
  1505. var nodeB = this.snapshot.createNode();
  1506. function sortByNodeField(fieldName, ascending)
  1507. {
  1508. var valueOrFunctionA = nodeA[fieldName];
  1509. var valueA = typeof valueOrFunctionA !== "function" ? valueOrFunctionA : valueOrFunctionA.call(nodeA);
  1510. var valueOrFunctionB = nodeB[fieldName];
  1511. var valueB = typeof valueOrFunctionB !== "function" ? valueOrFunctionB : valueOrFunctionB.call(nodeB);
  1512. var result = valueA < valueB ? -1 : (valueA > valueB ? 1 : 0);
  1513. return ascending ? result : -result;
  1514. }
  1515. function sortByComparator(indexA, indexB) {
  1516. nodeA.nodeIndex = indexA;
  1517. nodeB.nodeIndex = indexB;
  1518. var result = sortByNodeField(fieldName1, ascending1);
  1519. if (result === 0)
  1520. result = sortByNodeField(fieldName2, ascending2);
  1521. return result;
  1522. }
  1523. this._iterationOrder.sortRange(sortByComparator, leftBound, rightBound, count);
  1524. },
  1525. __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype
  1526. }