Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1930)

Unified Diff: pkg/front_end/lib/src/incremental/file_state.dart

Issue 2934933002: Build reverse dependencies between LibraryCycle(s). (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/file_state_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/incremental/file_state.dart
diff --git a/pkg/front_end/lib/src/incremental/file_state.dart b/pkg/front_end/lib/src/incremental/file_state.dart
index 87c5323f1e696f2bbccfacc23315a045b880da79..d32384d8d7798c2be9c56aaad3aa64d25678909f 100644
--- a/pkg/front_end/lib/src/incremental/file_state.dart
+++ b/pkg/front_end/lib/src/incremental/file_state.dart
@@ -399,6 +399,10 @@ class FileSystemState {
class LibraryCycle {
final List<FileState> libraries = <FileState>[];
+ /// [LibraryCycle]s that contain libraries directly import or export
+ /// this [LibraryCycle].
+ final List<LibraryCycle> directUsers = <LibraryCycle>[];
+
bool get _isForVm {
return libraries.any((l) => l.uri.toString().endsWith('dart:_vmservice'));
}
@@ -519,7 +523,7 @@ class _FileSystemViewEntry implements FileSystemEntity {
@override
Future<String> readAsString() async => _shouldNotBeQueried();
- /// _FileSystemViewEntry is used by the incremental kernel generator to
+ /// [_FileSystemViewEntry] is used by the incremental kernel generator to
/// provide Fasta with a consistent, race condition free view of the files
/// constituting the project. It should only need to be used for reading
/// file contents.
@@ -549,6 +553,7 @@ class _LibraryNode extends graph.Node<_LibraryNode> {
class _LibraryWalker extends graph.DependencyWalker<_LibraryNode> {
final nodesOfFiles = <FileState, _LibraryNode>{};
final topologicallySortedCycles = <LibraryCycle>[];
+ final fileToCycleMap = <FileState, LibraryCycle>{};
@override
void evaluate(_LibraryNode v) {
@@ -558,9 +563,30 @@ class _LibraryWalker extends graph.DependencyWalker<_LibraryNode> {
@override
void evaluateScc(List<_LibraryNode> scc) {
var cycle = new LibraryCycle();
+
+ // Build the set of cycles this cycles directly depends on.
Paul Berry 2017/06/12 22:19:45 s/this cycles/this cycle/
+ var directDependencies = new Set<LibraryCycle>();
+ for (var node in scc) {
+ var file = node.file;
+ for (var importedLibrary in file.importedLibraries) {
+ var importedCycle = fileToCycleMap[importedLibrary];
+ if (importedCycle != null) directDependencies.add(importedCycle);
+ }
+ for (var exportedLibrary in file.exportedLibraries) {
+ var exportedCycle = fileToCycleMap[exportedLibrary];
+ if (exportedCycle != null) directDependencies.add(exportedCycle);
+ }
+ }
+
+ // Register this cycle as a direct user of the direct dependencies.
+ for (var directDependency in directDependencies) {
+ directDependency.directUsers.add(cycle);
+ }
+
for (var node in scc) {
node.isEvaluated = true;
cycle.libraries.add(node.file);
+ fileToCycleMap[node.file] = cycle;
}
topologicallySortedCycles.add(cycle);
}
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698