Skip to content

Commit 5c3b11c

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Wrap the whole AnalysisDriver._getErrors() into performance operation.
Change-Id: Icd486de53fc043554a75698450e135eee7d06099 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446560 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent abfa152 commit 5c3b11c

File tree

1 file changed

+84
-81
lines changed

1 file changed

+84
-81
lines changed

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

Lines changed: 84 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,108 +1706,111 @@ class AnalysisDriver {
17061706
}
17071707

17081708
void _getErrors(String path) {
1709-
var file = _fsState.getFileForPath(path);
1709+
scheduler.accumulatedPerformance.run('getErrors', (performance) {
1710+
var file = _fsState.getFileForPath(path);
17101711

1711-
// Prepare the library - the file itself, or the known library.
1712-
var kind = file.kind;
1713-
var library = kind.library ?? kind.asLibrary;
1712+
// Prepare the library - the file itself, or the known library.
1713+
var kind = file.kind;
1714+
var library = kind.library ?? kind.asLibrary;
17141715

1715-
// TODO(scheglov): this is duplicate
1716-
if (!_hasLibraryByUri('dart:core')) {
1717-
_errorsRequestedFiles.completeAll(
1718-
path,
1719-
_newMissingDartLibraryResult(file, 'dart:core'),
1720-
);
1721-
return;
1722-
}
1716+
// TODO(scheglov): this is duplicate
1717+
if (!_hasLibraryByUri('dart:core')) {
1718+
_errorsRequestedFiles.completeAll(
1719+
path,
1720+
_newMissingDartLibraryResult(file, 'dart:core'),
1721+
);
1722+
return;
1723+
}
17231724

1724-
// TODO(scheglov): this is duplicate
1725-
if (!_hasLibraryByUri('dart:async')) {
1726-
_errorsRequestedFiles.completeAll(
1727-
path,
1728-
_newMissingDartLibraryResult(file, 'dart:async'),
1729-
);
1730-
return;
1731-
}
1725+
// TODO(scheglov): this is duplicate
1726+
if (!_hasLibraryByUri('dart:async')) {
1727+
_errorsRequestedFiles.completeAll(
1728+
path,
1729+
_newMissingDartLibraryResult(file, 'dart:async'),
1730+
);
1731+
return;
1732+
}
17321733

1733-
// Errors are based on elements, so load them.
1734-
scheduler.accumulatedPerformance.run('libraryContext', (performance) {
1735-
libraryContext.load(targetLibrary: library, performance: performance);
1734+
// Errors are based on elements, so load them.
1735+
performance.run('libraryContext', (performance) {
1736+
libraryContext.load(targetLibrary: library, performance: performance);
17361737

1737-
for (var import in library.docLibraryImports) {
1738-
if (import is LibraryImportWithFile) {
1739-
if (import.importedLibrary case var libraryFileKind?) {
1740-
libraryContext.load(
1741-
targetLibrary: libraryFileKind,
1742-
performance: OperationPerformanceImpl('<root>'),
1743-
);
1738+
for (var import in library.docLibraryImports) {
1739+
if (import is LibraryImportWithFile) {
1740+
if (import.importedLibrary case var libraryFileKind?) {
1741+
libraryContext.load(
1742+
targetLibrary: libraryFileKind,
1743+
performance: OperationPerformanceImpl('<root>'),
1744+
);
1745+
}
17441746
}
17451747
}
1746-
}
1747-
});
1748+
});
17481749

1749-
if (withFineDependencies) {
1750-
var performance = OperationPerformanceImpl('<root>');
1751-
var fileResultBytesMap = performance.run('errors(isSatisfied)', (
1752-
performance,
1753-
) {
1754-
var reqAndUnitBytes = performance.run('getBytes', (_) {
1755-
return _byteStore.get(library.resolvedKey);
1756-
});
1750+
if (withFineDependencies) {
1751+
var fileResultBytesMap = performance.run('errors(isSatisfied)', (
1752+
performance,
1753+
) {
1754+
var reqAndUnitBytes = performance.run('getBytes', (_) {
1755+
return _byteStore.get(library.resolvedKey);
1756+
});
17571757

1758-
if (reqAndUnitBytes != null) {
1759-
var elementFactory = libraryContext.elementFactory;
1758+
if (reqAndUnitBytes != null) {
1759+
var elementFactory = libraryContext.elementFactory;
17601760

1761-
var reader = SummaryDataReader(reqAndUnitBytes);
1762-
var requirements = performance.run('readRequirements', (_) {
1763-
return RequirementsManifest.read(reader);
1764-
});
1761+
var reader = SummaryDataReader(reqAndUnitBytes);
1762+
var requirements = performance.run('readRequirements', (_) {
1763+
return RequirementsManifest.read(reader);
1764+
});
17651765

1766-
var failure = requirements.isSatisfied(
1767-
elementFactory: elementFactory,
1768-
libraryManifests: elementFactory.libraryManifests,
1769-
);
1770-
if (failure == null) {
1771-
var mapBytes = reader.readUint8List();
1772-
library.lastResolutionResult = LibraryResolutionResult(
1773-
requirements: requirements,
1774-
bytes: mapBytes,
1766+
var failure = requirements.isSatisfied(
1767+
elementFactory: elementFactory,
1768+
libraryManifests: elementFactory.libraryManifests,
17751769
);
1770+
if (failure == null) {
1771+
var mapBytes = reader.readUint8List();
1772+
library.lastResolutionResult = LibraryResolutionResult(
1773+
requirements: requirements,
1774+
bytes: mapBytes,
1775+
);
17761776

1777-
var reader2 = SummaryDataReader(mapBytes);
1778-
return reader2.readMap(
1779-
readKey: () => reader2.readUri(),
1780-
readValue: () => reader2.readUint8List(),
1781-
);
1782-
} else {
1783-
scheduler.eventsController.add(
1784-
events.GetErrorsCannotReuse(library: library, failure: failure),
1785-
);
1777+
var reader2 = SummaryDataReader(mapBytes);
1778+
return reader2.readMap(
1779+
readKey: () => reader2.readUri(),
1780+
readValue: () => reader2.readUint8List(),
1781+
);
1782+
} else {
1783+
scheduler.eventsController.add(
1784+
events.GetErrorsCannotReuse(library: library, failure: failure),
1785+
);
1786+
}
17861787
}
1788+
return null;
1789+
});
1790+
1791+
if (fileResultBytesMap != null) {
1792+
var bytes = fileResultBytesMap[file.uri]!;
1793+
var result = _createErrorsResultFromBytes(file, library, bytes);
1794+
_errorsRequestedFiles.completeAll(path, result);
1795+
return;
17871796
}
1788-
return null;
1789-
});
1797+
}
1798+
1799+
// Prepare the signature and key.
1800+
var signature = _getResolvedUnitSignature(library, file);
1801+
var key = _getResolvedUnitKey(signature);
17901802

1791-
if (fileResultBytesMap != null) {
1792-
var bytes = fileResultBytesMap[file.uri]!;
1803+
var bytes = _byteStore.get(key);
1804+
if (bytes != null) {
17931805
var result = _createErrorsResultFromBytes(file, library, bytes);
17941806
_errorsRequestedFiles.completeAll(path, result);
17951807
return;
17961808
}
1797-
}
17981809

1799-
// Prepare the signature and key.
1800-
var signature = _getResolvedUnitSignature(library, file);
1801-
var key = _getResolvedUnitKey(signature);
1802-
1803-
var bytes = _byteStore.get(key);
1804-
if (bytes != null) {
1805-
var result = _createErrorsResultFromBytes(file, library, bytes);
1806-
_errorsRequestedFiles.completeAll(path, result);
1807-
return;
1808-
}
1809-
1810-
_analyzeFile(path);
1810+
performance.run('analyzeFile', (performance) {
1811+
_analyzeFileImpl(path: path, performance: performance);
1812+
});
1813+
});
18111814
}
18121815

18131816
Future<void> _getFilesDefiningClassMemberName(

0 commit comments

Comments
 (0)