| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dump_info; | 5 library dump_info; |
| 6 | 6 |
| 7 import 'dart:convert' | 7 import 'dart:convert' |
| 8 show HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink; | 8 show HtmlEscape, JsonEncoder, StringConversionSink, ChunkedConversionSink; |
| 9 | 9 |
| 10 import 'elements/elements.dart'; | 10 import 'elements/elements.dart'; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 * function body | 356 * function body |
| 357 */ | 357 */ |
| 358 void elementUsesSelector(Element element, UniverseSelector selector) { | 358 void elementUsesSelector(Element element, UniverseSelector selector) { |
| 359 if (compiler.dumpInfo) { | 359 if (compiler.dumpInfo) { |
| 360 selectorsFromElement | 360 selectorsFromElement |
| 361 .putIfAbsent(element, () => new Set<UniverseSelector>()) | 361 .putIfAbsent(element, () => new Set<UniverseSelector>()) |
| 362 .add(selector); | 362 .add(selector); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 final Map<Element, List<Element>> _dependencies = {}; |
| 367 void registerDependency(Element source, Element target) { |
| 368 _dependencies.putIfAbsent(source, () => new Set()).add(target); |
| 369 } |
| 370 |
| 366 /** | 371 /** |
| 367 * Returns an iterable of [Selection]s that are used by | 372 * Returns an iterable of [Selection]s that are used by |
| 368 * [element]. Each [Selection] contains an element that is | 373 * [element]. Each [Selection] contains an element that is |
| 369 * used and the selector that selected the element. | 374 * used and the selector that selected the element. |
| 370 */ | 375 */ |
| 371 Iterable<Selection> getRetaining(Element element) { | 376 Iterable<Selection> getRetaining(Element element) { |
| 372 if (!selectorsFromElement.containsKey(element)) { | 377 if (!selectorsFromElement.containsKey(element)) { |
| 373 return const <Selection>[]; | 378 return const <Selection>[]; |
| 374 } else { | 379 } else { |
| 375 return selectorsFromElement[element].expand((UniverseSelector selector) { | 380 return selectorsFromElement[element].expand((UniverseSelector selector) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 FunctionInfo functionInfo = infoCollector._elementToInfo[element]; | 490 FunctionInfo functionInfo = infoCollector._elementToInfo[element]; |
| 486 if (functionInfo == null) continue; | 491 if (functionInfo == null) continue; |
| 487 for (Element held in inlineMap[element]) { | 492 for (Element held in inlineMap[element]) { |
| 488 Info heldInfo = infoCollector._elementToInfo[held]; | 493 Info heldInfo = infoCollector._elementToInfo[held]; |
| 489 if (heldInfo == null) continue; | 494 if (heldInfo == null) continue; |
| 490 functionInfo.uses.add(new DependencyInfo(heldInfo, 'inlined')); | 495 functionInfo.uses.add(new DependencyInfo(heldInfo, 'inlined')); |
| 491 } | 496 } |
| 492 } | 497 } |
| 493 | 498 |
| 494 AllInfo result = infoCollector.result; | 499 AllInfo result = infoCollector.result; |
| 500 |
| 501 for (Element element in _dependencies.keys) { |
| 502 var a = infoCollector._elementToInfo[element]; |
| 503 if (a == null) continue; |
| 504 result.deps[a] = _dependencies[element] |
| 505 .map((o) => infoCollector._elementToInfo[o]) |
| 506 .where((o) => o != null) |
| 507 .toList(); |
| 508 } |
| 509 |
| 495 result.deferredFiles = compiler.deferredLoadTask.computeDeferredMap(); | 510 result.deferredFiles = compiler.deferredLoadTask.computeDeferredMap(); |
| 496 stopwatch.stop(); | 511 stopwatch.stop(); |
| 497 result.program = new ProgramInfo( | 512 result.program = new ProgramInfo( |
| 498 size: _programSize, | 513 size: _programSize, |
| 499 dart2jsVersion: compiler.hasBuildId ? compiler.buildId : null, | 514 dart2jsVersion: compiler.hasBuildId ? compiler.buildId : null, |
| 500 compilationMoment: new DateTime.now(), | 515 compilationMoment: new DateTime.now(), |
| 501 compilationDuration: compiler.totalCompileTime.elapsed, | 516 compilationDuration: compiler.totalCompileTime.elapsed, |
| 502 toJsonDuration: stopwatch.elapsedMilliseconds, | 517 toJsonDuration: stopwatch.elapsedMilliseconds, |
| 503 dumpInfoDuration: this.timing, | 518 dumpInfoDuration: this.timing, |
| 504 noSuchMethodEnabled: compiler.backend.enabledNoSuchMethod, | 519 noSuchMethodEnabled: compiler.backend.enabledNoSuchMethod, |
| 505 minified: compiler.enableMinification); | 520 minified: compiler.enableMinification); |
| 506 | 521 |
| 507 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 522 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
| 508 new StringConversionSink.fromStringSink(buffer)); | 523 new StringConversionSink.fromStringSink(buffer)); |
| 509 sink.add(result.toJson()); | 524 sink.add(result.toJson()); |
| 510 compiler.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 525 compiler.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
| 511 'text': "View the dumped .info.json file at " | 526 'text': "View the dumped .info.json file at " |
| 512 "https://dart-lang.github.io/dump-info-visualizer" | 527 "https://dart-lang.github.io/dump-info-visualizer" |
| 513 }); | 528 }); |
| 514 } | 529 } |
| 515 } | 530 } |
| OLD | NEW |