Skip to content

Commit 14e7e66

Browse files
scheglovCommit Queue
authored andcommitted
Linking libraries is not async anymore.
Change-Id: Id009fe12ae6283c4faa2500a86ed589d9729bb60 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407300 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent c27cec6 commit 14e7e66

File tree

5 files changed

+176
-191
lines changed

5 files changed

+176
-191
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,20 +1332,17 @@ class AnalysisDriver {
13321332
return;
13331333
}
13341334

1335-
await performance.runAsync(
1336-
'libraryContext',
1337-
(performance) async {
1338-
await libraryContext.load(
1339-
targetLibrary: library,
1340-
performance: performance,
1341-
);
1342-
},
1343-
);
1335+
performance.run('libraryContext', (performance) {
1336+
libraryContext.load(
1337+
targetLibrary: library,
1338+
performance: performance,
1339+
);
1340+
});
13441341

13451342
for (var import in library.docLibraryImports) {
13461343
if (import is LibraryImportWithFile) {
13471344
if (import.importedLibrary case var libraryFileKind?) {
1348-
await libraryContext.load(
1345+
libraryContext.load(
13491346
targetLibrary: libraryFileKind,
13501347
performance: OperationPerformanceImpl('<root>'),
13511348
);
@@ -1776,15 +1773,12 @@ class AnalysisDriver {
17761773
var kind = file.kind;
17771774
var library = kind.library ?? kind.asLibrary;
17781775

1779-
await performance.runAsync(
1780-
'libraryContext',
1781-
(performance) async {
1782-
await libraryContext.load(
1783-
targetLibrary: library,
1784-
performance: performance,
1785-
);
1786-
},
1787-
);
1776+
performance.run('libraryContext', (performance) {
1777+
libraryContext.load(
1778+
targetLibrary: library,
1779+
performance: performance,
1780+
);
1781+
});
17881782

17891783
var element = libraryContext.computeUnitElement(library, file);
17901784
var result = UnitElementResultImpl(
@@ -1877,7 +1871,7 @@ class AnalysisDriver {
18771871
var library = kind.library ?? kind.asLibrary;
18781872

18791873
// Errors are based on elements, so load them.
1880-
await libraryContext.load(
1874+
libraryContext.load(
18811875
targetLibrary: library,
18821876
performance: OperationPerformanceImpl('<root>'),
18831877
);
@@ -2012,15 +2006,12 @@ class AnalysisDriver {
20122006
var kind = file.kind;
20132007
var library = kind.library ?? kind.asLibrary;
20142008

2015-
await performance.runAsync(
2016-
'libraryContext',
2017-
(performance) async {
2018-
await libraryContext.load(
2019-
targetLibrary: library,
2020-
performance: performance,
2021-
);
2022-
},
2023-
);
2009+
performance.run('libraryContext', (performance) {
2010+
libraryContext.load(
2011+
targetLibrary: library,
2012+
performance: performance,
2013+
);
2014+
});
20242015
var unitElement = libraryContext.computeUnitElement(library, file);
20252016
var analysisOptions = libraryContext.analysisContext
20262017
.getAnalysisOptionsForFile(file.resource);

pkg/analyzer/lib/src/dart/analysis/library_context.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ class LibraryContext {
118118
}
119119

120120
/// Load data required to access elements of the given [targetLibrary].
121-
Future<void> load({
121+
void load({
122122
required LibraryFileKind targetLibrary,
123123
required OperationPerformanceImpl performance,
124-
}) async {
124+
}) {
125125
addToLogRing('[load][targetLibrary: ${targetLibrary.file}]');
126126
var librariesTotal = 0;
127127
var librariesLoaded = 0;
@@ -130,7 +130,7 @@ class LibraryContext {
130130
var bytesGet = 0;
131131
var bytesPut = 0;
132132

133-
Future<void> loadBundle(LibraryCycle cycle) async {
133+
void loadBundle(LibraryCycle cycle) {
134134
if (!loadedBundles.add(cycle)) return;
135135

136136
performance.getDataInt('cycleCount').increment();
@@ -139,7 +139,7 @@ class LibraryContext {
139139
librariesTotal += cycle.libraries.length;
140140

141141
for (var directDependency in cycle.directDependencies) {
142-
await loadBundle(directDependency);
142+
loadBundle(directDependency);
143143
}
144144

145145
var unitsInformativeBytes = <Uri, Uint8List>{};
@@ -160,16 +160,13 @@ class LibraryContext {
160160

161161
LinkResult linkResult;
162162
try {
163-
linkResult = await performance.runAsync(
164-
'link',
165-
(performance) async {
166-
return await link(
167-
elementFactory: elementFactory,
168-
performance: performance,
169-
inputLibraries: cycle.libraries,
170-
);
171-
},
172-
);
163+
linkResult = performance.run('link', (performance) {
164+
return link(
165+
elementFactory: elementFactory,
166+
performance: performance,
167+
inputLibraries: cycle.libraries,
168+
);
169+
});
173170
librariesLinked += cycle.libraries.length;
174171
} catch (exception, stackTrace) {
175172
_throwLibraryCycleLinkException(cycle, exception, stackTrace);
@@ -199,7 +196,7 @@ class LibraryContext {
199196
}
200197
}
201198

202-
await logger.runAsync('Prepare linked bundles', () async {
199+
logger.run('Prepare linked bundles', () {
203200
var libraryCycle = performance.run('libraryCycle', (performance) {
204201
fileSystemState.newFileOperationPerformance = performance;
205202
try {
@@ -208,7 +205,7 @@ class LibraryContext {
208205
fileSystemState.newFileOperationPerformance = null;
209206
}
210207
});
211-
await loadBundle(libraryCycle);
208+
loadBundle(libraryCycle);
212209
logger.writeln(
213210
'[librariesTotal: $librariesTotal]'
214211
'[librariesLoaded: $librariesLoaded]'

pkg/analyzer/lib/src/dart/micro/resolve_file.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ class FileResolver {
415415
throw ArgumentError('$uri is not a library.');
416416
}
417417

418-
await performance.runAsync('libraryContext', (performance) async {
419-
await libraryContext!.load(
418+
performance.run('libraryContext', (performance) {
419+
libraryContext!.load(
420420
targetLibrary: kind,
421421
performance: performance,
422422
);
@@ -470,7 +470,7 @@ class FileResolver {
470470
var libraryKind = file.kind.library ?? file.kind.asLibrary;
471471

472472
// Load the library, link if necessary.
473-
await libraryContext!.load(
473+
libraryContext!.load(
474474
targetLibrary: libraryKind,
475475
performance: performance,
476476
);
@@ -480,7 +480,7 @@ class FileResolver {
480480
var linkedKeysToRelease = libraryContext!.unloadAll();
481481

482482
// Load the library again, the reference count is `>= 2`.
483-
await libraryContext!.load(
483+
libraryContext!.load(
484484
targetLibrary: libraryKind,
485485
performance: performance,
486486
);
@@ -569,8 +569,8 @@ class FileResolver {
569569
var lineOffset = file.lineInfo.getOffsetOfLine(completionLine);
570570
var completionOffset = lineOffset + completionColumn;
571571

572-
await performance.runAsync('libraryContext', (performance) async {
573-
await libraryContext!.load(
572+
performance.run('libraryContext', (performance) {
573+
libraryContext!.load(
574574
targetLibrary: libraryKind,
575575
performance: performance,
576576
);
@@ -645,8 +645,8 @@ class FileResolver {
645645
var file = fileContext.file;
646646
var libraryKind = file.kind.library ?? file.kind.asLibrary;
647647

648-
await performance.runAsync('libraryContext', (performance) async {
649-
await libraryContext!.load(
648+
performance.run('libraryContext', (performance) {
649+
libraryContext!.load(
650650
targetLibrary: libraryKind,
651651
performance: performance,
652652
);

pkg/analyzer/lib/src/summary2/link.dart

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ import 'package:analyzer/src/util/performance/operation_performance.dart';
3030
import 'package:analyzer/src/utilities/extensions/element.dart';
3131
import 'package:analyzer/src/utilities/uri_cache.dart';
3232

33-
Future<LinkResult> link({
33+
LinkResult link({
3434
required LinkedElementFactory elementFactory,
3535
required OperationPerformanceImpl performance,
3636
required List<LibraryFileKind> inputLibraries,
37-
}) async {
37+
}) {
3838
var linker = Linker(elementFactory);
39-
await linker.link(
39+
linker.link(
4040
performance: performance,
4141
inputLibraries: inputLibraries,
4242
);
@@ -87,10 +87,10 @@ class Linker {
8787
return elementNodes[element.asElement];
8888
}
8989

90-
Future<void> link({
90+
void link({
9191
required OperationPerformanceImpl performance,
9292
required List<LibraryFileKind> inputLibraries,
93-
}) async {
93+
}) {
9494
performance.run('LibraryBuilder.build', (performance) {
9595
for (var inputLibrary in inputLibraries) {
9696
LibraryBuilder.build(
@@ -101,8 +101,8 @@ class Linker {
101101
}
102102
});
103103

104-
await performance.runAsync('buildOutlines', (performance) async {
105-
await _buildOutlines(
104+
performance.run('buildOutlines', (performance) {
105+
_buildOutlines(
106106
performance: performance,
107107
);
108108
});
@@ -189,19 +189,16 @@ class Linker {
189189
}
190190
}
191191

192-
Future<void> _buildOutlines({
192+
void _buildOutlines({
193193
required OperationPerformanceImpl performance,
194-
}) async {
194+
}) {
195195
_createTypeSystemIfNotLinkingDartCore();
196196

197-
await performance.runAsync(
198-
'computeLibraryScopes',
199-
(performance) async {
200-
await _computeLibraryScopes(
201-
performance: performance,
202-
);
203-
},
204-
);
197+
performance.run('computeLibraryScopes', (performance) {
198+
_computeLibraryScopes(
199+
performance: performance,
200+
);
201+
});
205202

206203
_createTypeSystem();
207204
_resolveTypes();
@@ -237,9 +234,9 @@ class Linker {
237234
}
238235
}
239236

240-
Future<void> _computeLibraryScopes({
237+
void _computeLibraryScopes({
241238
required OperationPerformanceImpl performance,
242-
}) async {
239+
}) {
243240
for (var library in builders.values) {
244241
library.buildElements();
245242
}

0 commit comments

Comments
 (0)