| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library object_graph; | 5 library object_graph; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
| 10 | 10 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 var result = _mostRetained; | 355 var result = _mostRetained; |
| 356 if (classId != null) { | 356 if (classId != null) { |
| 357 result = result.where((u) => u.vmCid == classId); | 357 result = result.where((u) => u.vmCid == classId); |
| 358 } | 358 } |
| 359 if (limit != null) { | 359 if (limit != null) { |
| 360 result = result.take(limit); | 360 result = result.take(limit); |
| 361 } | 361 } |
| 362 return result; | 362 return result; |
| 363 } | 363 } |
| 364 | 364 |
| 365 Future process(statusReporter) async { | 365 Stream<List> process() { |
| 366 // We build futures here instead of marking the steps as async to avoid the | 366 final controller = new StreamController<List>.broadcast(); |
| 367 // heavy lifting being inside a transformed method. | 367 (() async { |
| 368 // We build futures here instead of marking the steps as async to avoid th
e |
| 369 // heavy lifting being inside a transformed method. |
| 368 | 370 |
| 369 statusReporter.add("Remapping $_N objects..."); | 371 controller.add(["Remapping $_N objects...", 0.0]); |
| 370 await new Future(() => _remapNodes()); | 372 await new Future(() => _remapNodes()); |
| 371 | 373 |
| 372 statusReporter.add("Remapping $_E references..."); | 374 controller.add(["Remapping $_E references...", 15.0]); |
| 373 await new Future(() => _remapEdges()); | 375 await new Future(() => _remapEdges()); |
| 374 | 376 |
| 375 _addrToId = null; | 377 _addrToId = null; |
| 376 _chunks = null; | 378 _chunks = null; |
| 377 | 379 |
| 378 statusReporter.add("Finding depth-first order..."); | 380 controller.add(["Finding depth-first order...", 30.0]); |
| 379 await new Future(() => _dfs()); | 381 await new Future(() => _dfs()); |
| 380 | 382 |
| 381 statusReporter.add("Finding predecessors..."); | 383 controller.add(["Finding predecessors...", 45.0]); |
| 382 await new Future(() => _buildPredecessors()); | 384 await new Future(() => _buildPredecessors()); |
| 383 | 385 |
| 384 statusReporter.add("Finding dominators..."); | 386 controller.add(["Finding dominators...", 60.0]); |
| 385 await new Future(() => _buildDominators()); | 387 await new Future(() => _buildDominators()); |
| 386 | 388 |
| 387 _firstPreds = null; | 389 _firstPreds = null; |
| 388 _preds = null; | 390 _preds = null; |
| 389 | 391 |
| 390 _semi = null; | 392 _semi = null; |
| 391 _parent = null; | 393 _parent = null; |
| 392 | 394 |
| 393 statusReporter.add("Finding retained sizes..."); | 395 controller.add(["Finding retained sizes...", 75.0]); |
| 394 await new Future(() => _calculateRetainedSizes()); | 396 await new Future(() => _calculateRetainedSizes()); |
| 395 | 397 |
| 396 _vertex = null; | 398 _vertex = null; |
| 397 | 399 |
| 398 statusReporter.add("Loaded"); | 400 controller.add(["Loaded", 100.0]); |
| 399 return this; | 401 controller.close(); |
| 402 }()); |
| 403 return controller.stream; |
| 400 } | 404 } |
| 401 | 405 |
| 402 List<ByteData> _chunks; | 406 List<ByteData> _chunks; |
| 403 | 407 |
| 404 int _kObjectAlignment; | 408 int _kObjectAlignment; |
| 405 int _N; | 409 int _N; |
| 406 int _E; | 410 int _E; |
| 407 int _size; | 411 int _size; |
| 408 | 412 |
| 409 // Indexed by node id, with id 0 representing invalid/uninitialized. | 413 // Indexed by node id, with id 0 representing invalid/uninitialized. |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 for (var i = N; i > 1; i--) { | 816 for (var i = N; i > 1; i--) { |
| 813 var v = vertex[i]; | 817 var v = vertex[i]; |
| 814 assert(v != 1); | 818 assert(v != 1); |
| 815 retainedSizes[doms[i]] += retainedSizes[i]; | 819 retainedSizes[doms[i]] += retainedSizes[i]; |
| 816 } | 820 } |
| 817 | 821 |
| 818 _retainedSizes = retainedSizes; | 822 _retainedSizes = retainedSizes; |
| 819 _size = size; | 823 _size = size; |
| 820 } | 824 } |
| 821 } | 825 } |
| OLD | NEW |