Chromium Code Reviews| Index: pkg/compiler/lib/src/deferred_load.dart |
| diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart |
| index 937e620ef9a1c5d92aa6db17a7d585e3066992fc..63bed64e6c8415c0e85d8c1538e429671934939b 100644 |
| --- a/pkg/compiler/lib/src/deferred_load.dart |
| +++ b/pkg/compiler/lib/src/deferred_load.dart |
| @@ -32,6 +32,8 @@ import 'elements/elements.dart' show |
| PrefixElement, |
| ScopeContainerElement, |
| TypedefElement; |
| +import 'enqueue.dart' show |
| + WorldImpact; |
| import 'js_backend/js_backend.dart' show |
| JavaScriptBackend; |
| import 'resolution/resolution.dart' show |
| @@ -298,38 +300,46 @@ class DeferredLoadTask extends CompilerTask { |
| // TODO(sigurdm): We want to be more specific about this - need a better |
| // way to query "liveness". |
|
sigurdm
2015/10/14 08:00:36
Move this TODO into the else-branch.
Johnni Winther
2015/10/14 08:42:16
Done.
|
| - if (astElement is! TypedefElement && |
| - !compiler.enqueuer.resolution.hasBeenProcessed(astElement)) { |
| - return; |
| - } |
| - |
| - TreeElements treeElements = astElement.resolvedAst.elements; |
| + if (astElement.isTypedef) { |
| + TypedefElement typdef = astElement; |
| + collectTypeDependencies(typdef.thisType); |
| + } else { |
| + astElement = element.analyzableElement.declaration; |
|
sigurdm
2015/10/14 08:00:36
AstElement analyzableElement = astElement.analyzab
Johnni Winther
2015/10/14 08:42:16
Done.
|
| + if (!compiler.enqueuer.resolution.hasBeenProcessed(astElement)) { |
| + return; |
| + } |
| - assert(treeElements != null); |
| + WorldImpact worldImpact = |
| + compiler.resolution.getWorldImpact(astElement); |
| + elements.addAll(worldImpact.staticUses); |
| + elements.addAll(worldImpact.closures); |
| + for (DartType type in worldImpact.typeLiterals) { |
| + if (type.isTypedef || type.isInterfaceType) { |
| + elements.add(type.element); |
| + } |
| + } |
| + for (InterfaceType type in worldImpact.instantiatedTypes) { |
| + elements.add(type.element); |
| + } |
| - for (Element dependency in treeElements.allElements) { |
| - if (dependency.isLocal && !dependency.isFunction) continue; |
| - if (dependency.isErroneous) continue; |
| - if (dependency.isTypeVariable) continue; |
| + TreeElements treeElements = astElement.resolvedAst.elements; |
| + assert(treeElements != null); |
| - elements.add(dependency); |
| - } |
| + for (DartType type in treeElements.requiredTypes) { |
| + collectTypeDependencies(type); |
| + } |
| - for (DartType type in treeElements.requiredTypes) { |
| - collectTypeDependencies(type); |
| + treeElements.forEachConstantNode((Node node, _) { |
| + // Explicitly depend on the backend constants. |
| + ConstantValue value = |
| + backend.constants.getConstantValueForNode(node, treeElements); |
| + if (value != null) { |
| + // TODO(johnniwinther): Assert that all constants have values when |
| + // these are directly evaluated. |
| + constants.add(value); |
| + } |
| + }); |
| } |
| - |
| - treeElements.forEachConstantNode((Node node, _) { |
| - // Explicitly depend on the backend constants. |
| - ConstantValue value = |
| - backend.constants.getConstantValueForNode(node, treeElements); |
| - if (value != null) { |
| - // TODO(johnniwinther): Assert that all constants have values when |
| - // these are directly evaluated. |
| - constants.add(value); |
| - } |
| - }); |
| - elements.addAll(treeElements.otherDependencies); |
| } |
| // TODO(sigurdm): How is metadata on a patch-class handled? |
| @@ -863,6 +873,41 @@ class DeferredLoadTask extends CompilerTask { |
| }); |
| return mapping; |
| } |
| + |
| + /// Creates a textual representation of the output unit content. |
| + String dump() { |
| + Map<OutputUnit, List<String>> elementMap = <OutputUnit, List<String>>{}; |
| + Map<OutputUnit, List<String>> constantMap = |
| + <OutputUnit, List<String>>{}; |
| + _elementToOutputUnit.forEach((Element element, OutputUnit output) { |
| + elementMap.putIfAbsent(output, () => <String>[]).add('$element'); |
| + }); |
| + _constantToOutputUnit.forEach((ConstantValue value, OutputUnit output) { |
| + constantMap.putIfAbsent(output, () => <String>[]) |
| + .add(value.toStructuredString()); |
| + }); |
| + |
| + StringBuffer sb = new StringBuffer(); |
| + for (OutputUnit outputUnit in allOutputUnits) { |
| + sb.write(outputUnit.name); |
| + List<String> elements = elementMap[outputUnit]; |
| + if (elements != null) { |
| + sb.write('\n elements:'); |
| + for (String element in elements..sort()) { |
| + sb.write('\n $element'); |
| + } |
| + } |
| + List<String> constants = constantMap[outputUnit]; |
| + if (constants != null) { |
| + sb.write('\n constants:'); |
| + for (String value in constants..sort()) { |
| + sb.write('\n $value'); |
| + } |
| + } |
| + } |
| + return sb.toString(); |
| + } |
| + |
| } |
| class ImportDescription { |