Index: sdk/lib/_internal/compiler/implementation/dump_info.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/dump_info.dart b/sdk/lib/_internal/compiler/implementation/dump_info.dart |
index c5d0db85679d36d8849478deaa078147bb2f338c..51787fe2bd2a8a0dd2d30290cd1d440906c77fc5 100644 |
--- a/sdk/lib/_internal/compiler/implementation/dump_info.dart |
+++ b/sdk/lib/_internal/compiler/implementation/dump_info.dart |
@@ -18,11 +18,11 @@ import 'dart2jslib.dart' show |
CodeBuffer; |
import 'dart_types.dart' show DartType; |
import 'types/types.dart' show TypeMask; |
-import 'util/util.dart' show modifiersToString; |
+import 'util/util.dart' show modifiersToString, SpannableAssertionFailure; |
import 'deferred_load.dart' show OutputUnit; |
import 'js_backend/js_backend.dart' show JavaScriptBackend; |
import 'js/js.dart' as jsAst; |
-import 'compilation_info.dart' show CompilationInformation; |
+import 'dependency_info.dart' show DependencyInformation; |
/// Maps elements to an id. Supports lookups in |
/// both directions. |
@@ -34,6 +34,8 @@ class ElementMapper { |
ElementMapper(this.name); |
+ Iterable<Element> get elements => _elementToId.keys; |
+ |
String add(Element e) { |
if (_elementToId.containsKey(e)) { |
return name + "/${_elementToId[e]}"; |
@@ -54,6 +56,8 @@ class DividedElementMapper { |
ElementMapper _class = new ElementMapper('class'); |
ElementMapper _function = new ElementMapper('function'); |
+ Iterable<Element> get functions => _function.elements; |
+ |
// Convert this database of elements into JSON for rendering |
Map<String, dynamic> _toJson(ElementToJsonVisitor elementToJson) { |
Map<String, dynamic> json = {}; |
@@ -78,7 +82,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> { |
DividedElementMapper mapper = new DividedElementMapper(); |
Compiler compiler; |
- CompilationInformation compilationInfo; |
+ DependencyInformation dependencyInfo; |
Map<Element, Map<String, dynamic>> jsonCache = {}; |
Map<Element, jsAst.Expression> codeCache; |
@@ -91,7 +95,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> { |
ElementToJsonVisitor(Compiler compiler) { |
this.compiler = compiler; |
- this.compilationInfo = compiler.enqueuer.codegen.compilationInfo; |
+ this.dependencyInfo = compiler.enqueuer.codegen.dependencyInfo; |
programSize = compiler.assembledCode.length; |
compilationMoment = new DateTime.now(); |
@@ -108,8 +112,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> { |
// If keeping the element is in question (like if a function has a size |
// of zero), only keep it if it holds dependencies to elsewhere. |
bool shouldKeep(Element element) { |
- return compilationInfo.addsToWorkListMap.containsKey(element) || |
- compilationInfo.enqueuesMap.containsKey(element); |
+ return dependencyInfo.selectorsFromElement.containsKey(element); |
} |
Map<String, dynamic> toJson() { |
@@ -121,6 +124,14 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> { |
return jsonCache.putIfAbsent(element, () => element.accept(this)); |
} |
+ String idOf(Element element) { |
+ if (jsonCache.containsKey(element) && jsonCache[element] != null) { |
+ return jsonCache[element]['id']; |
+ } else { |
+ return null; |
+ } |
+ } |
+ |
Map<String, dynamic> visitElement(Element element) { |
return null; |
} |
@@ -464,34 +475,24 @@ class DumpInfoTask extends CompilerTask { |
void dumpInfoJson(StringSink buffer) { |
JsonEncoder encoder = const JsonEncoder(); |
- // `A` uses and depends on the functions `Bs`. |
- // A Bs |
- Map<String, List<String>> holding = <String, List<String>>{}; |
- |
DateTime startToJsonTime = new DateTime.now(); |
- CompilationInformation compilationInfo = |
- infoCollector.compiler.enqueuer.codegen.compilationInfo; |
- compilationInfo.addsToWorkListMap.forEach((func, deps) { |
- if (func != null) { |
- var funcJson = infoCollector.process(func); |
- if (funcJson != null) { |
- var funcId = funcJson['id']; |
- |
- List<String> heldList = <String>[]; |
- |
- for (var held in deps) { |
- // "process" to get the ids of the elements. |
- var heldJson = infoCollector.process(held); |
- if (heldJson != null) { |
- var heldId = heldJson['id']; |
- heldList.add(heldId); |
- } |
- } |
- holding[funcId] = heldList; |
+ DependencyInformation dependencyInfo = |
+ infoCollector.compiler.enqueuer.codegen.dependencyInfo; |
+ |
+ Map<String, List<String>> holding = <String, List<String>>{}; |
+ for (Element fn in infoCollector.mapper.functions) { |
+ Iterable<Element> pulling = dependencyInfo.getRetaining(fn, compiler); |
+ if (pulling.length > 0) { |
+ String fnId = infoCollector.idOf(fn); |
+ if (fnId != null) { |
+ holding[fnId] = pulling |
+ .map((a) => infoCollector.idOf(a)) |
+ .where((a) => a != null) |
+ .toList(); |
} |
} |
- }); |
+ } |
Map<String, dynamic> outJson = { |
'elements': infoCollector.toJson(), |