Skip to content

Commit

Permalink
remove old way of collecting dependencies for dump-info
Browse files Browse the repository at this point in the history
The new way of collecting dependencies covers everything from
the old way, and does not have any spurious dependencies that
the old way had.

Fixes #28849

R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2709043002 .
  • Loading branch information
harryterkelsen committed Feb 22, 2017
1 parent 442e384 commit fce2935
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
40 changes: 20 additions & 20 deletions pkg/compiler/lib/src/dump_info.dart
Expand Up @@ -419,21 +419,15 @@ class DumpInfoTask extends CompilerTask implements InfoReporter {
}

void reportInlined(Element element, Element inlinedFrom) {
element = element.declaration;
inlinedFrom = inlinedFrom.declaration;

inlineCount.putIfAbsent(element, () => 0);
inlineCount[element] += 1;
inlineMap.putIfAbsent(inlinedFrom, () => new List<Element>());
inlineMap[inlinedFrom].add(element);
}

final Map<Element, Set<Element>> _dependencies = {};
void registerDependency(Element target) {
if (compiler.options.dumpInfo) {
_dependencies
.putIfAbsent(compiler.currentElement, () => new Set())
.add(target);
}
}

void registerImpact(Element element, WorldImpact impact) {
if (compiler.options.dumpInfo) {
impacts[element] = impact;
Expand Down Expand Up @@ -552,6 +546,8 @@ class DumpInfoTask extends CompilerTask implements InfoReporter {
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();

AllInfo result = infoCollector.result;

// Recursively build links to function uses
Iterable<Element> functionElements =
infoCollector._elementToInfo.keys.where((k) => k is FunctionElement);
Expand All @@ -566,6 +562,21 @@ class DumpInfoTask extends CompilerTask implements InfoReporter {
info.uses.add(new DependencyInfo(useInfo, '${selection.mask}'));
}
}

// Recursively build links to field uses
Iterable<Element> fieldElements =
infoCollector._elementToInfo.keys.where((k) => k is FieldElement);
for (FieldElement element in fieldElements) {
FieldInfo info = infoCollector._elementToInfo[element];
Iterable<Selection> uses = getRetaining(element, closedWorld);
// Don't bother recording an empty list of dependencies.
for (Selection selection in uses) {
Info useInfo = infoCollector._elementToInfo[selection.selectedElement];
if (useInfo == null) continue;
info.uses.add(new DependencyInfo(useInfo, '${selection.mask}'));
}
}

// Notify the impact strategy impacts are no longer needed for dump info.
compiler.impactStrategy.onImpactUsed(IMPACT_USE);

Expand All @@ -580,17 +591,6 @@ class DumpInfoTask extends CompilerTask implements InfoReporter {
}
}

AllInfo result = infoCollector.result;

for (Element element in _dependencies.keys) {
var a = infoCollector._elementToInfo[element];
if (a == null) continue;
result.dependencies[a] = _dependencies[element]
.map((o) => infoCollector._elementToInfo[o])
.where((o) => o != null)
.toList();
}

result.deferredFiles = compiler.deferredLoadTask.computeDeferredMap();
stopwatch.stop();
result.program = new ProgramInfo(
Expand Down
4 changes: 0 additions & 4 deletions pkg/compiler/lib/src/js_backend/backend.dart
Expand Up @@ -2693,10 +2693,6 @@ class CodegenEnqueuerListener extends EnqueuerListenerBase {
WorldImpactBuilderImpl worldImpact = new WorldImpactBuilderImpl();
_registerUsedElement(worldImpact, member, forResolution: false);

// TODO(sigmund): add other missing dependencies (internals, selectors
// enqueued after allocations).
dumpInfoTask.registerDependency(member);

return worldImpact;
}

Expand Down

0 comments on commit fce2935

Please sign in to comment.